Question 7: (back)
Write a program that reads an eight-bit signed integer and a 32-bit signed integer from the user that computes and displays the sum and difference of these two numbers.
program Question7; #include( "stdlib.hhf" ); static a: int8; b: int32; c: int32; // total d: int32; // difference begin Question7; stdout.put( "Please enter an integer between -128..127: " ); stdin.get( a ); stdout.put( nl, "Please enter an integer from -2,146,483,648..2,146,483,647: " ); stdin.get( b ); mov( a, al ); cbw(); // convert al to ax cwde(); // convert ax to eax mov( b, ebx ); mov( ebx, c ); mov( ebx, d ); add( eax, c ); // calculate sum of 'a' and 'b' sub( eax, d ); // calculate difference of 'b' and 'a' stdout.put( "a + b = ", c, nl ); stdout.put( "b - a = ", d, nl ); end Question7;