mirror of
https://github.com/Michaelangel007/apple2_printm.git
synced 2024-12-20 05:29:38 +00:00
Ver 13
This commit is contained in:
parent
45bc1fa32d
commit
2400ba50e0
40
printm.s
40
printm.s
@ -1,9 +1,10 @@
|
|||||||
; Version 12
|
|
||||||
|
|
||||||
; ca65
|
; ca65
|
||||||
.feature c_comments
|
.feature c_comments
|
||||||
|
|
||||||
/*
|
/* Version 13
|
||||||
|
printm - a printf replacement for 6502
|
||||||
|
Michael Pohroeski
|
||||||
|
|
||||||
|
|
||||||
Problem:
|
Problem:
|
||||||
We want to print this:
|
We want to print this:
|
||||||
@ -61,8 +62,6 @@ ENABLE_PTR = 1 ; requires ENABLE_HEX
|
|||||||
ENABLE_STR = 1
|
ENABLE_STR = 1
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
.feature labels_without_colons
|
.feature labels_without_colons
|
||||||
.feature leading_dot_in_identifiers
|
.feature leading_dot_in_identifiers
|
||||||
; 65C02
|
; 65C02
|
||||||
@ -166,18 +165,23 @@ _HgrAddr
|
|||||||
JSR ReverseByte
|
JSR ReverseByte
|
||||||
STA DATA+12
|
STA DATA+12
|
||||||
|
|
||||||
|
.if ENABLE_BIN || ENABLE_DEC || ENABLE_HEX
|
||||||
LDY #0
|
LDY #0
|
||||||
JSR VTABY
|
JSR VTABY
|
||||||
LDX #<DATA ; Low Byte of Address
|
LDX #<DATA ; Low Byte of Address
|
||||||
LDY #>DATA ; High Byte of Address
|
LDY #>DATA ; High Byte of Address
|
||||||
JSR PrintM
|
JSR PrintM
|
||||||
|
.endif
|
||||||
|
|
||||||
|
.if ENABLE_BYTE
|
||||||
LDY #2
|
LDY #2
|
||||||
JSR VTABY
|
JSR VTABY
|
||||||
LDX #<DATA2
|
LDX #<DATA2
|
||||||
LDY #>DATA2
|
LDY #>DATA2
|
||||||
JSR PrintM
|
JSR PrintM
|
||||||
|
.endif ; ENABLE_BYTE
|
||||||
|
|
||||||
|
.if ENABLE_STR
|
||||||
LDY #4
|
LDY #4
|
||||||
JSR VTABY
|
JSR VTABY
|
||||||
LDX #<DATA3
|
LDX #<DATA3
|
||||||
@ -189,6 +193,7 @@ _HgrAddr
|
|||||||
LDX #<DATA4
|
LDX #<DATA4
|
||||||
LDY #>DATA4
|
LDY #>DATA4
|
||||||
JSR PrintM
|
JSR PrintM
|
||||||
|
.endif ; ENABLE_STR
|
||||||
|
|
||||||
LDA #8
|
LDA #8
|
||||||
JMP TABV
|
JMP TABV
|
||||||
@ -243,7 +248,7 @@ TEXT
|
|||||||
.byte "@"
|
.byte "@"
|
||||||
APPLE " "
|
APPLE " "
|
||||||
.byte "%"
|
.byte "%"
|
||||||
APPLE "~"
|
APPLE "~"
|
||||||
.byte "?"
|
.byte "?"
|
||||||
.byte 0
|
.byte 0
|
||||||
|
|
||||||
@ -322,7 +327,7 @@ DATA4
|
|||||||
ds 256 - <*
|
ds 256 - <*
|
||||||
|
|
||||||
|
|
||||||
; Self-Modifying variable aliases
|
; self-modifying variable aliases
|
||||||
|
|
||||||
_pScreen = PutChar +1
|
_pScreen = PutChar +1
|
||||||
_pFormat = GetFormat +1
|
_pFormat = GetFormat +1
|
||||||
@ -340,7 +345,7 @@ DATA4
|
|||||||
PrintM
|
PrintM
|
||||||
STX _pArg+0
|
STX _pArg+0
|
||||||
STY _pArg+1
|
STY _pArg+1
|
||||||
STZ _iArg
|
STZ _iArg
|
||||||
|
|
||||||
NextArg
|
NextArg
|
||||||
JSR NxtArgYX
|
JSR NxtArgYX
|
||||||
@ -421,7 +426,7 @@ _PrintPtr
|
|||||||
JSR NxtArgToTemp
|
JSR NxtArgToTemp
|
||||||
|
|
||||||
; JSR NxtArgYX
|
; JSR NxtArgYX
|
||||||
; 13 bytes - zero page version
|
; 13 bytes: zero page version
|
||||||
; STX _temp+0 ; zero-page for (ZP),Y
|
; STX _temp+0 ; zero-page for (ZP),Y
|
||||||
; STY _temp+1
|
; STY _temp+1
|
||||||
LDY #$0
|
LDY #$0
|
||||||
@ -431,7 +436,7 @@ _PrintPtr
|
|||||||
LDA (_temp),Y
|
LDA (_temp),Y
|
||||||
TAY
|
TAY
|
||||||
|
|
||||||
; 20 bytes - self modifying code version if zero-page not available
|
; 20 bytes: self-modifying code version if zero-page not available
|
||||||
; STX PtrVal+1
|
; STX PtrVal+1
|
||||||
; STY PtrVal+2
|
; STY PtrVal+2
|
||||||
; LDY #0 ; 0: A->X
|
; LDY #0 ; 0: A->X
|
||||||
@ -463,6 +468,7 @@ GetFormat
|
|||||||
LDA $C0DE ; _pFormat NOTE: self-modifying!
|
LDA $C0DE ; _pFormat NOTE: self-modifying!
|
||||||
BEQ _Done
|
BEQ _Done
|
||||||
BMI Print ; neg = literal
|
BMI Print ; neg = literal
|
||||||
|
; NOTE: If all features are turned off, will get a ca65 Range Error
|
||||||
LDX #NumMeta-1 ; pos = meta
|
LDX #NumMeta-1 ; pos = meta
|
||||||
FindMeta
|
FindMeta
|
||||||
CMP MetaChar,X
|
CMP MetaChar,X
|
||||||
@ -552,7 +558,7 @@ _BCD2Char
|
|||||||
BPL _BCD2Char
|
BPL _BCD2Char
|
||||||
|
|
||||||
DecWidth
|
DecWidth
|
||||||
LDX #0 ; _nDecDigits NOTE: self modifying!
|
LDX #0 ; _nDecDigits NOTE: self-modifying!
|
||||||
JMP PrintReverseBCD
|
JMP PrintReverseBCD
|
||||||
.endif ; ENABLE_DEC
|
.endif ; ENABLE_DEC
|
||||||
|
|
||||||
@ -576,10 +582,10 @@ _Bit2Asc
|
|||||||
CMP #$80 ; C= A>=$80
|
CMP #$80 ; C= A>=$80
|
||||||
ROL ; C<-76543210<-C
|
ROL ; C<-76543210<-C
|
||||||
TAX
|
TAX
|
||||||
AND #$01 ; 0 -> B0
|
AND #$01 ; 0 -> B0
|
||||||
BEQ _FlipBit
|
BEQ _FlipBit
|
||||||
_PrintBit
|
_PrintBit
|
||||||
LDA #$81 ; 1 -> 31 NOTE: self-modifying!
|
LDA #$81 ; 1 -> 31 NOTE: self-modifying!
|
||||||
_FlipBit
|
_FlipBit
|
||||||
EOR #$B0
|
EOR #$B0
|
||||||
JSR PutChar
|
JSR PutChar
|
||||||
@ -676,7 +682,7 @@ _PrintCharA
|
|||||||
|
|
||||||
; ======================================================================
|
; ======================================================================
|
||||||
PutChar
|
PutChar
|
||||||
STA $400 ; NOTE: self-modifying!
|
STA $C0DE ; _pScreen NOTE: self-modifying!
|
||||||
INC PutChar+1 ; inc lo
|
INC PutChar+1 ; inc lo
|
||||||
RTS
|
RTS
|
||||||
|
|
||||||
@ -689,10 +695,10 @@ NxtArgYX
|
|||||||
|
|
||||||
; @return _Arg[ _Num ]
|
; @return _Arg[ _Num ]
|
||||||
NxtArgByte
|
NxtArgByte
|
||||||
LDY #00 ; _iArg NOTE: self-modifying!
|
LDY #00 ; _iArg NOTE: self-modifying!
|
||||||
IncArg
|
IncArg
|
||||||
LDA $C0DE,Y ; _pArg NOTE: self-modifying!
|
LDA $C0DE,Y ; _pArg NOTE: self-modifying!
|
||||||
INC _iArg ;
|
INC _iArg ;
|
||||||
BNE @_SamePage
|
BNE @_SamePage
|
||||||
INC _pArg+1 ;
|
INC _pArg+1 ;
|
||||||
@_SamePage
|
@_SamePage
|
||||||
@ -709,7 +715,7 @@ _NxtArgToTemp
|
|||||||
|
|
||||||
RTS
|
RTS
|
||||||
|
|
||||||
;
|
;
|
||||||
; ======================================================================
|
; ======================================================================
|
||||||
|
|
||||||
_bcd ds 6 ; 6 chars for printing dec
|
_bcd ds 6 ; 6 chars for printing dec
|
||||||
|
Loading…
Reference in New Issue
Block a user