TITLE "text.a -- text processing demo" ; by Douglas Jones USE "hawk.h" USE "monitor.h" S MAIN INT MAIN SUBTITLE "main program" ;AR for main ;RETAD = 0 ARSIZE = 4 ;body of main MAIN: STORES R1,R2 LEA R3,HELLO ADDI R2,R2,ARSIZE JSR R1,MYPUTS ; myputs( HELLO ) ADDI R2,R2,-ARSIZE LOADS R1,R2 JUMPS R1 ;constants used by main HELLO: ASCII "hello world",0 SUBTITLE "myputs" ;AR for myputs ;RETAD = 0 S = 4 I = 8 CH = 12 ARSIZE = 16 ;code for myputs MYPUTS: ; expects R3 = s -- pointer to string STORES R1,R2 STORE R3,R2,S LIS R3,0 STORE R3,R2,I ; i = 0 MYPLP: ; for (;;) { LOAD R3,R2,S LOAD R4,R2,I ADD R3,R3,R4; -- R3 is address of s[i] LOADS R4,R3 ; -- R4 is word holding s[i] EXTB R3,R4,R3 STORE R3,R2,CH; ch = s[i] LOAD R3,R2,CH CMPI R3,0 BEQ MYPQT ; if (ch == 0) break LOAD R3,R2,CH; -- param ADDI R2,R2,ARSIZE LIL R1,PUTCHAR JSRS R1,R1 ; putchar( ch ) ADDI R2,R2,-ARSIZE LOAD R3,R2,I ADDI R3,R3,1 STORE R3,R2,I ; i = i + 1 BR MYPLP ; } MYPQT: LOADS R1,R2 JUMPS R1 ; return END