I have built a simple single board computer, and am trying to learn 6809 assembly language. I have got a few simple things running, Echo over via a 6850 ACIA for example. I am trying to print a string and am stuck.
The string is in ROM and terminated with null zero. I load the X register to point to start of the string. Later I load character pointed to by X to A register, and X is incremented. Then test for null zero before outputing the character to the ACIA. I have connected a simple logic analyser to the data bus, and know that nothing is output to the ACIA because it sees a zero instead of the first character, and thinks the string has finished. I can't see a bug in the code, and it could be hardware related, but need an experienced eye to look it over in case I'm making a beginners error.
Here is the assembly:
*******************************EQUATES****************************************
***ACIA register definitions****
ACIA_control EQU $A000 ;write only
ACIA_status EQU $A000 ;read only
ACIA_data EQU $A001 ;read/write
********************************STRING CONSTANT******************************
ORG $C000 ; ROM starts here
***store string to send out on serial***
*Pseudo op FCN stores characters in sequential bytes,
*and automatically adds null zero.
start_of_string
FCN "The quick brown fox jumps over the lazy dog"
**********************************SETUP****************************************
setup
***reset_ACIA***
LDA #%00000011
STA ACIA_control
***set_ACIA_mode***
;clock/64 gives 19,200 baud with 4.9152 MHz xtal
;8 bits, 1 stop bit, no parity
;/RTS inactive (set high), TX interupt disabled, RX interupt disabled
LDA #%01010110
STA ACIA_control
*********************************SEND LOOP**************************************
reset_index_register
LDX start_of_string
***Is ACIA ready to TX***
wait LDA #%00000010
ANDA ACIA_status
BEQ wait
***send character***
LDA ,X+
BEQ end_of_string; string finished at null zero
STA ACIA_data
BRA wait ;next character
***LOOP BACK***
end_of_string
BRA reset_index_register
*********************************VECTORS****************************************
***RESET***
ORG $FFFE
FDB setup ;Jump to programme entry