TITLE "hello.c -- a hello world program with a for loop" USE "hawk.h" USE "ascii.h" USE "stdio.h" INT MAIN S MAIN MAIN: ; entry to main STORES R1,R2 ADDSI R2,4 ; ------- application code ; ; -- really for(counter=0; counter<5; counter++) LIS R8,0 ; counter = 0 LOOP: ; for (;;) { -- infinite with exit by break ; LIS R9,5 ; v1: unreadable ; SUB R0,R8,R9 ; -- compare ; LIS R9,5 ; v2: self explanatory ; CMP R8,R9 CMPI R8,5 ; v3: saves one register BGE QUIT ; if (counter >= 5) break MOVE R3,R8 ; -- parameter counter LIS R4,5 ; -- parameter width LIL R1,PUTDEC JSRS R1,R1 ; putdec( counter, 5 ) LIL R3,HELLO ; -- parameter LIL R1,PUTSTR JSRS R1,R1 ; putstr( hello ) ADDSI R8,1 ; counter++ BR LOOP QUIT: ; } ; ------- end application code ADDSI R2,-4 LOADS PC,R2 ; return ; ------- application constants HELLO: ASCII " Hello World",LF,NUL ; ------- end application constants END