TITLE "mp2sol1.a by Douglas Jones" ; outputs text on the screen from a data ; structure separately assembled into memory. USE "hawk.h" USE "monitor.h" INT MAIN S MAIN ; activation record format ;RETAD = 0 ARSIZE = 4 ; --- end of boilerplate declarations, start application declarations EXT ARRAY ; addr of first word of array ; each word points to a record ; the last word is a null pointer ; format of each record pointed to from ARRAY ; the first word is the X coordinate of text ; the second word is the Y coordinate of text ; the third word begins the start of the null-terminated text string ; --- start of boilerplate code MAIN: STORES R1,R2 ADDI R2,R2,ARSIZE ; --- end of boilerplate code, start application code LIL R8,ARRAY ; -- R8 points to array entry a LOOP: ; do { LOADS R9,R8 ; p = *a -- contents of array entry a CMPI R9,0 BEQ QUIT ; if (p == NULL) break LOADS R3,R9 ; -- parameter = *p -- first word, x ADDSI R9,4 ; p++ -- advance to second word LOADS R4,R9 ; -- parameter = *p -- second word, y ADDSI R9,4 ; p++ -- advance to second word LIL R1,PUTAT JSRS R1,R1 ; call putat( x, y ) MOVE R3,R9 ; -- parameter = p LIL R1,PUTS ; call puts( p ) JSRS R1,R1 ADDSI R8,4 ; a++ -- point at next array entry BR LOOP ; } QUIT: ; --- end of application code, resume boilerplate code ADDI R2,R2,-ARSIZE LOADS R1,R2 JUMPS R1 END