2018-02-02 23:02:06 +00:00
|
|
|
; C02 library stdiox.h02 assembly language subroutines
|
|
|
|
|
2020-10-13 16:42:03 +00:00
|
|
|
SUBROUTINE STDIOX
|
2018-07-27 18:11:39 +00:00
|
|
|
|
2020-10-13 16:42:03 +00:00
|
|
|
.ANYKEY BYTE "PRESS ANY KEY...",0
|
2018-07-30 00:40:31 +00:00
|
|
|
;
|
2020-09-29 19:41:41 +00:00
|
|
|
;char anykey(nls) - wait for character with ANY KEY prompt
|
|
|
|
;Args: A = Print Newlines (0 = No, otherwise Yes)
|
2018-07-30 00:40:31 +00:00
|
|
|
;Calls: GETCPR, NEWLIN - Print Newline to Screen
|
|
|
|
;Affects: C,N,Z
|
|
|
|
;Returns: A = Character code of keypress
|
2018-07-27 18:11:39 +00:00
|
|
|
ANYKEY: JSR NEWLIN ;Start at Beginning of Next Line
|
2020-10-13 16:42:03 +00:00
|
|
|
.NONL LDY #>.ANYKEY ;Load Prompt High Byte
|
|
|
|
LDX #<.ANYKEY ;Load Prompt Low Byte
|
2018-07-27 18:11:39 +00:00
|
|
|
;Drop into GETCPR
|
|
|
|
|
2020-09-29 19:41:41 +00:00
|
|
|
;char getcpr(nls, &s) - GET Character with PRompt
|
|
|
|
;Args: A = Print Newlines (0 = No, otherwise Yes)
|
|
|
|
; Y,X = Address of Prompt String
|
2018-07-30 00:40:31 +00:00
|
|
|
;Sets: TEMP0 - Character code of keypress
|
2020-09-29 19:41:41 +00:00
|
|
|
; TEMP1 - Newline Flag
|
2018-07-30 00:40:31 +00:00
|
|
|
;Calls: PUTS - Put String to Screen
|
|
|
|
; GETC - Get Character from Keyboard
|
|
|
|
; NEWLIN - Print Newline to Screen
|
|
|
|
;Affects: C,N,Z
|
|
|
|
;Returns: A = Character code of keypress
|
|
|
|
GETCPR: JSR PUTS ;Print Prompt
|
|
|
|
JSR GETC ;Wait for and Return Keypress
|
|
|
|
STA TEMP0 ;Save Key Code
|
|
|
|
JSR NEWLIN ;Move to Next Line
|
2018-07-27 18:11:39 +00:00
|
|
|
JSR NEWLIN ;Generate Blank Line
|
2020-09-29 19:41:41 +00:00
|
|
|
.NONLS LDA TEMP0 ;Load Key Code
|
2018-07-30 00:40:31 +00:00
|
|
|
RTS
|
2018-07-27 18:11:39 +00:00
|
|
|
|
2018-09-17 23:44:47 +00:00
|
|
|
;void putbin(b) - PUT Binary
|
|
|
|
;Args: A = number to print
|
2020-09-08 15:51:30 +00:00
|
|
|
;Destroys: TEMP0, TEMP1
|
2018-09-17 23:44:47 +00:00
|
|
|
;Affects: A,Y,C,N,X
|
2020-10-13 16:42:03 +00:00
|
|
|
PUTBIN: LDY #$FF ;Set Bit Mask to All 1's
|
2020-09-08 15:51:30 +00:00
|
|
|
|
2020-10-13 16:42:03 +00:00
|
|
|
;void putmsk(b) - PUT Bit Mask
|
2020-09-08 15:51:30 +00:00
|
|
|
;Args: A = byte to print
|
2020-10-13 16:42:03 +00:00
|
|
|
; Y = Bit Mask
|
2020-09-08 15:51:30 +00:00
|
|
|
;Destroys: TEMP0, TEMP1
|
|
|
|
;Affects: A,Y,C,N,X
|
|
|
|
PUTMSK: STA TEMP2 ;Save Byte
|
2020-10-13 16:42:03 +00:00
|
|
|
STY TEMP1 ;Save Bit Mask
|
2018-09-17 23:44:47 +00:00
|
|
|
LDX #8 ;Print 8 Binary Digits
|
2020-09-29 19:41:41 +00:00
|
|
|
.MASKL LDA #0 ;Clear Accumulator
|
2020-09-08 15:51:30 +00:00
|
|
|
ASL TEMP2 ;Shift Top Bit Out of Byte
|
2018-09-17 23:44:47 +00:00
|
|
|
ADC #$30 ;Convert to '0' or '1'
|
2020-09-08 15:51:30 +00:00
|
|
|
ASL TEMP1 ;Shift Top Bit Out of Mask
|
2020-09-29 19:41:41 +00:00
|
|
|
BCC .MASKP ;If Set
|
2020-09-08 15:51:30 +00:00
|
|
|
JSR PUTCHR ; Print Digit
|
2020-09-29 19:41:41 +00:00
|
|
|
.MASKP DEX ;Decrement Index
|
|
|
|
BNE .MASKL ;Loop if Not Done
|
2018-09-17 23:44:47 +00:00
|
|
|
RTS
|
|
|
|
|
2018-07-30 00:40:31 +00:00
|
|
|
;void putdel(b) - PUT DEcimal Left justified
|
2018-07-08 05:38:36 +00:00
|
|
|
;Args: A = number to print
|
|
|
|
;Sets: TEMP0 - ones digit
|
|
|
|
; TEMP1 - tens digit
|
|
|
|
; TEMP2 - hundreds digit
|
|
|
|
; TEMP3 - number that was printed
|
2020-09-29 19:41:41 +00:00
|
|
|
;.putdel - Alternate Entry Point if number is already in TEMP3
|
|
|
|
;.spaces - Alternate Entry Point to print only padding spaces
|
2018-02-02 23:02:06 +00:00
|
|
|
PUTDEL: STA TEMP3
|
2020-09-29 19:41:41 +00:00
|
|
|
.PUTDEL JSR PUTDEC ;Print Decimal Representation of number
|
2018-07-08 05:38:36 +00:00
|
|
|
LDA TEMP3 ;
|
2020-09-29 19:41:41 +00:00
|
|
|
.SPACES CMP #100 ;If Number < 100
|
|
|
|
BCS .ONES ;
|
2018-07-08 05:38:36 +00:00
|
|
|
JSR PUTSPC ; Print a Space
|
|
|
|
LDA TEMP3 ;
|
2020-09-29 19:41:41 +00:00
|
|
|
.ONES CMP #10 ; If Number < 10
|
|
|
|
BCS .RETURN ;
|
2018-07-08 05:38:36 +00:00
|
|
|
JSR PUTSPC ; Print another Space
|
2020-09-29 19:41:41 +00:00
|
|
|
.RETURN RTS
|
|
|
|
|
|
|
|
;void putdeh(b) - PUT DEcimal Hundred
|
|
|
|
;Args: A = number to print
|
|
|
|
;Sets: TEMP0 - ones digit
|
|
|
|
; TEMP1 - tens digit
|
|
|
|
; TEMP2 - hundreds digit
|
|
|
|
PUTDEH: JSR CUBCD ;Convert Accumulator to Unpacked BCD
|
|
|
|
LDX #2 ;Print 2 Digits
|
|
|
|
BNE .DEZLP
|
|
|
|
|
|
|
|
;void putdez(b) - PUT DEcimal Zero filled
|
|
|
|
;Args: A = number to print
|
|
|
|
;Sets: TEMP0 - ones digit
|
|
|
|
; TEMP1 - tens digit
|
|
|
|
; TEMP2 - hundreds digit
|
|
|
|
PUTDEZ: JSR CUBCD ;Convert Accumulator to Unpacked BCD
|
|
|
|
LDX #3 ;Print 3 Digits
|
|
|
|
.DEZLP LDA TEMP0-1,X ;Get Byte
|
|
|
|
JSR PUTDGT ;Print Digit
|
|
|
|
DEX ;Decrement Counter
|
|
|
|
BNE .DEZLP ; And Loop if Not Done
|
|
|
|
RTS
|
2018-02-02 23:02:06 +00:00
|
|
|
|
2018-07-30 00:40:31 +00:00
|
|
|
;void putder(b) - PUT DEcimal Right justified
|
2018-07-08 05:38:36 +00:00
|
|
|
;Args: A = number to print
|
|
|
|
;Sets: TEMP0 - ones digit
|
|
|
|
; TEMP1 - tens digit
|
|
|
|
; TEMP2 - hundreds digit
|
|
|
|
; TEMP3 - number that was printed
|
2018-02-02 23:37:19 +00:00
|
|
|
PUTDER: STA TEMP3
|
2020-09-29 19:41:41 +00:00
|
|
|
.PUTDER JSR .SPACES
|
2018-02-02 23:37:19 +00:00
|
|
|
LDA TEMP3
|
2018-07-08 05:38:36 +00:00
|
|
|
|
2018-07-30 00:40:31 +00:00
|
|
|
;void putdec(b) - PUT DECimal
|
2018-07-08 05:38:36 +00:00
|
|
|
;Args: A = number to print
|
|
|
|
;Sets: TEMP0 - ones digit
|
|
|
|
; TEMP1 - tens digit
|
|
|
|
; TEMP2 - hundreds digit
|
2018-02-02 23:02:06 +00:00
|
|
|
PUTDEC: JSR CUBCD ;Convert Accumulator to Unpacked BCD
|
|
|
|
LDA TEMP2 ;Get High Byte
|
2020-09-29 19:41:41 +00:00
|
|
|
BEQ .DIGIT1 ;If Not Zero
|
2019-05-27 21:12:10 +00:00
|
|
|
JSR PUTDGT ; Print Digit
|
2020-09-29 19:41:41 +00:00
|
|
|
.DIGIT1 LDA TEMP1 ;Get Low Byte
|
|
|
|
BNE .DIGIT2 ;If Not Zero
|
2018-02-02 23:02:06 +00:00
|
|
|
CMP TEMP2 ; and Hundreds
|
2020-09-29 19:41:41 +00:00
|
|
|
BEQ .DIGIT3 ; not Zero
|
|
|
|
.DIGIT2 JSR PUTDGT ; Print Digit
|
|
|
|
.DIGIT3 LDA TEMP0 ;Get Low Byte
|
2019-05-27 21:12:10 +00:00
|
|
|
PUTDGT: ORA #$30 ;Convert to ASCII digit
|
|
|
|
JMP PUTCHR ;And Print
|
2018-02-02 23:02:06 +00:00
|
|
|
|
2020-09-08 15:51:30 +00:00
|
|
|
;puthex(b) - PUT HEXadecimal
|
2018-07-30 00:40:31 +00:00
|
|
|
PUTHEX EQU PRBYTE ;Print Byte as Hexadecimal
|
|
|
|
|
2020-10-13 16:42:03 +00:00
|
|
|
;putinr(i) - PUT INteger Right justified
|
2020-09-29 19:41:41 +00:00
|
|
|
PUTINR: SEC ;Mode = Justified
|
|
|
|
BCS .PUTINT ;Print Integer
|
|
|
|
|
2020-10-13 16:42:03 +00:00
|
|
|
;putint(i) - PUT INTeger
|
2020-09-29 19:41:41 +00:00
|
|
|
PUTINT: CLC ;Mode = Not Justified
|
|
|
|
.PUTINT JSR CVIBCD ;Convert Integer to Packed BCD
|
2019-05-27 21:12:10 +00:00
|
|
|
LDY #4 ;Set Initial Digit Number
|
2020-09-29 19:41:41 +00:00
|
|
|
.IZERO JSR UPBCDI ;Unpack Digit X
|
|
|
|
BNE .IDIGIT ;If Zero
|
|
|
|
BCC .INEXT ; If Justified
|
|
|
|
JSR PUTSPC ; Print a Space
|
|
|
|
.INEXT DEY ; Decrement Digit Number
|
|
|
|
BNE .IZERO ; and If Not Zero Loop
|
|
|
|
.ILOOP JSR UPBCDI ;Unpack Digit X
|
|
|
|
.IDIGIT JSR PUTDGT ;Print Digit
|
2019-05-27 21:12:10 +00:00
|
|
|
DEY ;Decrement Digit Number
|
2020-09-29 19:41:41 +00:00
|
|
|
BPL .ILOOP ;Loop if >= Zero
|
2019-05-27 21:12:10 +00:00
|
|
|
RTS
|
|
|
|
|
2020-09-08 15:51:30 +00:00
|
|
|
;putnyb(b) - PUT NYBble
|
|
|
|
PUTNYB EQU PRHEX ;Print Nybble as Hexadecimal
|
|
|
|
|
2020-09-29 19:41:41 +00:00
|
|
|
;putsqb(&.HEXW) - PUT SesQuiByte
|
2020-09-08 15:51:30 +00:00
|
|
|
;Args: Y = High Nybble
|
|
|
|
; X = Low Byte
|
2020-09-29 19:41:41 +00:00
|
|
|
;Calls: PUTHEX = Print Byte
|
|
|
|
; PRHEX = Print Hex Digit
|
2020-09-08 15:51:30 +00:00
|
|
|
; SAVRXY = Save X and Y Registers
|
|
|
|
;Affects: A,Y,X,N,Z,C
|
|
|
|
PUTSQB: JSR SAVRXY ;Save Address
|
2020-09-29 19:41:41 +00:00
|
|
|
.PUTSQB LDA TEMP2 ;Load Address MSB
|
2020-09-08 15:51:30 +00:00
|
|
|
JSR PRHEX ;Print High Nybble
|
|
|
|
LDA TEMP1 ;Load Address LSB
|
2020-09-29 19:41:41 +00:00
|
|
|
JMP PUTHEX ;Print and Return`
|
2020-09-08 15:51:30 +00:00
|
|
|
|
2020-09-29 19:41:41 +00:00
|
|
|
;putexh(&.HEXW) - PUT EXtended Hexadecimal
|
2020-09-08 15:51:30 +00:00
|
|
|
;Args: A = Value Extended Byte
|
|
|
|
; Y = Value High Byte
|
|
|
|
; X = Value Low Byte
|
2020-09-29 19:41:41 +00:00
|
|
|
;Calls: PUTHEX = Print Byte
|
2020-09-08 15:51:30 +00:00
|
|
|
; SAVRXY = Save X and Y Registers
|
2020-10-13 16:42:03 +00:00
|
|
|
; PUTWRT = Put .HEXW (Alternate Entry Point)
|
2020-09-08 15:51:30 +00:00
|
|
|
;Affects: A,Y,X,N,Z,C
|
|
|
|
PUTEXH: JSR SAVRXY ;Save High and Low Bytes
|
2020-09-29 19:41:41 +00:00
|
|
|
JSR PUTHEX ;Print Extended Byte
|
2020-10-13 16:42:03 +00:00
|
|
|
JMP PUTWRT ;Print TEMP2, TEMP1 as HEX word
|
2020-09-08 15:51:30 +00:00
|
|
|
|
2020-10-13 16:42:03 +00:00
|
|
|
;putwrd(&HEXW) - PUT WORD
|
2020-09-29 19:41:41 +00:00
|
|
|
;Args: Y = .HEXW MSB
|
|
|
|
; X = .HEXW LSB
|
|
|
|
;Calls: PUTHEX = Print Byte
|
2018-07-30 00:40:31 +00:00
|
|
|
; SAVRXY = Save X and Y Registers
|
|
|
|
;Affects: A,Y,X,N,Z,C
|
2020-09-29 19:41:41 +00:00
|
|
|
PUTWRD: JSR SAVRXY ;Save .HEXW
|
2020-10-13 16:42:03 +00:00
|
|
|
PUTWRT: LDA TEMP2 ;Load .HEXW MSB
|
2020-09-29 19:41:41 +00:00
|
|
|
JSR PUTHEX ;Print as Hexadecimal
|
|
|
|
LDA TEMP1 ;Load .HEXW LSB
|
|
|
|
JMP PUTHEX ;Print and Return`
|
2018-07-30 00:40:31 +00:00
|
|
|
|
2018-02-02 23:02:06 +00:00
|
|
|
;Print a Space
|
2018-02-02 23:37:19 +00:00
|
|
|
PUTSPC: LDA #32 ;Load Space Character
|
2018-09-17 23:44:47 +00:00
|
|
|
JMP PUTCHR ;and Print it
|
2018-07-19 04:27:50 +00:00
|
|
|
|
2020-09-08 15:51:30 +00:00
|
|
|
;Print Repeated Spaces
|
|
|
|
PUTRPS: TAY ;Set Counter to Number of Spaces
|
|
|
|
LDA #32
|
|
|
|
|
|
|
|
;Print Repeated Character
|
|
|
|
PUTRPT: JSR PUTCHR ;Print Space Character
|
|
|
|
DEY ;Decrement Counter
|
|
|
|
BNE PUTRPT ;If Not 0, Loop
|
|
|
|
RTS
|
|
|
|
|
2018-07-30 00:40:31 +00:00
|
|
|
;void printf(b, &s) - PRINT Formatted byte and/or string
|
|
|
|
;Args: A = byte to format
|
2018-07-08 05:38:36 +00:00
|
|
|
; Y,X = address of formatting string
|
2020-10-13 16:42:03 +00:00
|
|
|
;Uses: DSTPTR = Address of %S string
|
|
|
|
;Sets: SRCPTR = Address of formatting string
|
2018-07-30 00:40:31 +00:00
|
|
|
; TEMP3 - number to format
|
|
|
|
;Destroys: TEMP0,TEMP1,TEMP2
|
|
|
|
;Returns: A,Y = Total number of characters printed
|
2020-09-08 15:51:30 +00:00
|
|
|
PRINTF: STA TEMP3 ;Save Byte to Format
|
|
|
|
JSR SETSRC ;Initialize Source String
|
2020-10-13 16:42:03 +00:00
|
|
|
.FLOOP LDA (SRCPTR),Y ;Read next character in string
|
2020-09-29 19:41:41 +00:00
|
|
|
BEQ .FDONE ;If Not 0
|
|
|
|
CMP #'%' ; If Format Specified
|
|
|
|
BEQ .FEVAL ; Jump to Formatter
|
|
|
|
.FPUTC JSR PUTCHR ; Print character at offset,
|
|
|
|
.FNEXT INY ; increment offset, and
|
|
|
|
BPL .FLOOP ; loop if less than 128
|
|
|
|
.FDONE TYA ;Return Number of
|
|
|
|
RTS ; characters printed
|
2018-02-02 23:02:06 +00:00
|
|
|
;Process Format Specifier
|
2020-09-29 19:41:41 +00:00
|
|
|
.FEVAL: INY ;Increment Offset
|
2020-10-13 16:42:03 +00:00
|
|
|
LDA (SRCPTR),Y ;Get Formatting Character
|
2020-09-29 19:41:41 +00:00
|
|
|
BEQ .FDONE ;If NUL, then Exit
|
|
|
|
CMP #'%' ;If Percent Sign
|
|
|
|
BEQ .FPUTC ; Print it and Continue
|
2018-07-19 04:27:50 +00:00
|
|
|
AND #$DF ;Convert to Upper Case
|
2020-09-29 19:41:41 +00:00
|
|
|
.HNDRD CMP #'H' ;If "z" or "Z"
|
|
|
|
BNE .ZEROF
|
|
|
|
LDA TEMP3 ; Load Byte to Format
|
|
|
|
JSR PUTDEH ; Print Zero Filled
|
|
|
|
JMP .FNEXT ; and Continue .INTGRng String
|
|
|
|
.ZEROF CMP #'Z' ;If "z" or "Z"
|
|
|
|
BNE .LJUST
|
|
|
|
LDA TEMP3 ; Load Byte to Format
|
|
|
|
JSR PUTDEZ ; Print Zero Filled
|
|
|
|
JMP .FNEXT ; and Continue .INTGRng String
|
|
|
|
.LJUST CMP #'L' ;If "l" or "L"
|
|
|
|
BNE .RJUST
|
2018-07-19 04:27:50 +00:00
|
|
|
LDA TEMP3 ; Load Byte to Format
|
2020-09-29 19:41:41 +00:00
|
|
|
JSR .PUTDEL ; Print Left Justified
|
|
|
|
JMP .FNEXT ; and Continue .INTGRng String
|
|
|
|
.RJUST CMP #'R' ;If "r" or "R"
|
|
|
|
BNE .DECML
|
2018-07-19 04:27:50 +00:00
|
|
|
LDA TEMP3 ; Load Byte to Format
|
2020-09-29 19:41:41 +00:00
|
|
|
JSR .PUTDER ; Print Right Justified
|
|
|
|
JMP .FNEXT ; and Continue .INTGRng String
|
|
|
|
.DECML CMP #'D' ;Else If "d" or "D"
|
|
|
|
BNE .NYBBL
|
2018-07-19 04:27:50 +00:00
|
|
|
LDA TEMP3 ; Load Byte to Format
|
|
|
|
JSR PUTDEC ; Print as Decimal
|
2020-09-29 19:41:41 +00:00
|
|
|
JMP .FNEXT ; and Continue .INTGRng String
|
|
|
|
.NYBBL CMP #'Y' ;Else If "y" or "Y"
|
|
|
|
BNE .HEXB
|
2020-09-08 15:51:30 +00:00
|
|
|
LDA TEMP3 ; Load Byte to Format
|
|
|
|
JSR PUTNYB ; Print as Low Nybble as Hexadecimal
|
2020-09-29 19:41:41 +00:00
|
|
|
JMP .FNEXT ; and Continue .INTGRng String
|
|
|
|
.HEXB CMP #'X' ;Else If "x" or "Y"
|
|
|
|
BNE .BNRY
|
2018-07-19 04:27:50 +00:00
|
|
|
LDA TEMP3 ; Load Byte to Format
|
2018-07-30 00:40:31 +00:00
|
|
|
JSR PUTHEX ; Print as Hexadecimal
|
2020-09-29 19:41:41 +00:00
|
|
|
JMP .FNEXT ; and Continue .INTGRng String
|
|
|
|
.BNRY CMP #'B' ;Else If "b" or "B"
|
|
|
|
BNE .NEWLN
|
2020-09-08 15:51:30 +00:00
|
|
|
STY TEMP0 ; Save Index
|
2018-09-17 23:44:47 +00:00
|
|
|
LDA TEMP3 ; Load Byte to Format
|
|
|
|
JSR PUTBIN ; Print as Binary
|
2020-09-08 15:51:30 +00:00
|
|
|
LDY TEMP0 ; Restore Index
|
2020-09-29 19:41:41 +00:00
|
|
|
JMP .FNEXT ; and Continue .INTGRng String
|
|
|
|
.NEWLN CMP #'N' ;Else If "n" or "N"
|
|
|
|
BNE .STRNG
|
2018-12-10 22:23:04 +00:00
|
|
|
STY TEMP0 ; Save Index
|
2018-08-14 18:14:32 +00:00
|
|
|
JSR NEWLIN ; Execute Newline Function
|
2018-12-10 22:23:04 +00:00
|
|
|
LDY TEMP0 ; Restore Index
|
2020-09-29 19:41:41 +00:00
|
|
|
JMP .FNEXT ; and Continue .INTGRng String
|
|
|
|
.STRNG CMP #'S' ;Else If "s" or "S"
|
|
|
|
BEQ .FDEST ; Print Destination String
|
|
|
|
.SQBYT CMP #'Q' ;Else If "w" or "W"
|
|
|
|
BEQ .FDEST ; Print Sesquibyte as Hex
|
|
|
|
.HEXW CMP #'W' ;Else If "w" or "W"
|
|
|
|
BEQ .FDEST ; Print Word as Hex
|
|
|
|
.INTGR CMP #'I' ;Else If "i" or "I"
|
|
|
|
BEQ .FDEST ; Print Decimal Integer
|
|
|
|
.IJUST CMP #'J' ;Else If "j" or "J"
|
|
|
|
BEQ .FDEST ; Print Right-Justified Decimal
|
|
|
|
.FECHO LDA TEMP3 ;Else
|
|
|
|
JMP .FPUTC ; Print Raw Byte and Continue
|
|
|
|
|
|
|
|
;Process Value in DSTPTR
|
|
|
|
.FDEST TAX ;Save Specifier
|
|
|
|
TYA ;Save Index
|
2019-05-27 21:12:10 +00:00
|
|
|
PHA
|
2020-09-29 19:41:41 +00:00
|
|
|
TXA ;Restore Specifier
|
2020-10-16 02:58:12 +00:00
|
|
|
JSR GETDST ;Get Integer in DSTPTR
|
2020-09-29 19:41:41 +00:00
|
|
|
CMP #'I' ;If 'i' or 'I'
|
|
|
|
BNE .FDESTJ
|
|
|
|
JSR PUTINT ; Print Integer Right Justified
|
|
|
|
BMI .FSKIP
|
|
|
|
.FDESTJ CMP #'J' ;Else If 'J' or 'J'
|
|
|
|
BNE .FDESTQ
|
|
|
|
JSR PUTINR ;Print Integer Right Justified
|
|
|
|
BMI .FSKIP
|
|
|
|
.FDESTQ CMP #'Q' ;Else If 'q' or 'Q'
|
|
|
|
BNE .FDESTW
|
|
|
|
JSR .PUTSQB ; Print MSB and LSB as Hex
|
|
|
|
BNE .FSKIP
|
|
|
|
.FDESTW CMP #'W' ;Else If 'w' or 'J'
|
|
|
|
BNE .FDESTS
|
|
|
|
JSR PUTWRD ; Print MSB and LSB as Hex
|
|
|
|
BNE .FSKIP
|
|
|
|
.FDESTS JSR PUTDST ;Else Print Destination String
|
|
|
|
.FSKIP PLA ;Restore Index
|
2019-05-27 21:12:10 +00:00
|
|
|
TAY
|
2020-09-29 19:41:41 +00:00
|
|
|
JMP .FNEXT
|
2018-07-19 04:27:50 +00:00
|
|
|
|
2018-08-14 18:14:32 +00:00
|
|
|
;char putdst()
|
2020-09-29 19:41:41 +00:00
|
|
|
PUTDST LDY #0 ;Initialize character offset
|
2020-10-16 02:58:12 +00:00
|
|
|
.DLOOP LDA (DSTPTR),Y ;Read next character in string
|
2020-09-29 19:41:41 +00:00
|
|
|
BEQ .DRETY ;If Not 0
|
2018-07-19 04:27:50 +00:00
|
|
|
JSR PUTC ; Print character at offset,
|
|
|
|
INY ; increment offset, and
|
2020-09-29 19:41:41 +00:00
|
|
|
BPL .DLOOP ; loop if less than 128
|
|
|
|
.DRETY TYA ;Return number of
|
2018-07-19 04:27:50 +00:00
|
|
|
RTS ; characters printed
|
2020-10-13 16:42:03 +00:00
|
|
|
|
|
|
|
ENDSUBROUTINE
|