;+ ; ; Routine to print a number using TSS/8's BCD method. ; On non-EIS machines this is much faster than dividing ; by 10. for each digit, although it's probably a loss ; on machines with EIS. ; ; Takes number in r5. ; ; 04-Nov-90 JMBW Created. ; ;- .mcall .ttyout decout: mov #10421,r2 ;magic bits (1 every 4) mov #dectab,r3 ;pt at table br 30$ ;jump into loop 5$: ; next digit clr r0 ;clear it 10$: asl r0 ;*2 cmp r1,r5 ;OK? bhi 20$ ;no (C=0) sub r1,r5 ;remove the bit (C=0) inc r0 ;count it 20$: ror r1 ;/2 (C=0 either way above) asl r2 ;magic bits left adc r2 ;C to bit 0 bpl 10$ ;loop bis #'0,r0 ;cvt to ascii .ttyout ;display 30$: mov (r3)+,r1 ;get next value bne 5$ ;loop if non-zero mov r5,r0 ;copy last bis #'0,r0 ;cvt to ascii .ttyout ;and display rts pc ; dectab: .word 40000.,8000.,800.,80.,0 ; .end start