It is currently Sun Feb 25, 2018 1:05 pm

All times are UTC - 7 hours





Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: Sat Dec 30, 2017 1:01 pm 
Offline
User avatar

Joined: Sat Sep 07, 2013 2:59 pm
Posts: 1573
During an interrupt, I do this:

Code:
PHA
TXA
PHA
TYA
PHA

; Regular code.
; ...

PLA
TAY
PLA
TAX
PLA

Now I've seen an example where the last command before the regular code is PHP and the first command after the regular code is PLP (push and pull procssor status).

Is this necessary? Why? Why not?

_________________
Available now: My game "City Trouble".
Website: https://megacatstudios.com/products/city-trouble
Trailer: https://youtu.be/IYXpP59qSxA
Gameplay: https://youtu.be/Eee0yurkIW4
German Retro Gamer article: http://i67.tinypic.com/345o108.jpg


Top
 Profile  
 
PostPosted: Sat Dec 30, 2017 1:12 pm 
Offline
User avatar

Joined: Thu Mar 31, 2016 11:15 am
Posts: 279
Interrupts automatically push the status flags to the stack and RTI automatically pops them.

So no, you don't need to use PHP/PLP. BRK/RTI do the same plus more.


Top
 Profile  
 
PostPosted: Sat Dec 30, 2017 2:26 pm 
Offline
User avatar

Joined: Sat Sep 07, 2013 2:59 pm
Posts: 1573
Thanks. That's good because I didn't do it in my previous game.

_________________
Available now: My game "City Trouble".
Website: https://megacatstudios.com/products/city-trouble
Trailer: https://youtu.be/IYXpP59qSxA
Gameplay: https://youtu.be/Eee0yurkIW4
German Retro Gamer article: http://i67.tinypic.com/345o108.jpg


Top
 Profile  
 
PostPosted: Sat Dec 30, 2017 2:31 pm 
Offline
User avatar

Joined: Fri Nov 19, 2004 7:35 pm
Posts: 4003
it's common to see PHP/PLP because not everyone who codes 6502 knows that interrupts and RTI instructions push and pop the flags.

_________________
Here come the fortune cookies! Here come the fortune cookies! They're wearing paper hats!


Top
 Profile  
 
PostPosted: Sat Dec 30, 2017 4:38 pm 
Offline
User avatar

Joined: Sun Sep 19, 2004 10:59 pm
Posts: 1405
Even if you did do PHP/PLP, you'd want to do PHP first and PLP last so that the Z and X flags wouldn't get modified by the other instructions (TXA, TAX, TAY, TYA, and PLA all modify those flags).

_________________
Quietust, QMT Productions
P.S. If you don't get this note, let me know and I'll write you another.


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 2 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