self-modifying assembly code?
retrac0 opened this issue · 3 comments
When trying to reference a label as an operand, I get an error that the label is not known.
For example with:
asm {
begin:
lda current_slot // 0xc6
sta rdsector+2
rdsector:
jsr $005c // will be 0xC65C based on current_slot
}
Is there a way around this or some other syntax?
Also, the current git version doesn't seem to like labels on the same line as an assembler statement and will give: "Syntax error: assembly statement expected", though they work when placed on their own line.
Thanks for feedback!
Labels are currently treated in a special way when it comes to compiling parameters and essentially they work only for branching instructions. Sorry for not documenting it anywhere.
I'll improve this a bit in the next version, self-modifying code is too useful not to support.
As for the labels in the same line, it's an oversight. I'll fix it too.
Thanks. Yes, I'm writing a wrapper for ProDOS on the Apple II (I'll post it when it's a little more polished) and some SMC would makes the interface a lot tidier.
As a workaround, I just dumped the bytes for the code into an array, then jump to the array, but that's not so elegant :)
Long story short, I've managed to get what you want to work, it will be in the next release.
In some cases, wrapping the label in label(...)
might be necessary, if only to silence the warning, but for the most part it should just work.