News: 11 March 2016 - Forum Rules

Author Topic: A snes asm question  (Read 3165 times)


  • Jr. Member
  • **
  • Posts: 59
    • View Profile
    • Parallel Worlds
A snes asm question
« on: July 15, 2012, 09:13:26 am »
Hi snes assembly gurus,

Been trying the following in snes9x (also tried in zsnes):

Code: [Select]
$0D/FC49 97 07       STA [$07],y[$7E:C756]   A:2C04 X:0000 Y:FFC0 P:envmxdizc

Where $07 has 96 C7 7E in it ( ie 0x7EC796), operating in 16 bit mode as per processor flags.

The trace log seems to say that it writes to 7EC756 (0x7EC796- 0x40, as per Y register), but in actual fact it wrote to 0x7EC796+0xFFC0 = 0x7FC756 instead.

Bug in emulator or as per real snes hardware? Wouldn't think the real snes would jump memory banks like that :huh:

Unless there's some assembly notes I'm missing I would assume it should have done the subtraction and did as per what the logs said.


  • Hero Member
  • *****
  • Posts: 910
    • View Profile
Re: A snes asm question
« Reply #1 on: July 15, 2012, 10:13:16 am »
0x7fc756 would be the correct address to write to. The square brackets basically imply 24-bit addresses and are fully handled as such. It's just that the Snes9x debugger displays this incorrectly, probably because it doesn't take the final address but does the calculation itself (in the wrong way).

Also, you should try bsnes next time. What bsnes does usually also applies to the real hardware.


  • Forum Moderator
  • Hero Member
  • *****
  • Posts: 647
  • Who ya gonna call
    • View Profile
    • Arc-Nova - Rohmackin' and Chiptunin'
Re: A snes asm question
« Reply #2 on: July 15, 2012, 08:00:01 pm »
Generally speaking, any address calculation that has an index register (X or Y) can extend into the next bank. In contrast, address calculations that don't use an index register will almost certainly wrap when they exceed 0xffff in the local part. Source: WDC's "Programming the 65816"