TITLE "MP2 by Douglas Jones" ; a program to traverse a binary tree and print the strings in it. USE "hawk.h" USE "stdio.h" ; record structure for binary tree nodes ; LEFT ; DATA -- all 3 fields are defined by the header file included at the end ; RIGHT ; root of the binary tree ; ROOT -- an address defined by the header file included at the end ; activation record for TRAVERS ;RETAD = 0 R8SAVE = 4 ARSIZE = 8 TRAVERS:; expects R3 = p, pointer to the root ; returns nothing ; void travers( node * p ) { TESTR R3 BZS TRAVQT ; if (p != NULL) { STORES R1,R2 ; -- deferred receiving sequence STORE R8,R2,R8SAVE ; -- saves R8 for local use as p ADDSI R2,ARSIZE MOVE R8,R3 ; -- move p LOAD R3,R8,LEFT ; -- param JSR R1,TRAVERS ; travers( p->left ) LOAD R3,R8,DATA ; -- param LIL R1,PUTSTR JSRS R1,R1 ; putstr( p->data ) LOAD R3,R8,RIGHT ; -- param JSR R1,TRAVERS ; travers( p->right ) ADDSI R2,-ARSIZE LOAD R8,R2,R8SAVE ; -- recover R8 LOADS R1,R2 ; -- early partial return sequence TRAVQT: ; } -- end of if JUMPS R1 ; } -- end of travers ; activation record for MAIN ;RETAD = 0 ARSIZE = 4 S MAIN INT MAIN MAIN: ; void main() { STORES R1,R2 ADDSI R2,ARSIZE ; -- normal receiving sequence LIL R3,ROOT ; --parameter JSR R1,TRAVERS ; travers( root ) ADDSI R2,-ARSIZE ; -- normal return sequence LOADS R1,R2 JUMPS R1 ; } ; the assignment said to put the following at the very end USE "/mnt/nfs/clasnetappvm/fs3/dwjones/2630mp2.h" END