TITLE "MP3 -- by Douglas Jones, lightly optimized version" USE "hawk.h" USE "stdio.h" EXT MP3DATA INT MAIN S MAIN ; AR for PUTMSG, the recursive routine to traverse the message tree ;RETAD = 0 N = 4 ; pointer used to index through a tree node ARSIZE = 8 PUTMSG: ; expects R3 = n, a pointer to a tree node ; returns nothing ; uses R3 for various purposes STORES R1,R2 STORE R3,R2,N ; -- move n to activation record PUTLOOP: ; for (;;) { LOAD R3,R2,N ; LOADS R3,R3 ; int p = *n TESTR R3 BZS PUTQUIT ; if (p == NULL) break BITTST R3,0 BBS ODDADDR ; if ((p & 1) == 0) { -- p is even ADDI R2,R2,ARSIZE ; -- note p is still in R3 JSR R1,PUTMSG ADDI R2,R2,-ARSIZE ; putmsg( p ) -- traverse a subtree BR ENDIF ODDADDR: ; } else { -- p is odd ADDI R2,R2,ARSIZE ; -- note p is still in R3 LIL R1,PUTSTR JSRS R1,R1 ADDI R2,R2,-ARSIZE ; putstr( p ) -- output a leaf string ENDIF: ; } LOAD R3,R2,N ADDSI R3,4 STORE R3,R2,N ; n++ BR PUTLOOP PUTQUIT: ; } LOADS PC,R2 ; return ; AR for MAIN ;RETAD = 0 ARSIZE = 4 MAIN: ; expects nothing ; returns nothing ; uses R3 STORES R1,R2 ADDSI R2,4 LIL R3,MP3DATA JSR R1,PUTMSG ADDSI R2,-4 ; putmsg( mp3data ) LOADS PC,R2 ; return END