I'm using the AVR-GCC toolchain to compile a bit of hello world code for an LCD screen and ATmega168. I can get everything to work if my message is an odd number of characters, but not if it is an even number. For instance, "Hello World' displays just fine, but 'Hello World!' displays nothing.
I'm using the .asciz directive to create null terminated strings, then testing for the last byte read from program memory to be zero. Is this the wrong way to do it?
Pertinent code below.
Thanks for any help you can give.
#define mp r16 #define payload r17 #...cut a bunch of code here # ;print message from program memory ldi ZH, hi8(greeting) ldi ZL, lo8(greeting) rcall sendMsg loop: rjmp loop greeting: .asciz "Hello World" sendMsg: lpm payload,Z+ cpi payload,0 ; test for null character breq done ; issues RET command if end of string is found rcall writeChar rjmp sendMsg done: ret writeChar: #...cut a bunch of code here #