26 January 2017, 15:14 | #1 | |
Registered User
Join Date: Sep 2007
Location: Stockholm
Posts: 4,332
|
Call vs JSR
Quote:
|
|
26 January 2017, 15:57 | #2 |
Registered User
Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 6,334
|
Hmmm, it doesn't sound like it. I've only ever used JSR so I can't be sure, but it just sounds like a "BASIC-ified" wrapper for JSR.
|
26 January 2017, 17:08 | #3 |
Registered User
Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 6,334
|
I can't make sense of the token numbers in the Blitz source, so I'll have a look tonight when I'm in front of my Amiga. But it looks like it just does some stack shuffling and then calls the JSR:
Code:
JL_0_25C: CNIF #return0=1 ADDQ.l #4,a7 JSR -$8a(a6) MOVEM.l (A7)+,A0-A1/A6 RTS CELSE MOVE.l #AL_0_268,D0 TRAP #$0 CEND |
27 January 2017, 03:32 | #4 |
Unregistered User
Join Date: Nov 2005
Location: Tasmania
Age: 42
Posts: 893
|
I can't say what the differences are between many Blitz functions and their 68K ASM equivalents.
Personally I made a habit of using 68K instructions instead of Blitz functions whenever I could, under the assumption that using them might somehow make my code that little bit more efficient, for example I would use: JSR instead of GoSub or GoTo RTS instead of Return LSL instead of *2, *4, *8, etc. LSR instead of /2, /4, /8, etc. and sometimes BEQ or BNE with the appropriate value instead of JoyB and other condition checks. But I honestly don't know if there is any actual improvement/optimisation of final binary going on when using these instead of Blitz functions (although I suspect that LSL/LSR are quite a bit faster than standard math routines). If someone could shed some light on the issue that would be handy. Last edited by Anakirob; 27 January 2017 at 03:39. Reason: typo |
27 January 2017, 11:03 | #5 |
Registered User
Join Date: Sep 2007
Location: Stockholm
Posts: 4,332
|
Even the AMOS compiler translates multiplications in powers of two into shifts. I can't imagine Blitz being any worse.
|
31 January 2017, 17:46 | #6 |
Registered User
Join Date: Sep 2007
Location: Stockholm
Posts: 4,332
|
So does this mean that A0, A1 and A6 are saved on the stack using CALL?
|
31 January 2017, 19:49 | #7 |
AMOS Extensions Developer
Join Date: Jun 2007
Location: near Cambridge, UK
Age: 44
Posts: 1,924
|
Why not try a simple test to find out?
|
31 January 2017, 23:08 | #8 |
Registered User
Join Date: Sep 2007
Location: Stockholm
Posts: 4,332
|
I don't have the necessary mastery of the debugger.
|
02 February 2017, 12:50 | #9 |
Registered User
Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 6,334
|
Well, bear in mind that I'm still not sure that's the actual Call token code... But it actually looks like it's pulling those registers back off the stack after returning from the JSR. Not sure at which point they're pushed onto the stack, so I think there's more to it. Thinking about it, if Call just jumps the PC to another address, why would it need any stack shuffling at all?
|
02 February 2017, 12:59 | #10 |
Registered User
Join Date: Sep 2007
Location: Stockholm
Posts: 4,332
|
It would make more sense if it actually saved those registers which are vital to Blitz instead of some random address registers.
|
02 February 2017, 15:38 | #11 |
Registered User
Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 6,334
|
Yep, which is why I have my doubts about it now. Hmmmm, more investigation is needed...
|
02 February 2017, 22:45 | #12 |
AMOS Extensions Developer
Join Date: Jun 2007
Location: near Cambridge, UK
Age: 44
Posts: 1,924
|
In standard ASM, a6 is used for the user/custom stack pointer and a7 (or PC) is used as the program counter.
Of course, this is Blitz and may not be following normal ASM conventions... |
02 February 2017, 22:50 | #13 |
Registered User
Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 6,334
|
Yeah, Blitz uses A7 as the stack pointer according to the documents. PC is its own separate register, A6 can be used for whatever you want it seems.
|
03 February 2017, 01:27 | #14 |
Registered User
Join Date: Sep 2007
Location: Stockholm
Posts: 4,332
|
|
04 February 2017, 21:48 | #15 |
Global Moderator
Join Date: Nov 2001
Location: Derby, UK
Age: 48
Posts: 9,355
|
|
05 February 2017, 01:03 | #16 | |
AMOS Extensions Developer
Join Date: Jun 2007
Location: near Cambridge, UK
Age: 44
Posts: 1,924
|
No.
It's been over a year since I coded in ASM so when you questioned what I wrote I wondered if I was getting things mixed up. Here is a quote from a Wiki page (https://en.wikibooks.org/wiki/68000_Assembly): Quote:
I note that I quoted a Wiki and it may be wrong, but I am pretty sure that the above information is correct. Edit: After re-reading what I originally wrote and what I just posted, I realise I meant SP instead of PC Last edited by Lonewolf10; 05 February 2017 at 01:10. Reason: Realised my confusion between PC and SP |
|
05 February 2017, 03:00 | #17 |
Registered User
Join Date: Sep 2007
Location: Stockholm
Posts: 4,332
|
A6 is usually used for library bases as far as I know.
|
05 February 2017, 22:40 | #18 |
AMOS Extensions Developer
Join Date: Jun 2007
Location: near Cambridge, UK
Age: 44
Posts: 1,924
|
Yes, that is what the official documentation recommends. However, it is up to the programmer if they wish to follow it and if they decide to take full control of the machine (e.g. for demo's or games) and pause the background processes (e.g. workbench) then a6 can be used for anything.
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Call for testing | cla | Coders. System | 0 | 26 October 2016 20:49 |
Let's call it karma. Or something. | trooper | Retrogaming General Discussion | 10 | 19 September 2013 23:44 |
Game appears to use weird JSR instructions | MethodGit | Coders. General | 15 | 18 March 2011 16:26 |
68040 MMU jsr/bsr | Toni Wilen | Coders. General | 5 | 28 April 2010 20:57 |
Call to all UK Sceners, old and new! | rc55 | Amiga scene | 6 | 12 February 2008 01:41 |
|
|