14 September 2021, 20:23 | #1 |
Registered User
Join Date: Apr 2013
Location: paris
Posts: 133
|
move sr and rtr
Hi!
I need to call a subroutine but save/restore X cpu flag. To do that I'm using the nice RTR instruction like: Code:
bsr foo ... foo: move.w sr,-(a7) ; code that could scratch X flag rtr Is that kind of code ( move sr,-(a7) and rtr ) fully ocmpatible with any amiga CPUs? |
14 September 2021, 20:47 | #2 |
Registered User
Join Date: Jun 2016
Location: europe
Posts: 1,039
|
Yeah, it's implemented in hardware in 000-060. Just have to run it in supervisor mode because 010+ requires supervisor for move sr,<ea>, while providing move ccr,<ea> (which 000 doesn't have) for user mode.
|
14 September 2021, 21:09 | #3 | |
Registered User
Join Date: Apr 2013
Location: paris
Posts: 133
|
Quote:
Code:
subx.b d1,d1 ; read X flag in d1 move.w d1,-(a7) bsr MFMDecodeTrackCallback move.w (a7)+,d1 add.b d1,d1 ; restore X flag |
|
14 September 2021, 21:44 | #4 |
Defendit numerus
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 53
Posts: 4,468
|
This?:
Code:
subx.w d1,d1 move.w d1,-(sp) ; code that could scratch X flag rtr Last edited by ross; 14 September 2021 at 22:05. Reason: first version with roxr.b #4, but who cares for other CCR flags :) |
15 September 2021, 01:11 | #5 |
Registered User
Join Date: Apr 2013
Location: paris
Posts: 133
|
|
17 September 2021, 13:03 | #6 | |
Engineer
Join Date: Oct 2018
Location: Shadow realm
Posts: 165
|
Quote:
Whereas move from CCR is 010+, so it will break on plain 68000. A reliable (and fast!) alternative is to call exec.library's GetCC(). Of course, that assumes execbase is available and consistent. If it's not, what I would do is: * Make a function for it, and use get from SR or CCR depending on CPU model. Then call as needed. * If it's used in a single place, implement the detection right there, or set up the right code via self-modifying code. Last edited by admiral; 17 September 2021 at 13:08. Reason: self-modifying code |
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Is move.l atomic | sparhawk | Coders. Asm / Hardware | 1 | 25 December 2019 20:43 |
Move it Move it... (68000) | Gilloo | Coders. Asm / Hardware | 19 | 04 December 2011 17:36 |
Move Em | amigapd | request.Old Rare Games | 1 | 13 March 2011 02:22 |
Please delete or move if necessary | JSemple3 | support.Games | 7 | 30 June 2003 13:59 |
|
|