Code: Select all
s1: .asciiz "string 1"
s2: .asciiz "string 2"
s3: .asciiz "string 3"
But I don't know how to get the address of a label.
Can someone give me a hint please?
Code: Select all
s1: .asciiz "string 1"
s2: .asciiz "string 2"
s3: .asciiz "string 3"
Code: Select all
LDX #0
again:
LDA s1,X
BEQ done
JSR print
INX
BNE again
done:
Code: Select all
LDA #<s1
STA zp1
LDA #>s1
STA zp1+1
Code: Select all
LDY#0
LDA (zp1),YCode: Select all
ldx #<s1 ;LSB of string address
ldy #>s1 ;MSB of string address
jsr sprint ;print stringCode: Select all
ldx #$12 ;LSB of string address
ldy #$ab ;MSB of string address
jsr sprint ;print stringCode: Select all
;sprint: print a character string
;
; syntax: ldx #<string
; ldy #>string
; jsr sprint
;
; String must be null-terminated.
;
sprint stx zpptr01 ;set up ZP...
sty zpptr01+1 ;pointer to string
ldy #0 ;starting string index
;
sprint10 lda (zpptr01),y ;get from string
beq sprint20 ;end reached
;
jsr putch ;output character to somewhere
iny ;bump index
bne sprint10 ;get next
;
inc zpptr01+1 ;move to next page &...
bne sprint10 ;resume
;
sprint20 rts ;return to callerCode: Select all
SRCHTXT LDA #$08 ;Get msg " find text:"
JSR PROMPT ;Send to terminal
Code: Select all
MSG_00 .DB " cont?"
MSG_01 .DB "(y/n)"
.DB $00
MSG_02 .DB $0D,$0A
.DB " "
MSG_03 .DB " addr:"
.DB $00
MSG_04 .DB " len:"
.DB $00
MSG_05 .DB " val:"
.DB $00
MSG_06 .DB " src:"
.DB $00
MSG_07 .DB " tgt:"
.DB $00
MSG_08 .DB " find txt:"
.DB $00
MSG_09 .DB " find bin:"
.DB $00
MSG_0A .DB "not "
MSG_0B .DB "found"
.DB $00
MSG_0C .DB $0D,$0A
.DB "search- "
.DB $00
MSG_0D .DB $0D,$0A
.DB "(n)ext? "
.DB $00
MSG_0E .DB "SR:$"
.DB $00
MSG_0F .DB "SP:$"
.DB $00
;
MSG_TABLE ;Message table: contains message addresses sent via the PROMPT routine
.DW MSG_00, MSG_01, MSG_02, MSG_03, MSG_04, MSG_05, MSG_06, MSG_07
.DW MSG_08, MSG_09, MSG_0A, MSG_0B, MSG_0C, MSG_0D, MSG_0E, MSG_0F
Code: Select all
;PROMPT routine: Send indexed text string to terminal. Index is contained in A Reg.
; String buffer address is stored in variable PROMPTL/PROMPTH.
PROMPT ASL A ;Multiply by two for msg table index
TAX ;Xfer to X Reg - index
LDA MSG_TABLE,X ;Get low byte address
LDY MSG_TABLE+1,X ;Get high byte address
;
;PROMPTR routine: takes message address in Y/A and prints via PROMPT2 routine
PROMPTR STA PROMPTL ;Store low byte
STY PROMPTH ;Store high byte
;
;PROMPT2 routine: prints message at address (PROMPTL) till null character found
PROMPT2 LDA (PROMPTL) ;Get string data (5)
BEQ HINEXIT ;If null character, exit (borrowed RTS) (2/3)
JSR B_CHROUT ;Send character to terminal (6)
INC PROMPTL ;Increment low byte index (5)
BNE PROMPT2 ;Loop back for next character (2/3)
INC PROMPTH ;Increment high byte index (5)
BRA PROMPT2 ;Loop back and continue printing (3)
;
HINEXIT RTS ;And return to caller
;
Code: Select all
SRCHTXT LDX #MNM_08 ;Get msg " find text:"
JSR PROMPT ;Send to terminal
Code: Select all
MSG_00 .DB " cont?"
MSG_01 .DB "(y/n)"
.DB $00
MSG_02 .DB $0D,$0A
.DB " "
MSG_03 .DB " addr:"
.DB $00
MSG_04 .DB " len:"
.DB $00
MSG_05 .DB " val:"
.DB $00
MSG_06 .DB " src:"
.DB $00
MSG_07 .DB " tgt:"
.DB $00
MSG_08 .DB " find txt:"
.DB $00
MSG_09 .DB " find bin:"
.DB $00
MSG_0A .DB "not "
MSG_0B .DB "found"
.DB $00
MSG_0C .DB $0D,$0A
.DB "search- "
.DB $00
MSG_0D .DB $0D,$0A
.DB "(n)ext? "
.DB $00
MSG_0E .DB "SR:$"
.DB $00
MSG_0F .DB "SP:$"
.DB $00
; Depending on your assembler, you may be able to generate these semi-automatically in a loop...
MNM_00 .EQU 0
MNM_01 .EQU MSG_01-MSG_00
MNM_02 .EQU MSG_02-MSG_00
MNM_03 .EQU MSG_03-MSG_00
MNM_04 .EQU MSG_04-MSG_00
MNM_05 .EQU MSG_05-MSG_00
MNM_06 .EQU MSG_06-MSG_00
MNM_07 .EQU MSG_07-MSG_00
MNM_08 .EQU MSG_08-MSG_00
MNM_09 .EQU MSG_09-MSG_00
MNM_0A .EQU MSG_0A-MSG_00
MNM_0B .EQU MSG_0B-MSG_00
MNM_0C .EQU MSG_0C-MSG_00
MNM_0D .EQU MSG_0D-MSG_00
MNM_0E .EQU MSG_0E-MSG_00
MNM_0F .EQU MSG_0F-MSG_00
Code: Select all
;PROMPT routine: Send indexed text string to terminal. Index is contained in X Reg.
PROMPT1 JSR B_CHROUT ;Send character to terminal (6)
INX ;Increment byte index (2)
PROMPT LDA MSG_00,X ;Get string data (4)
BNE PROMPT1 ;If null character, exit (borrowed RTS) (2/3)
;
HINEXIT RTS ;And return to caller
;
Code: Select all
;Data Output A routine: puts the data in the A Reg into the xmit buffer, data in
; A Reg is preserved on exit. Transmit is IRQ driven/buffered with a size of 128 bytes.
;
CHROUT PHY ;Save Y Reg (3)
OUTCH LDY OCNT_A ;Get data output count in buffer (3)
BMI OUTCH ;Check against limit, loop back if full (2/3)
;
LDY OTAIL_A ;Get the buffer tail pointer (3)
STA OBUF_A,Y ;Place data in the buffer (5)
INC OTAIL_A ;Increment Tail pointer (5)
RMB7 OTAIL_A ;Strip off bit 7, 128 bytes only (5)
INC OCNT_A ;Increment data count (5)
;
LDY #%00000100 ;Get mask for xmit on (2)
STY UART_COMMAND_A ;Turn on xmit (4)
;
PLY ;Restore Y Reg (4)
RTS ;Return to caller (6)
;
Code: Select all
MSG_49 .DB $0D,$0A
.DB "Memory Ops: "
.DB "[C]ompare, "
.DB "[D]isplay, "
.DB "[E]dit, "
.DB "[F]ill, "
.DB "[G]o Exec,",$0D,$0A
.DB "[H]ex Find, "
.DB "[I]nput Text, "
.DB "[M]ove, "
.DB "[T]ext Find",$0D,$0A,$0A
.DB "Register Ops: "
.DB "R,A,X,Y,S,P",$0D,$0A,$0A
.DB "Counter/Timer Ops: "
.DB ",= set ms|mult, "
.DB ".= exe ms, "
.DB "/= exe ms*mult",$0D,$0A
.DB "[B]enchmark clear/start, "
.DB "[Q]uit benchmark/display elapsed time",$0D,$0A,$0A
.DB "Macro: "
.DB "(= Init "
.DB ")= Run",$0D,$0A,$0A
.DB "CTRL[?]: "
.DB "[A]ssemble, "
.DB "[B]oot DOS/65, "
.DB "[D]isassemble, "
.DB "[E]dit EEPROM, "
.DB "[L]oad",$0D,$0A
.DB "[P]rogram, "
.DB "[Q]uery Cmds ,"
.DB "[R]eset, "
.DB "[S]ave, "
.DB "[T]ime/Date, "
.DB "[V]ersion",$0D,$0A
.DB "[Z]ero RAM/Reset",$0A
.DB $00
;
Code: Select all
ldx #M1N_08
jsr PROMPT1
ldx #M2N_09
jsr PROMPT2