It is currently Fri Sep 21, 2018 9:05 pm

All times are UTC - 7 hours





Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: Thu Mar 22, 2018 4:37 pm 
Offline
User avatar

Joined: Wed Mar 14, 2018 6:23 pm
Posts: 9
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?


Top
 Profile  
 
PostPosted: Thu Mar 22, 2018 4:40 pm 
Offline
User avatar

Joined: Sat Feb 12, 2005 9:43 pm
Posts: 10814
Location: Rio de Janeiro - Brazil
That's not normal at all, and I don't remember ever running into something like this during the long time I used ASM6.


Top
 Profile  
 
PostPosted: Thu Mar 22, 2018 4:47 pm 
Offline
User avatar

Joined: Wed Mar 14, 2018 6:23 pm
Posts: 9
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 ;)


Top
 Profile  
 
PostPosted: Thu Mar 22, 2018 5:16 pm 
Offline
User avatar

Joined: Sat Feb 12, 2005 9:43 pm
Posts: 10814
Location: Rio de Janeiro - Brazil
Maybe you forgot the # and were in fact loading from zero page address $03, which likely contained a zero?


Top
 Profile  
 
PostPosted: Thu Mar 22, 2018 7:08 pm 
Offline
User avatar

Joined: Wed Mar 14, 2018 6:23 pm
Posts: 9
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.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 7 hours


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group