Question: HLA programming I am trying to modify the code below from 16-bit short packed date format to 32-bit, long packed date format, which i assume

HLA programming

I am trying to modify the code below from 16-bit short packed date format to 32-bit, long packed date format, which i assume I will have to envolve "eax" the register.

The code below intakes an input of a date in the format (MM, DD, YY) and outpiut the hexadecimal format which can be managed by a 16-bit packed data. But we are required to intake an input of a date in the format (YYYY, MM, DD) and pref orm the same function but this requires more than 16 bit so we are supposed to use a 32 bit pakage which will require us to invlove eax for an additional 16 bit of storage. (i.e. Input: March 26, 1948. (input: 1948, 3, 26), Output will be 079C031A)

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 an 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( day = 0 ) then stdout.put( "Day value must be in the range 1..31", 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;

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!