Hello,
I'm new to assembly, so I'm struggling with some of the basic concepts. I'm not new to programming, just assembly.
Anyway, I'm using ACME right now, and I've written a "Hello World" program that displays "Hello World" on a 20x4 LCD display hooked up to the VIA. To start with, I hard coded the string into the assembly program using
Code:
*=$8100
.hello !text "Hello World",0,$FF
That put the ASCII codes for "Hello World" followed by a 0 and $FF at address $8100 in the ROM.
I then had some code that copied that to address $0300 in RAM:
Code:
COPY_TEXT:
LDX #$00
COPY_LOOP:
LDA $8100,X
STA $0300,X
BEQ COPY_DONE
INX
JMP COPY_LOOP
COPY_DONE:
RTS
Finally, I had some code that put the "text" at $0300 out to the VIAs outputs in such a way that it would display it on the LCD.
Code:
OUT_TEXT:
LDX #$00
OUTLOOP:
LDY $0300,X
BEQ LOOP_DONE
JSR DATA
INX
JMP OUTLOOP
LOOP_DONE:
RTS
(the code at DATA would put the data on the VIA's outputs so that the LCD new it was getting data instead of a command).
The thought process was that eventually, I could put any text I wanted at $0300, and then call the OUT_TEXT subroutine, and the text would be displayed.
The problem I'm having is that I can't figure out how to have variable strings.
For example, say I want to put, "Some Variable = $12" on the LCD, I figured I could create a string with something like
Code:
.variable=$12
.string !text "Some Variable = ", #.variable,0
Then call some code to copy .string to $0300, then call the OUT_TEXT subroutine, and I'd have my text on my LCD.
But that second line of code hard codes the value into the ROM, and doesn't create anything in the memory that is dynamic.
Is there a way for me to create a dynamic string, or do I have to create a static string for the "Some Variable = " part, and when I need to set it into $0300, copy it out there, then copy the variable's value, then call OUT_TEXT?
I know this is super basic, and I'm sorry for that. I've read through the docs for ACME a few times looking for an answer to this, and haven't found one. I've searched the internet, and haven't found an answer there, either.
Thanks a bunch.