Question 3: (back)
Write a program that reads three values from the user: a month, a day, and a year. Pack the date into the long date format appearing in this chapter and display the result in hexadecimal. If the date is between 2000 and 2099, also pack the date into the short packed date format and display that 16-bit value in hexadecimal form. If the date is not in the range 2000..2099, then display a short message suggesting that the translation is not
possible.
program Question3; #include( "stdlib.hhf" ); static day: uns8; month: uns8; year: uns16; PackedDate: dword; begin Question3; stdout.put( "Enter month day year: " ); stdin.get( day, month, year ); mov( 0, eax ); mov( eax, PackedDate ); mov( year, ax ); shl( 8, eax ); or( month, al ); shl( 8, eax ); or( day, al ); mov( eax, PackedDate ); stdout.put( "Entered: ", day, " ", month, " ", year, nl ); stdout.put( "Ouput: ", PackedDate, nl ); mov( PackedDate, eax ); and( $8f, al ); mov( al, day ); shr( 8, eax ); and( $8f, al ); mov( al, month ); shr( 8, eax ); mov( ax, year ); stdout.put( "The date is ", day, "-", month, "-", year, nl ); end Question3;