mirror of
https://github.com/RevCurtisP/C02.git
synced 2024-11-22 01:31:33 +00:00
Added Left and Right Justified Decimal to stdiox.a02
This commit is contained in:
parent
a1294860cd
commit
90134a4009
@ -6,21 +6,19 @@ PUTDEL: STA TEMP3
|
||||
PUTDEM: JSR PUTDEC ;Alternate Entry Point
|
||||
LDA TEMP3
|
||||
PUTDEH: CMP #100
|
||||
BCS PUTDE0
|
||||
BCS PUTDET
|
||||
JSR PUTSPC
|
||||
PUTDE0: CMP #10
|
||||
LDA TEMP3
|
||||
PUTDET: CMP #10
|
||||
BCS PUTDEX
|
||||
JSR PUTSPC
|
||||
PUTDEX: RTS
|
||||
|
||||
;Print Byte as Right Justified Decimal Number
|
||||
;putder(b)
|
||||
PUTDER: CMP #100
|
||||
BCS PUTDE0
|
||||
JSR PUTSPC
|
||||
PUTDE0: CMP #10
|
||||
BCS PUTDEC
|
||||
JSR PUTSPC
|
||||
PUTDER: STA TEMP3
|
||||
PUTDES: JSR PUTDEH
|
||||
LDA TEMP3
|
||||
;Print Byte as Decimal Number
|
||||
;putdec(b)
|
||||
PUTDEC: JSR CUBCD ;Convert Accumulator to Unpacked BCD
|
||||
@ -38,12 +36,9 @@ PUTDEP: ORA #$30 ;Convert to ASCII digit
|
||||
RTS
|
||||
|
||||
;Print a Space
|
||||
PUTSPC: PHA ;Save Accumulator
|
||||
LDA #32 ;Load Space Character
|
||||
JSR PRCHR ;and Print it
|
||||
PLA ;Restore Accumulator
|
||||
RTS
|
||||
|
||||
PUTSPC: LDA #32 ;Load Space Character
|
||||
JMP PRCHR ;and Print it
|
||||
|
||||
;Print Byte in Formatted String
|
||||
;printf(b, &s)
|
||||
PRINTF: JSR SETSRC ;Initialize Source String
|
||||
@ -63,20 +58,25 @@ PRINTS: INY ;Increment Offset
|
||||
CMP #'% ;If Percent Sign
|
||||
BEQ PRINTC ; Print it and Continue
|
||||
AND #$DF ;Convert to Upper Case
|
||||
CMP #'R ;If "d" or "D"
|
||||
CMP #'L ;If "d" or "D"
|
||||
BNE PRINTR
|
||||
LDA TEMP3 ; Load Byte to Format
|
||||
JSR PUTDEM ; Print Left Justified
|
||||
JMP PRINTY ; and Continue Printing Screen
|
||||
PRINTR: CMP #'R ;If "d" or "D"
|
||||
BNE PRINTD
|
||||
LDA TEMP3 ; Load Byte to Format
|
||||
JSR PUTDER ; Print as Decimal
|
||||
JMP PRINTY ; and Continue Printing Screen
|
||||
LDA TEMP3 ; Load Byte to Format
|
||||
JSR PUTDES ; Print Right Justified
|
||||
JMP PRINTY ; and Continue Printing Screen
|
||||
PRINTD: CMP #'D ;If "d" or "D"
|
||||
BNE PRINTH
|
||||
LDA TEMP3 ; Load Byte to Format
|
||||
JSR PUTDEC ; Print as Decimal
|
||||
JMP PRINTY ; and Continue Printing Screen
|
||||
LDA TEMP3 ; Load Byte to Format
|
||||
JSR PUTDEC ; Print as Decimal
|
||||
JMP PRINTY ; and Continue Printing Screen
|
||||
PRINTH: CMP #'H ;Else If "h" or "H"
|
||||
BNE PRINTB
|
||||
LDA TEMP3 ; Load Byte to Format
|
||||
JSR PRBYTE ; Print as Hexadecimal
|
||||
JMP PRINTY ; and Continue Printing Screen
|
||||
LDA TEMP3 ; Load Byte to Format
|
||||
JSR PRBYTE ; Print as Hexadecimal
|
||||
JMP PRINTY ; and Continue Printing Screen
|
||||
PRINTB: LDA TEMP3 ;Otherwise
|
||||
JMP PRINTC ; Print Raw Byte and Continue
|
||||
|
59
py65/testiox.c02
Normal file
59
py65/testiox.c02
Normal file
@ -0,0 +1,59 @@
|
||||
/***********************************************
|
||||
* TESTIOX - Test Library stdiox.h for py65mon *
|
||||
***********************************************/
|
||||
|
||||
#include <py65.h02>
|
||||
#include <stdlib.h02>
|
||||
#include <stdio.h02>
|
||||
#include <stdiox.h02>
|
||||
|
||||
char c, i;
|
||||
|
||||
main:
|
||||
|
||||
i = 0;
|
||||
|
||||
putln("prtdec()");
|
||||
do {
|
||||
putdec(i);
|
||||
putc(':');
|
||||
i++;
|
||||
if (!i&15) newlin();
|
||||
} while (i);
|
||||
anykey();
|
||||
|
||||
putln("prtdel()");
|
||||
do {
|
||||
putdel(i);
|
||||
putc(':');
|
||||
i++;
|
||||
if (!i&15) newlin();
|
||||
} while (i);
|
||||
anykey();
|
||||
|
||||
putln("prtder()");
|
||||
do {
|
||||
putder(i);
|
||||
putc(':');
|
||||
i++;
|
||||
if (!i&15) newlin();
|
||||
} while (i);
|
||||
anykey();
|
||||
|
||||
do {
|
||||
if (i<32) printf(" H='%h' R='%r' L='%l' D='%d'");
|
||||
else printf("C='%c' H='%h' R='%r' L='%l' D='%d'");
|
||||
newlin();
|
||||
i++;
|
||||
if (!i&15) anykey();
|
||||
} while (i<128);
|
||||
|
||||
done:
|
||||
goto exit;
|
||||
|
||||
void anykey() {
|
||||
newlin();
|
||||
putln("Press any key...");
|
||||
c = getc();
|
||||
newlin();
|
||||
}
|
Loading…
Reference in New Issue
Block a user