BlueAmulet/Thistle

Some instructions not working?

Closed this issue · 6 comments

My apologies if this is a dumb issue,
I have successfully recompiled for 1.12.2 and I have noticed that some instructions do not work, mainly branch instructions, so I was thinking maybe it was just a thing with the recompiled one, but it appears to not work for the earlier versions too.
I have tried the different formatting/addressing modes such as ($XXXX), $XXXX, #$XX and it doesn't seem to work.
The boot.s remains the same.

20kdc commented

Are these the branch instructions as assembled by boot.s, or the branch instructions at CPU level? (The latter would result in boot.s not working properly at all)

I think they're assembled by boot.s/rom, as when typed in, it just shows "Unknown Command", others work fine, I was going to fork the repo to add some example programs but then ran into this problem, after having a look through the boot.s all the branch commands are in there.

20kdc commented

So doing further investigation, I just realized you're specifically talking about the branch instructions as in relative branches, i.e. BRA, etc.
These use relative addressing. The assembler doesn't support using absolute targets for these instructions - instead you must use the syntax, say, 0x05 (to skip 5 bytes after the end of the branch instruction), or 0xFB (to skip 5 bytes back - keeping in mind that 2 of those bytes include the branch instruction itself). This number can be prefixed with -.
An example program (warning: causes flashing stripes, primarily due to laziness on my part):

LDA #$41
STA $E003
LDA #$0A
STA $E003
BRA -0x0C

Ah I see, partly an error on my end, my apologies, It would be useful if things like this were documented in the wiki if not already, thank you!

20kdc commented

Ahead of you in that regard: I added it to the boot ROM manual after realizing what had happened.

20kdc commented

Closing as not a software issue and the relevant wiki change was made.