11 August 2011, 21:02 | #1 |
Dazed and Confused
Join Date: Dec 2001
Location: portsmouth/uk
Posts: 242
|
What's this code doing?
I'm having fun disassembling a C program (one of the RKM examples), anyway there's a bit of code that appears a few times and I don't know how to make sense of it. I guess it's pretty easy when you know, but I don't know where to look...
JSR _LVOSetSignal(A6) MOVEA.L $114(A6),A3 <---- this bit. What's going on here? Several times it gets AbsExecBase in A6 and then moves the value at offset $114. But what does that value represent? What include file do I need to look at? |
11 August 2011, 21:14 | #2 |
Join Date: Jul 2008
Location: Sweden
Posts: 2,269
|
It's part of the execbase, and is the pointer to your task. It's the value you get when you call FindTask with an argument of 0. You can find the info in the description of the execbase in execbase.h and execbase.i, and also with printed out offsets in the Structure.Offsets file in the Amiga NDK.
|
11 August 2011, 21:24 | #3 |
Registered User
Join Date: Jun 2008
Location: somewhere else
Posts: 510
|
It's actually ExecBase->ThisTask
|
11 August 2011, 21:33 | #4 |
Dazed and Confused
Join Date: Dec 2001
Location: portsmouth/uk
Posts: 242
|
Thank you chaps
|
11 August 2011, 21:35 | #5 |
Computer Nerd
Join Date: Sep 2007
Location: Rotterdam/Netherlands
Age: 47
Posts: 3,749
|
Hmm, shouldn't you use FindTask instead of reading directly? Seems cleaner that way, or is reading this value completely safe (as in theoretical future versions keeping this the same)?
|
11 August 2011, 22:28 | #6 |
Registered User
Join Date: Mar 2006
Location: Germany
Posts: 899
|
Kickstart does exactly the same when you call FindTask(0). (Well, it does move.l $114(a6),d0).
|
11 August 2011, 23:28 | #7 |
Dazed and Confused
Join Date: Dec 2001
Location: portsmouth/uk
Posts: 242
|
That's what I thought too. I always believed it was bad practice, but this is the compiler output... Anyway, I guess that it's never going to change now!
|
12 August 2011, 04:29 | #8 |
Posts: n/a
|
If compilers are doing it there is no way the 68K version would be able to be changed as so much would break. I guess the compiler did it as an optimisation to save on the expense of going through the jumptable when it already has ExecBase to hand.
|
12 August 2011, 09:47 | #9 | ||
move.l #$c0ff33,throat
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,863
|
Quote:
Quote:
|
||
12 August 2011, 19:06 | #10 | |
Computer Nerd
Join Date: Sep 2007
Location: Rotterdam/Netherlands
Age: 47
Posts: 3,749
|
Thanks guys
Quote:
|
|
12 August 2011, 21:32 | #11 |
Join Date: Jul 2008
Location: Sweden
Posts: 2,269
|
Generally it's better to ask the operating system for any value you need whenever you can. If any functionality gets patched or otherwise hooked then any code like this will just fall through.
The reason the compiler produced the above is because the source said exactly what Hitchhikr posted. Inlining a function call like this, for which the compiler doesn't have any corresponding source or object file for, would be prone to fail. |
13 August 2011, 02:00 | #12 | |
move.l #$c0ff33,throat
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,863
|
Quote:
I'd rather not use any patches that will make perfectly valid code "just fall through". |
|
13 August 2011, 12:04 | #13 |
Join Date: Jul 2008
Location: Sweden
Posts: 2,269
|
You don't understand, it's about asking the OS through function calls instead of getting stuff yourself by peeking inside system structures.
These could be things like SetPatch, RTG, programs like SnoopDos, Scout, FBlit or anything. It's not necessarily about just reading some value from memory. The whole point is that if you use established interfaces your program is more likely to benefit from things like these. |
15 August 2011, 17:55 | #14 |
Computer Nerd
Join Date: Sep 2007
Location: Rotterdam/Netherlands
Age: 47
Posts: 3,749
|
Reading values directly should be fine if the docs say it's fine. In the case of execbase->ThisTask the include file says it's readable. Changing this can break things, and thus it wouldn't have changed in future versions.
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
My old source code | gemanix | Coders. General | 36 | 09 July 2017 13:33 |
AmiBlitz code | AlfaRomeo | Coders. Tutorials | 4 | 23 February 2010 18:39 |
[code] tag? | Amiga1992 | project.EAB | 14 | 07 January 2004 10:48 |
Looking for some routine code | Amiga1992 | Coders. General | 4 | 17 December 2003 23:51 |
3D code and/or internet code for Blitz Basic 2.1 | EdzUp | Retrogaming General Discussion | 0 | 10 February 2002 11:40 |
|
|