TITLE "MP4 by Douglas W. Jones" USE "hawk.h" USE "monitor.h" BUFLEN = 4 ; buffer length, must be a multiple of 4 SUBTITLE "INTTOS -- integer to string converter" --- no code will be given for this part until after the due date for mp5 --- SUBTITLE "MAIN -- test program for inttos" INT MAIN S MAIN ; activation record structure ;RETAD = 0 BUFFER = 4 ; a buffer passed to INTTOS ARSIZE = 4 + BUFLEN ; code MAIN: ; ignores its parameters ; uses R8 = i -- iteration counter ; R9 = a -- a Fibonacci number ; R10 = b -- successor of a in Fibonacci series STORES R1,R2 LIS R8,0 ; i = 0 LIS R9,0 ; a = 0 LIS R10,1 ; b = 1 MAINLP: ; loop { ADDSI R8,1 ; i = i + 1 LEA R3,R2,BUFFER ; -- parameter buf = buffer LIS R4,BUFLEN ; -- parameter len = buflen MOVE R5,R9 ; -- parameter num = a MOVE R6,R8 ; -- parameter base = i ADDI R2,R2,ARSIZE JSR R1,INTTOS ; s = inttos( buffer, buflen, a, i ) ; -- parameter s already in R3 LIL R1,PUTS JSRS R1,R1 ; puts( s ) LIS R3,' ' ; -- parameter LIL R1,PUTCHAR ADDI R2,R2,-ARSIZE JSRS R1,R1 ; putchar( ' ' ); ADD R1,R9,R10 ; temp = a + b MOVE R9,R10 ; a = b MOVE R10,R1 ; b = temp CMPI R8,33 BLT MAINLP ; } until (i >= 33) LOADS R1,R2 JUMPS R1 ; return