06 January 2022, 18:40 | #1 |
Registered User
Join Date: Feb 2018
Location: Northumberland, UK
Posts: 272
|
Different results with BSR and non-BSR code
Evening!
Why would calling code via a BSR act differently to calling the exact same code inline? For example, in my startup I've got the following to disable the OS: Code:
lea $dff000,a6 bsr WaitEOF move.l $1c(a6),-(sp) move.w 2(a6),-(sp) move.l INTVECTORL2(a4),-(sp) move.l INTVECTORL3(a4),-(sp) Code:
DisableSystem: lea $dff000,a6 bsr WaitEOF move.l $1c(a6),-(sp) move.w 2(a6),-(sp) move.l INTVECTORL2(a4),-(sp) move.l INTVECTORL3(a4),-(sp) rts Code:
move.l $1c(a6),-(sp) Anyone else know why this would be the case? |
06 January 2022, 18:43 | #2 |
move.l #$c0ff33,throat
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,863
|
Just a hint: watch your stack. And ask yourself where the return address comes from. And then check your "DisableSystem" routine.
|
06 January 2022, 18:46 | #3 | |
Registered User
Join Date: Feb 2017
Location: Denmark
Posts: 1,098
|
BSR/RTS also uses the stack, so when you do:
Quote:
|
|
06 January 2022, 19:15 | #4 |
Registered User
Join Date: Feb 2018
Location: Northumberland, UK
Posts: 272
|
Ooooooooh... of course, the return address is stored in the stack isn't it!
|
06 January 2022, 21:46 | #5 |
Registered User
Join Date: Jan 2019
Location: Germany
Posts: 3,215
|
The "why" has been answered, though there is also a solution for you in case you want to use a subroutine for storing data on the stack. Code:
Sub: ... do something ... move.l (a7)+,d0 ;get return address move.l ....,-(a7) ;store stuff on the stack move.l ...,-(a7) ; more stuff... move.l d0,-(a7) ; restore return address rts |
06 January 2022, 23:35 | #6 | |
Registered User
Join Date: Feb 2018
Location: Northumberland, UK
Posts: 272
|
Quote:
Regarding the system though; the whole point of me jumping into ASM coding on the Amiga in the first place was to learn how to 'bang the metal' as was done in the good old days. I've coded plenty of system friendly Amiga apps in the past so time to go old skool I reckon! |
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Profiling C code, interpreting results | Ernst Blofeld | Coders. C/C++ | 5 | 19 November 2020 18:45 |
bsr.l on 68000 doesn't crash | StingRay | support.WinUAE | 5 | 22 September 2012 21:43 |
Undefined symbol bsr.b init_bitmaps | VoltureX | Coders. General | 12 | 13 November 2011 16:11 |
clr.b -(SP) followed by bsr... | Photon | Coders. General | 19 | 18 January 2011 22:42 |
68040 MMU jsr/bsr | Toni Wilen | Coders. General | 5 | 28 April 2010 20:57 |
|
|