Hello norticum,
A couple of comments about Eckhard's sub-routine -
- The sub-routine assumes that the string data is terminated with a zero byte value.
- The sub-routine will work only if the value H:X remains unaltered by the write_char sub-routine. Perhaps check that this is so. If not, you might consider modifying write_char by saving the H:X entry value(s) to the stack, and restoring them on exit.
- The H-register must have a value of zero for the sub-routine to operate correctly. This might be explicitly initialised with ldhx #0 as the first instruction (in lieu of clrx).
For a more general sub-routine that is capable of sending many different strings to the LCD, consider entering the sub-routine with the H:X value already set to the start address of a particular string.
MSG1:
dc.b "Hello",0
...
ldhx #MSG1
jsr send_string
...
send_string:
lda ,x
beq end_str ; Exit if end of string
jsr write_char
aix #1 ; Next string character
bra send_string ; Loop always
end_str:
rts
Again, the write_char sub-routine must not alter the H:X value.
Regards,
Mac
Message Edited by bigmac on 2009-11-28 03:36 AM