Question 3: (back)

Write a program that generates a "Powers of Four" table. Note that you can create the powers of four by loading a register with one and then successively add that register to itself twice for each power of two.

program Question3;

#include( "stdlib.hhf" );

static
    PwrOf4:     int32;
    LoopCntr:   int32;

begin Question3;
    stdout.put( "Powers of four:", nl, nl );
    
    mov( 1, PwrOf4 );
    
    mov( 0, LoopCntr );
    while( LoopCntr < 10 ) do
        stdout.put( "4^", LoopCntr:2, " = ", PwrOf4:10, nl );
        
        mov( PwrOf4, eax );
        add( eax, eax );
        add( eax, eax );
        mov( eax, PwrOf4 );
        
        inc( LoopCntr );
    endwhile;
    stdout.newln();

end Question3;