TITLE "mp2sol2.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 X = 0 ; the X coordinate of text Y = 4 ; the Y coordinate of text TEXT = 8 ; the text ; --- 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 { LOADSCC R9,R8 ; p = array entry a BZS QUIT ; if (p == NULL) break LOAD R3,R9,X ; -- parameter = p->x LOAD R4,R9,Y ; -- parameter = p->y LIL R1,PUTAT JSRS R1,R1 ; call putat( p->x, p->y ) LEA R3,R9,TEXT ; -- parameter = @p->text LIL R1,PUTS ; call puts( @p->x ) JSRS R1,R1 ADDSI R8,4 ; point p to the next array entry BR LOOP ; } QUIT: ; --- end of application code, resume boilerplate code ADDI R2,R2,-ARSIZE LOADS R1,R2 JUMPS R1 END