Page 1 of 1

64tass odd behavior with labeled jmp and jsr opcodes

Posted: Fri Sep 16, 2022 2:17 am
by load81
So, I've encountered a strange issue with 64tass. When I use labels with jmp and jsr these opcodes don't get pointed to the memory location I expect. Passing labels to branch instructions, example bcc, works just fine. I've checked and I don't see any obvious cases of double-defining a label or any simple mistake like that. I also double-checked the documentation and in the .ptext section I can see a jsr being used with a label.

For clarity sake, here is a random slice of code:

Code: Select all

L_8284                  lda $19                      ; $8284    $a519   ;
                        sta $1d                      ; $8286    $851d   ;
                        dec $15                      ; $8288    $c615   ;
                        beq L_828f                   ; $828a    $f003   ;
                        jmp L_8200                   ; $828c    $4c0082 ;
L_828f                  ldy #$17                     ; $828f    $a017   ;
                        ldx #$17                     ; $8291    $a217   ;
L_8293                  lda $9fb0,x                  ; $8293    $bdb09f ;
The column on the left contains labels followed by opcodes and operands. The columns on the right enclosed in comments contain the current memory offset followed by the raw bytes of the opcode and operand for that line. Branching to L_828f works just fine. But, passing L_8200 to the jmp instruction produces unexpected output when I assemble the file. I'm disassembling and reassembling a cartridge. I've just about got it working except for this. What am I missing?

I'm running 64tass v1.56 r2625 on Linux; I built the 64tass binary myself as it's not in my OS's software repo.

Re: 64tass odd behavior with labeled jmp and jsr opcodes

Posted: Fri Sep 16, 2022 3:56 am
by GARTHWILSON
I'm not familiar with 64tass; but it looks like your labels are merely the address tacked onto the end of "L_". Remember that JMP's operand goes low byte first; so JMP $8200 will come out 4C 00 82.

Re: 64tass odd behavior with labeled jmp and jsr opcodes

Posted: Fri Sep 16, 2022 5:13 pm
by load81
I got it to work. I missed two important things.

My *= variable was not quite correct and I was missing a flag with 64tass. It's working now.