Question: Modify the dateDemo program. Instead of 16 bit short packed date format, use 32 bit long packed date format. Accept as input 4 digit year

 Modify the dateDemo program. Instead of 16 bit short packed date

Modify the dateDemo program.

Instead of 16 bit short packed date format, use 32 bit long packed date format.

Accept as input 4 digit year full year, month number, and day

Prompt user by "Enter your birthdate (full year, month, day): "

Read input as integers. Do computations and conversions and then output the result as a 32-bit hexadecimal number

Example:

Input: March 26, 1948. (input: 1948, 3, 26). Output will be 079C031A.

Input: October 12, 1957 (input: 1957, 10, 12). Output will be 07A50A0C

program dateDemo;

#include( "stdlib.hhf" )

static

day: uns8; month: uns8; year: uns8; packedDate: word;

begin dateDemo;

stdout.put("Enter the current month, day, and year: "); stdin.get(month, day, year);

// pack the data into the following bits: // // 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 // m m m m d d d d d y y y y y y y

mov(0, ax);

mov(ax, packedDate); //just in case there is error.

if(month > 12) then stdout.put("Month value is too large", nl);

elseif(month = 0) then stdout.put( "Month value must be in the range 1..12", nl );

elseif( day > 31 ) then stdout.put( "Day value is too large", nl );

elseif(year > 99) then stdout.put( "Year value must be in the range 0..99", nl );

else mov( month, al ); shl( 5, ax ); or( day, al ); shl( 7, ax ); or( year, al ); mov( ax, packedDate );

endif;

// Okay, display the packed value: stdout.put( "Packed data = $", packedDate, nl );

// Unpack the date: mov( packedDate, ax ); and( $7f, al ); // Retrieve the year value. mov( al, year );

mov( packedDate, ax ); // Retrieve the day value. shr( 7, ax ); and( %1_1111, al ); mov( al, day );

mov( packedDate, ax ); // Retrieve the month value. rol( 4, ax ); and( %1111, al ); mov( al, month );

stdout.put( "The date is ", month, "/", day, "/", year, nl );

end dateDemo;

Read month into a byte Read day into a byte Read 4-digit year into a word. Project 2: Combine month, day and year in a double word as long packed date. Then break long packed date into month, day and year parts. 1. 2. Example: July 22, 1985 0 0 0 0 0 1 1 1 month %0000_0111 day 960001-0110 year-60000 0111-1100 0001 month day 000 1 0 1 1 0 year= | 0| 0| 0| 0| 0| 1| 1| 1| 1| 1| 0| 0| 0| 0| 0| 1 Pack the month, day, and year into a double-word as shown below. packedDate= | 0| 0| 0| 0| 0| 1| 1| 1| 1| 1| 0| 0| 0| 0| 0| 1 0 0 0 0 0 11 1 0 0 0 1 0 1 1 0 Prompt to read all three elements as follow: "Enter year (YYYY), month, and day : Also, make sure that your program do not reject 4-digit number for year

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!