nesdev.com
http://forums.nesdev.com/

ASM6 endian-ness for LDA and CMP
http://forums.nesdev.com/viewtopic.php?f=10&t=17175
Page 1 of 1

Author:  sailense [ Thu Mar 22, 2018 4:37 pm ]
Post subject:  ASM6 endian-ness for LDA and CMP

So, I just fixed a bug where my gamestate wasn't being tracked properly. The issue was this:

I have defines for things to make the code more readable:

Code:
STATE_START = $00
STATE_CHARSELECT = $01
STATE_LEVELSTART = $02
STATE_RUNNING = $03
STATE_STATUS = $04


When I do LDA, for example with STATE_RUNNING, it works fine and A = $03. But if I do a compare, like:

Code:
CMP #STATE_CHARSELECT


It seems to expand $03 into $0003 and only loads the high byte. The debugger shows that A gets the proper value of $01 but the compare is done against $00. I fixed it by doing:

Code:
CMP #<STATE_CHARSELECT


My question is: is this the normal behaviour of the assember? Like, is this general to all assemblers and a part of addressing that I'm not aware of or a quirk of ASM6?

Author:  tokumaru [ Thu Mar 22, 2018 4:40 pm ]
Post subject:  Re: ASM6 endian-ness for LDA and CMP

That's not normal at all, and I don't remember ever running into something like this during the long time I used ASM6.

Author:  sailense [ Thu Mar 22, 2018 4:47 pm ]
Post subject:  Re: ASM6 endian-ness for LDA and CMP

tokumaru wrote:
That's not normal at all, and I don't remember ever running into something like this during the long time I used ASM6.


You're right. I wasn't able to reproduce it and it works fine without specifying the low byte. Chalk this down to me being a newbie and probably having some other issue that was messing with it ;)

Author:  tokumaru [ Thu Mar 22, 2018 5:16 pm ]
Post subject:  Re: ASM6 endian-ness for LDA and CMP

Maybe you forgot the # and were in fact loading from zero page address $03, which likely contained a zero?

Author:  sailense [ Thu Mar 22, 2018 7:08 pm ]
Post subject:  Re: ASM6 endian-ness for LDA and CMP

tokumaru wrote:
Maybe you forgot the # and were in fact loading from zero page address $03, which likely contained a zero?


That's actually a likely scenario. I only recently started to grok zero page and direct/indirect addressing.

Page 1 of 1 All times are UTC - 7 hours
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/