6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Fri Nov 01, 2024 2:18 am

All times are UTC




Post new topic Reply to topic  [ 7 posts ] 
Author Message
PostPosted: Wed Sep 01, 2021 5:57 pm 
Offline

Joined: Wed Sep 01, 2021 5:47 pm
Posts: 6
I am using calculated addresses to push onto the stack and return from, but when I use

Code:
addressTableH
    .byte >address00, etc
addressTableL
    .byte <address00-1, etc


I get a range error (not within 255) whenever the lowbyte of an address is 0 and causes an underflow. I am sure there is a simple way around this, I can't find it though.


Top
 Profile  
Reply with quote  
PostPosted: Wed Sep 01, 2021 6:07 pm 
Offline

Joined: Sun Jun 29, 2014 5:42 am
Posts: 352
reesey-spoon wrote:
I get a range error (not within 255) whenever the lowbyte of an address is 0 and causes an underflow. I am sure there is a simple way around this, I can't find it though.

Try this:
Code:
addressTableH
    .byte >(address00-1), etc
addressTableL
    .byte <(address00-1), etc


Top
 Profile  
Reply with quote  
PostPosted: Wed Sep 01, 2021 6:10 pm 
Offline

Joined: Wed Sep 01, 2021 5:47 pm
Posts: 6
hoglet wrote:
Try this:
Code:
addressTableH
    .byte >(address00-1), etc
addressTableL
    .byte <(address00-1), etc


Thank you! I'll try it tonight


Top
 Profile  
Reply with quote  
PostPosted: Wed Sep 01, 2021 7:08 pm 
Offline
User avatar

Joined: Thu May 28, 2009 9:46 pm
Posts: 8467
Location: Midwestern USA
hoglet wrote:
Try this:
Code:
addressTableH
    .byte >(address00-1), etc
addressTableL
    .byte <(address00-1), etc

Yuh beat me to it! :D

_________________
x86?  We ain't got no x86.  We don't NEED no stinking x86!


Top
 Profile  
Reply with quote  
PostPosted: Sun Sep 26, 2021 6:25 pm 
Offline

Joined: Wed Sep 01, 2021 5:47 pm
Posts: 6
hoglet wrote:
Try this:
Code:
addressTableH
    .byte >(address00-1), etc
addressTableL
    .byte <(address00-1), etc



I'm guessing the -1 NEEDS to be on both the High and Low address. I have been hunting down a bug for the past few days and I think its because, after reading your advice, I only but it on the low byte side.


Top
 Profile  
Reply with quote  
PostPosted: Sun Sep 26, 2021 8:11 pm 
Offline
User avatar

Joined: Wed Feb 14, 2018 2:33 pm
Posts: 1482
Location: Scotland
reesey-spoon wrote:
hoglet wrote:
Try this:
Code:
addressTableH
    .byte >(address00-1), etc
addressTableL
    .byte <(address00-1), etc



I'm guessing the -1 NEEDS to be on both the High and Low address. I have been hunting down a bug for the past few days and I think its because, after reading your advice, I only but it on the low byte side.


Indeed - so say for example, the target address is $8000, then >$8000 is $80 and <$8000 is $00, but by just taking 1 from the low byte you get: >$8000 = $80 and <$7FFF = $FF, so the resulting address is $80FF which isn't what you want, so >$7FFF = $7F and <$7FFF is $FF which is what you want.

So you have an address that lands on a page boundary $xx00 and it crashes. This is a tricky thing to fix as simply adding in debug code can change the target address which may then cause it to work! it's only when address00 is $xx00 that you'll have issues.


-Gordon

_________________
--
Gordon Henderson.
See my Ruby 6502 and 65816 SBC projects here: https://projects.drogon.net/ruby/


Top
 Profile  
Reply with quote  
PostPosted: Sun Sep 26, 2021 11:01 pm 
Offline

Joined: Wed Sep 01, 2021 5:47 pm
Posts: 6
drogon wrote:

Indeed - so say for example, the target address is $8000, then >$8000 is $80 and <$8000 is $00, but by just taking 1 from the low byte you get: >$8000 = $80 and <$7FFF = $FF, so the resulting address is $80FF which isn't what you want, so >$7FFF = $7F and <$7FFF is $FF which is what you want.

So you have an address that lands on a page boundary $xx00 and it crashes. This is a tricky thing to fix as simply adding in debug code can change the target address which may then cause it to work! it's only when address00 is $xx00 that you'll have issues.


-Gordon


Yes I found this out the hard way. My program was hanging at "random" intervals. Took me quite some time to realize it was unrelated to what I was working on at the moment. Thank you for all your help


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

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


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: