ô > 6502.ProgTips.PrtDecDemo : ô OS Entries: (OSWRCH=&FFEE 2: <ô Memory locations: F PRPAD=&70:PRTEMP=&71:NUM=&74 P: Z Þ mc% 60 d ã P=0 ¸ 1 nP%=mc%:O%=P% x[OPT P*3+4 ‚(\ Print arbitary size decimal number Œ(\ ================================== –J\ Prints decimal number by pushing digits in reverse order onto stack.  \ ª1\ See forum.6502.org/viewtopic.php?f=2&t=4894 ´;\ and groups.google.com/g/comp.sys.apple2/c/_y27d_TxDHA ¾\ È3\ On entry X=>base of four zero page locations Ò?\ Y= number of digits to pad to, 0 for no padding Ü*\ On exit 0,X to 3,X are set to zero æ\ X preserved ð\ A,Y corrupted ú*\ Uses PRPAD = to hold pad count $\ PRTEMP = bit counter \ Size 55 bytes \ "J\ This can display an arbitary number of digits from an arbitary-sized ,E\ number by just increasing or decreasing the number of zero page 6F\ locations used at label PRDEC10 and the bit count at PRDECDIGIT. @\ JC.PRDEC STY PRPAD \ Number of padding+digit characters T. LDY #0 \ Digit counter ^..PRDECDIGIT LDA #32 \ 32-bit divide h STA PRTEMP r, LDA #0 \ Remainder=0 |< CLV \ V=0 means divide result = 0 †3.PRDECDIV10 CMP #10/2 \ Calculate OSNUM/10  BCC PRDEC10 šN SBC #10/2+&80 \ Remove digit & set V=1 to show div result > 0 ¤8 SEC \ Shift 1 into div result ®<.PRDEC10 ROL 0,X \ Shift /10 result into OSNUM ¸L ROL 1,X \ The number of locations must match the bits Â2 ROL 2,X \ set at PRDECDIGIT Ì ROL 3,X ÖL ROL A \ Shift bits of input into acc (input mod 10) à DEC PRTEMP ê7 BNE PRDECDIV10 \ Continue 32-bit divide ô6 „A #—"0" \ Convert to —II character þ< PHA \ Push low digit 0-9 to print : INY \ Increase number of digits L BVS PRDECDIGIT \ If V=1, result of /10 was >0, do next digit . LDA #—" " \ Pad with spaces &.PRDECLP1 CPY PRPAD 06 BCS PRDECLP2 \ Enough padding pushed :> PHA \ Push leading space characters D INY N BNE PRDECLP1 X<.PRDECLP2 PLA \ Pop character left to right b) JSR OSWRCH \ Print it l DEY v BNE PRDECLP2 € RTS ŠG\ ----------------------------------------------------------------- ”]:í ž: ¨õ ²$è "Enter test number: "A% ¼$è "Number of padding digits: "B% Æ/ñ "PRDEC: ";:!NUM=A%:X%=NUM:Y%=B%:Ö PRDEC:ñ Ðý £ ÿ