TITLE "A Hello-World Program" USE "hawk.h" USE "monitor.h" ; activation record and interface for myputs ;RETAD = 0 ; return address R8SAVE = 4 ; save value in R8 ARSIZE = 8 MYPUTS: ; expects R3 = p ; pointer to string to print STORES R1,R2 STORE R8,R2,R8SAVE ; -- make room for p MOVE R8,R3 ; -- move p to R8 ADDI R2,R2,ARSIZE MYLOOP: ; loop { LOADS R3,R8 ; -- get word holding *p EXTB R3,R3,R8 ; ch = *p BZS MYEXIT ; if (ch == NUL) break ADDSI R8,1 ; p = p + 1 ; ; -- parameter LIL R1,PUTCHAR JSRS R1,R1 ; putchar(ch) BR MYLOOP ; } MYEXIT: ADDI R2,R2,-ARSIZE LOAD R8,R2,R8SAVE LOADS R1,R2 JUMPS R1 ; return SUBTITLE"Main Program" ; activation record and interface for main ARSIZE = 4 ; just a return address INT MAIN S MAIN MAIN: ; entry point STORES R1,R2 ADDI R2,R2,ARSIZE ; --- begin aplication code --- LIL R3,HELLO LIL R1,MYPUTS JSRS R1,R1 ; puts(HELLO) ; --- end aplication code --- ADDI R2,R2,-ARSIZE LOADS R1,R2 JUMPS R1 ; return ; --- begin aplication constants --- HELLO: ASCII "Hello world!",0 END