TITLE "MP2 by Douglas Jones, version b" ; calls SHOWITEM for each item in a linked list of items, ; where ITEM1 is the address of the first item, and ; each item has a structure as documented below ; (after the boilerplate and linkage sections). S START USE "hawk.macs" USE "monitor.h" COMMON STACK,#1000 PSTACK: W STACK ; ----------------- linkage ------------------ EXT ITEM1 PITEM1: W ITEM1 ; link to the data structures from mp1 EXT SHOWITEM PSHOWITEM: W SHOWITEM; link to the code in mp2test.o ; ------------ fields of one item ------------ NEXT = 0 ; pointer to next item in list X = 4 ; X coordinate of this item Y = 8 ; Y coordinate of this item WIDTH = 12 ; width of this item HEIGHT = 16 ; height of this item TEXT = 20 ; pointer to text of this item or null SUBTITLE "main program" ; -------------------------------------------- START: LOAD R2,PSTACK ; set up the stack LOAD R1,PDSPINI JSRS R1,R1 ; initialize the display LOAD R3,PITEM1 JSR R1,SHOWITEMS ; display all the items LOAD R1,PEXIT JSRS R1,R1 ; call monitor routine to stop! SUBTITLE "SHOWITEMS -- traverse list of items" ; -------------------------------------------- RETAD = 0 ITEM = 4 ARSIZE = 8 SHOWITEMS: ; expects R3 = item pointer STORES R1,R2 STORE R3,R2,ITEM SHOWLOOP: ; for (;;) { TEST R2,ITEM ; if BZS SHOWQUIT ; (item == NULL) break; LOAD R3,R2,ITEM ADDI R2,R2,ARSIZE LOAD R1,PSHOWITEM JSRS R1,R1 ; call showitem( p ) ADDI R2,R2,-ARSIZE LOAD R3,R2,ITEM LOAD R3,R3,NEXT ; item = next->next; STORE R3,R2,ITEM BR SHOWLOOP SHOWQUIT: ; } LOADS R1,R2 JUMPS R1 ; return END