TITLE "decimal print routine" ; subroutine to print a decimal number ; activation record structure RETAD = 0 REM = 4 ARSIZE = 8 ; receiving sequence DSPNUM: ; expects R3 -- number to print ; R1 -- return address STORE R1,R2,RETAD ; body begins here CMPI R3,9 BLE DSPNO ; if (number > 9) ; parameter 1, dividend = number LIS R4,10 ; parameter 2, divisor = 10 ADDI R2,R2,ARSIZE ; push AR LIL R1,DIVU JSRS R1,R1 ; call divu(number,10) ADDI R2,R2,-ARSIZE ; pop AR ; returns quotient in R3 ; returns remainder in R4 ; parameter 1, number = quotient STORE R4,R2,REM ; store remainder in rem ADDI R2,R2,ARSIZE ; push AR JSR R1,DSPNUM ; call dspnum(number) ADDI R2,R2,-ARSIZE ; pop AR LOAD R3,R2,REM ; recover number from rem DSPNO: ; endif ADDI R3,'0' ; convert number to character ; parameter 1, number ADDI R2,R2,ARSIZE ; push AR LIL R1,DSPCH JSRS R1,R1 ; call dspch(number) ADDI R2,R2,-ARSIZE ; pop AR ; return sequence LOAD R1,R2,RETAD JUMPS R1