It is currently Tue Nov 13, 2018 9:35 am

All times are UTC - 7 hours





Post new topic Reply to topic  [ 20 posts ]  Go to page Previous  1, 2
Author Message
PostPosted: Wed Oct 31, 2018 8:33 am 
Offline
User avatar

Joined: Thu Mar 31, 2016 11:15 am
Posts: 415
You need to save and restore registers A, X, and Y. (assuming you use those registers in the NMI)

You don't need to save the status flags (PHP/PLP).


Top
 Profile  
 
PostPosted: Wed Oct 31, 2018 8:41 am 
Offline
User avatar

Joined: Wed Sep 05, 2018 11:13 am
Posts: 141
Location: Colorado
pubby wrote:
You need to save and restore registers A, X, and Y. (assuming you use those registers in the NMI)

You don't need to save the status flags (PHP/PLP).


My thinking is I only need to pha and pla. The reason is because I'm using a flag to make sure the gameloop has completed before the nmi runs. The only reason I need to save off the A register is because I need to use it to check my nmi_ready flag

_________________
A few of my web games
https://www.embed.com
Or if you're bored at work
https://www.classicsolitaire.com


Top
 Profile  
 
PostPosted: Wed Oct 31, 2018 9:00 am 
Offline

Joined: Tue Aug 28, 2018 8:54 am
Posts: 58
Location: Edmonton, Canada
battagline wrote:
My thinking is I only need to pha and pla. The reason is because I'm using a flag to make sure the gameloop has completed before the nmi runs. The only reason I need to save off the A register is because I need to use it to check my nmi_ready flag


If you are can guarantee 100% that your code will never lag and nmi happens in the middle of your gameloop than yes. If no, you still should save/restore x and y to prevent any weird glitches.


Top
 Profile  
 
PostPosted: Wed Oct 31, 2018 9:28 am 
Online

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 20763
Location: NE Indiana, USA (NTSC)
And the only way to "guarantee 100 percent" is formal proof of correctness, which software engineering curricula have historically not taught in favor of more empirical testing-driven methods. Only E.W. Dijkstra ever really pushed hard for formal methods.


Top
 Profile  
 
PostPosted: Wed Oct 31, 2018 9:39 am 
Offline
User avatar

Joined: Tue Jun 24, 2008 8:38 pm
Posts: 2035
Location: Fukuoka, Japan
battagline wrote:

Ahh, that makes sense. Out of curiosity, what would happen if I didn't rti, but instead did a jmp gameloop?

Thanks


- the last code that was executing will be interrupted and not continue, causing all kind of bad things to happens
- the return address will never be used, causing a stack overflow sooner or later

You're not supposed to do that :) You should always return with RTI.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 20 posts ]  Go to page Previous  1, 2

All times are UTC - 7 hours


Who is online

Users browsing this forum: No registered users and 6 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