Question 9: (back)
Write a program that reads a 32-bit unsigned integer from the user and displays this value in binary. Use the SHL instruction to perform the integer to binary conversion.
program Question9;
#include( "stdlib.hhf" );
static
a: uns32;
cnt: int8;
cnt2: int8;
begin Question9;
stdout.put( "Enter a number: " );
stdin.getu32();
mov( 0, cnt );
mov( 0, cnt2 );
while( cnt < 32 ) do
if( cnt2 = 4 ) then
stdout.put( "_" );
mov( 0, cnt2 );
endif;
shl( 1, eax );
if( @c ) then
stdout.put( "1" );
else
stdout.put( "0" );
endif;
inc( cnt );
inc( cnt2 );
endwhile;
end Question9;