ORG 0 ; Position independent .oswrch EQU 4 ; TUBE Character output routine ;.oswrch EQU 225 ; RT11 Character output routine ; Print 32-bit number with decimal fraction ; ========================================= ; On entry: R0=number b0-b15 ; R1=number b16-b31 ; R2=number of decimal places ; On exit: R0,R1,R2,R3 corrupted ; Size: 76 bytes ; .prdecimal CLR -(SP) ; Stack terminator TST R2 BEQ prdeclp2 ; No decimal places .prdeclp1 JSR PC,divide10 MOV R3,-(SP) ; Stack digit DEC R2 BNE prdeclp1 ; Do decimal places MOV #ASC".",-(SP) ; Stack a decimal point .prdeclp2 JSR PC,divide10 MOV R3,-(SP) ; Stack digit MOV R1,R3 BIS R0,R3 BNE prdeclp2 ; Loop until number is zero .prdeclp3 MOV (SP)+,R0 ; Pop digit off BEQ done ; Terminator, all done EMT oswrch ; Print digit BR prdeclp3 ; Loop for another ; Divide by 10 without using DIV ; ------------------------------ ; On entry: R0=number b0-b15 ; R1=number b16-b31 ; On exit: R0=result b0-b15 ; R1=result b16-b31 ; R3=remainder as ASCII character ; .divide10 CLR R3 ; Clear accumulator MOV #32,-(SP) ; Shift counter .div10lp1 ASL R0 ; Perform the division ROL R1 ROL R3 CMP R3,#10 BLO div10lp2 SUB #10,R3 INC R0 .div10lp2 DEC (SP) BNE div10lp1 ; Not done? BIS #ASC"0",R3 ; Convert digit to ascii TST (SP)+ ; Clear stack .done RTS PC