program binary_shifts;
#include( "stdlib.hhf" )
// Phil Gardner
begin binary_shifts;
// Base 10 number to be converted to 7-bit binary
mov( 45, ax );
// Start at leftmost column
mov( 64, cl );
stdout.put( nl, "Convert " );
stdout.puti16( ax );
stdout.put( " to 7-bit binary:" );
stdout.put( nl );
processColumn:
// Determine whether this column fits into number
// Divides ax by cl
div( cl );
stdout.put( nl, "Place value in cl " );
stdout.puti8( cl );
stdout.put( stdio.tab, "quotient in al " );
stdout.puti8( al );
stdout.put( stdio.tab, "modulo in ah " );
stdout.puti8( ah );
// Expand the modulo into ax
mov( ah, al );
cbw();
// Update place value to use for next column
shr( 1, cl );
// Decide whether all columns now completed
cmp( cl, 0 );
jg processColumn;
finished:
stdout.put( nl, nl, "Finished.", nl );
end binary_shifts;