Espozo wrote:I don't know why it just now occurred to me to check the listing file...
I don't think this is correct. Shouldn't there be 3 sets of "rr"?
Code: Select all
0003DDr 1 DC rr rr jmp [LongJumpLocation]
I actually wrote "jmp dummy" and it worked perfectly, so this must be the problem.
It occurred to me to write "jml" to force the assembler to do 24 bit addressing, but it still assembled to be 16 bit. :(
Code: Select all
0003DDr 1 DC rr rr jml [LongJumpLocation]
Is this a bug with ca65?
No, the bug is in you. :-) You're using
jml [Address]. The brackets here are important. This is asking for the addressing mode absolute indirect long, which assembles to opcode $DC (correct), and consists of 3 total bytes (i.e. 1 opcode byte, 2 operand bytes). This is **indirect** addressing, which means the full 24-bit address is what's stored in memory location LongJumpLocation (i.e. if LongJumpLocation = $1100, then byte at $1100 = low byte of address to jump to, byte at $1101 = high byte of address to jump to, byte at $1102 = bank byte of address to jump to). That probably isn't going to make any sense to you, so I'll rewrite it in code:
Code: Select all
LongJumpLocation .res 3 ; Needs to be in RAM or direct page
sep #$20
lda #$45
sta LongJumpLocation
lda #$23
sta LongJumpLocation+1
lda #$01
sta LongJumpLocation+2
jml [LongJumpLocation] ; Will assemble to $DC {2-byte address of LongJumpLocation}
;
; This will end up jumping to $012345.
;
Now compare that to:
Code: Select all
LongJumpLocation = $6789ab
jml LongJumpLocation ; Will assemble to $5C AB 89 67
;
; This will end up jump to $6789ab.
;
If you wanted an absolute 24-bit jump, you'd want
jml LongJumpLocation. Whether or not you want indirect addressing depends on what you're trying to do and "how" you're using LongJumpLocation. There's no way any of us would know this.
As for the JMP vs. JML syntax: you can use the pseudo-op JML for two opcodes: either absolute long addressing (i.e.
jml LongJumpLocation) or absolute indirect long addressing (i.e.
jml [LongJumpLocation]). Both are considered acceptable.
I strongly urge you to go look at the
WDC 65816 documentation - specifically PDF page 459 -- and look/read the opcode chart there very carefully.
There is no "absolute indirect long jump" that has a full 24-bit address in the operand list (i.e. a 4 byte instruction). Your choices are absolute long, or absolute indirect long.