Romhacking.net

Romhacking => Programming => Topic started by: Mikey88 on February 08, 2015, 04:26:57 PM

Title: SNES ASM direct page addressing
Post by: Mikey88 on February 08, 2015, 04:26:57 PM
While tracing in Geiger's Debugger I ran into this.

$00/841A DD FF FF    CMP $FFFF,x[$00:01FE]   A:83F6 X:01FF Y:0000 P:eNvmxdIzC
$00/841D F0 6C       BEQ $6C    [$848B]      A:83F6 X:01FF Y:0000 P:envmxdIzC


I understand (or thought i understood) CMP $FFFF,x is comparing the value at address $00:01FE. Then if equal, branch. What i am having trouble with is, if it says BEQ $6C and the DP is #$00 I thought the effective address would be $006C, but the debugger says $848B. I am not quite sure how it is getting this address. Any help would me much appreciated.[/code]
Title: Re: SNES ASM direct page addressing
Post by: mziab on February 08, 2015, 04:43:22 PM
It's not direct page addressing. Branch instructions use Program Counter relative addressing. The operand is actually a signed number relative to the next opcode.
Title: Re: SNES ASM direct page addressing
Post by: Mikey88 on February 08, 2015, 05:27:15 PM
Great! Thank you! I did not know branching used a different addressing mode. I see now it is the program counter #$841F + #$6C = #$848B. Thanks again!