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
|
PUTDEM: JSR PUTDEC ;Alternate Entry Point
|
||||||
LDA TEMP3
|
LDA TEMP3
|
||||||
PUTDEH: CMP #100
|
PUTDEH: CMP #100
|
||||||
BCS PUTDE0
|
BCS PUTDET
|
||||||
JSR PUTSPC
|
JSR PUTSPC
|
||||||
PUTDE0: CMP #10
|
LDA TEMP3
|
||||||
|
PUTDET: CMP #10
|
||||||
BCS PUTDEX
|
BCS PUTDEX
|
||||||
JSR PUTSPC
|
JSR PUTSPC
|
||||||
PUTDEX: RTS
|
PUTDEX: RTS
|
||||||
|
|
||||||
;Print Byte as Right Justified Decimal Number
|
;Print Byte as Right Justified Decimal Number
|
||||||
;putder(b)
|
;putder(b)
|
||||||
PUTDER: CMP #100
|
PUTDER: STA TEMP3
|
||||||
BCS PUTDE0
|
PUTDES: JSR PUTDEH
|
||||||
JSR PUTSPC
|
LDA TEMP3
|
||||||
PUTDE0: CMP #10
|
|
||||||
BCS PUTDEC
|
|
||||||
JSR PUTSPC
|
|
||||||
;Print Byte as Decimal Number
|
;Print Byte as Decimal Number
|
||||||
;putdec(b)
|
;putdec(b)
|
||||||
PUTDEC: JSR CUBCD ;Convert Accumulator to Unpacked BCD
|
PUTDEC: JSR CUBCD ;Convert Accumulator to Unpacked BCD
|
||||||
@ -38,12 +36,9 @@ PUTDEP: ORA #$30 ;Convert to ASCII digit
|
|||||||
RTS
|
RTS
|
||||||
|
|
||||||
;Print a Space
|
;Print a Space
|
||||||
PUTSPC: PHA ;Save Accumulator
|
PUTSPC: LDA #32 ;Load Space Character
|
||||||
LDA #32 ;Load Space Character
|
JMP PRCHR ;and Print it
|
||||||
JSR PRCHR ;and Print it
|
|
||||||
PLA ;Restore Accumulator
|
|
||||||
RTS
|
|
||||||
|
|
||||||
;Print Byte in Formatted String
|
;Print Byte in Formatted String
|
||||||
;printf(b, &s)
|
;printf(b, &s)
|
||||||
PRINTF: JSR SETSRC ;Initialize Source String
|
PRINTF: JSR SETSRC ;Initialize Source String
|
||||||
@ -63,20 +58,25 @@ PRINTS: INY ;Increment Offset
|
|||||||
CMP #'% ;If Percent Sign
|
CMP #'% ;If Percent Sign
|
||||||
BEQ PRINTC ; Print it and Continue
|
BEQ PRINTC ; Print it and Continue
|
||||||
AND #$DF ;Convert to Upper Case
|
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
|
BNE PRINTD
|
||||||
LDA TEMP3 ; Load Byte to Format
|
LDA TEMP3 ; Load Byte to Format
|
||||||
JSR PUTDER ; Print as Decimal
|
JSR PUTDES ; Print Right Justified
|
||||||
JMP PRINTY ; and Continue Printing Screen
|
JMP PRINTY ; and Continue Printing Screen
|
||||||
PRINTD: CMP #'D ;If "d" or "D"
|
PRINTD: CMP #'D ;If "d" or "D"
|
||||||
BNE PRINTH
|
BNE PRINTH
|
||||||
LDA TEMP3 ; Load Byte to Format
|
LDA TEMP3 ; Load Byte to Format
|
||||||
JSR PUTDEC ; Print as Decimal
|
JSR PUTDEC ; Print as Decimal
|
||||||
JMP PRINTY ; and Continue Printing Screen
|
JMP PRINTY ; and Continue Printing Screen
|
||||||
PRINTH: CMP #'H ;Else If "h" or "H"
|
PRINTH: CMP #'H ;Else If "h" or "H"
|
||||||
BNE PRINTB
|
BNE PRINTB
|
||||||
LDA TEMP3 ; Load Byte to Format
|
LDA TEMP3 ; Load Byte to Format
|
||||||
JSR PRBYTE ; Print as Hexadecimal
|
JSR PRBYTE ; Print as Hexadecimal
|
||||||
JMP PRINTY ; and Continue Printing Screen
|
JMP PRINTY ; and Continue Printing Screen
|
||||||
PRINTB: LDA TEMP3 ;Otherwise
|
PRINTB: LDA TEMP3 ;Otherwise
|
||||||
JMP PRINTC ; Print Raw Byte and Continue
|
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