English Amiga Board


Go Back   English Amiga Board > Coders > Coders. General

 
 
Thread Tools
Old 11 August 2011, 21:02   #1
Jherek Carnelia
Dazed and Confused
Jherek Carnelia's Avatar
 
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?
Jherek Carnelia is offline  
Old 11 August 2011, 21:14   #2
Leffmann
 
Join Date: Jul 2008
Location: Sweden
Posts: 2,265
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.
Leffmann is offline  
Old 11 August 2011, 21:24   #3
hitchhikr
Registered User

 
Join Date: Jun 2008
Location: somewhere else
Posts: 431
It's actually ExecBase->ThisTask
hitchhikr is offline  
Old 11 August 2011, 21:33   #4
Jherek Carnelia
Dazed and Confused
Jherek Carnelia's Avatar
 
Join Date: Dec 2001
Location: portsmouth/uk
Posts: 242
Thank you chaps
Jherek Carnelia is offline  
Old 11 August 2011, 21:35   #5
Thorham
Computer Nerd

Thorham's Avatar
 
Join Date: Sep 2007
Location: Rotterdam/Netherlands
Age: 45
Posts: 3,232
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)?
Thorham is offline  
Old 11 August 2011, 22:28   #6
thor
Registered User
thor's Avatar
 
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).
thor is offline  
Old 11 August 2011, 23:28   #7
Jherek Carnelia
Dazed and Confused
Jherek Carnelia's Avatar
 
Join Date: Dec 2001
Location: portsmouth/uk
Posts: 242
Quote:
Originally Posted by Thorham View Post
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)?
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!
Jherek Carnelia is offline  
Old 12 August 2011, 04:29   #8
Steady
 
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.
 
Old 12 August 2011, 09:47   #9
StingRay
move.l #$c0ff33,throat

StingRay's Avatar
 
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,652
Quote:
Originally Posted by Thorham View Post
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)?
Quote:
Originally Posted by Jherek Carnelia View Post
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!
There is absolutely nothing wrong doing it that way, it's a commented part of execbase so it can be used without any problems.
StingRay is offline  
Old 12 August 2011, 19:06   #10
Thorham
Computer Nerd

Thorham's Avatar
 
Join Date: Sep 2007
Location: Rotterdam/Netherlands
Age: 45
Posts: 3,232
Thanks guys

Quote:
Originally Posted by StingRay View Post
There is absolutely nothing wrong doing it that way, it's a commented part of execbase so it can be used without any problems.
Yep It says that most fields shouldn't be read or written (I thought none of the fields should be used directly), but it also says when it's fine to do so, and in this case it is
Thorham is offline  
Old 12 August 2011, 21:32   #11
Leffmann
 
Join Date: Jul 2008
Location: Sweden
Posts: 2,265
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.
Leffmann is offline  
Old 13 August 2011, 02:00   #12
StingRay
move.l #$c0ff33,throat

StingRay's Avatar
 
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,652
Quote:
Originally Posted by Leffmann View Post
Generally it's better to ask the operating system for any value you need whenever you can.
And what is exec for you? Not a part of the OS?

Quote:
Originally Posted by Leffmann View Post
If any functionality gets patched or otherwise hooked then any code like this will just fall through.
I'd rather not use any patches that will make perfectly valid code "just fall through".
StingRay is offline  
Old 13 August 2011, 12:04   #13
Leffmann
 
Join Date: Jul 2008
Location: Sweden
Posts: 2,265
Quote:
Originally Posted by StingRay View Post
And what is exec for you? Not a part of the OS?
You don't understand, it's about asking the OS through function calls instead of getting stuff yourself by peeking inside system structures.

Quote:
Originally Posted by StingRay View Post
I'd rather not use any patches that will make perfectly valid code "just fall through".
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.
Leffmann is offline  
Old 15 August 2011, 17:55   #14
Thorham
Computer Nerd

Thorham's Avatar
 
Join Date: Sep 2007
Location: Rotterdam/Netherlands
Age: 45
Posts: 3,232
Quote:
Originally Posted by Leffmann View Post
You don't understand, it's about asking the OS through function calls instead of getting stuff yourself by peeking inside system structures.
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.
Thorham is offline  
 


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? Akira project.EAB 14 07 January 2004 10:48
Looking for some routine code Akira 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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 13:33.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, vBulletin Solutions Inc.
Page generated in 0.13783 seconds with 13 queries