I'm trying to take in a byte of information, really number and compare them. My comparisons are generating the wrong input. Here's the code.
program dateDemo;
#include ("stdlib.hhf")
static
dayR: byte;
monthR: byte;
yearR: word;
day: uns8;
month: uns8;
year: uns16;
packedDate: dword;
begin dateDemo;
stdout.put( "Enter the current month, day, and year: " );
stdin.get( monthR, dayR, yearR );
mov( 0, eax );
mov(0, bx);
mov( eax, packedDate ); // Just in case there is an error.
mov(monthR, ah);
mov(ah, month);
mov(dayR, al);
mov(al, day);
mov(yearR, bx);
mov(bx, 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
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
stdout.put("It worked");
/*mov( month, al );
shl( 5, ax );
or( day, al );
shl( 7, ax );
or( year, al );
mov( ax, packedDate );*/
endif;
I left out some code that doesn't matter. If I enter, "10 20 1997" it outputs, "Month is too large" I tried to do the comparison with an uns8 instead of hte byte information but to no avail. Can anyone give me tips.
Also my year will go up to 2000 so it will use a whole 16-bit word.