14 February 2011, 20:04 | #1 |
tulou
Join Date: Jun 2006
Location: Gothenburg / Sweden
Posts: 88
|
#pragma libcall
Does anybody know if it is possible, in SAS/C, to specify fpu registers as arguments to external library functions? The fd2pragma util supplied with the compiler does not recognize fpX registers at all.
|
15 February 2011, 17:33 | #2 | |
Registered User
Join Date: Sep 2007
Location: Las Cruces, USA
Age: 71
Posts: 351
|
Quote:
I don't know about libcall but regcall you can, this is what I use. For this to work you have to specify 68020/68881 or higher. There may be other things that have to be done, but it's been awhile and unless I have problems I don't mess with it so I tend to forget. I'm a little fuzzy on this but I did look at my includes for my function library and the first function listed for using the 68881 is #pragma regcall(dpabs(fp0)). I hope this helps. Last edited by Ed Cruse; 15 February 2011 at 17:39. |
|
16 February 2011, 11:51 | #3 |
tulou
Join Date: Jun 2006
Location: Gothenburg / Sweden
Posts: 88
|
Thanks! Don't know how to apply that to libcalls though, because they are declared with a different syntax. Can regcalls be used to call functions in an external library (an opened .library-file) ?
|
16 February 2011, 18:21 | #4 | |
Registered User
Join Date: Sep 2007
Location: Las Cruces, USA
Age: 71
Posts: 351
|
Quote:
My problem is I've never called an external library other then the system libs. My function library is a link library. Right now I don't have time to check into this, but later today I'll go look and try to get smarter. |
|
16 February 2011, 20:33 | #5 |
Registered User
Join Date: Sep 2007
Location: Las Cruces, USA
Age: 71
Posts: 351
|
I checked out my SASC includes and they are complicated. There's a directory called 'protos' which is where the pointer to the function is set up, assuming that the library has already been opened. The 'proto' then points to the 'progmas' directory which is where the 'libcall's are. They seem to setup the library pointer, function name, and I think the registers, so this might be good for assembly interface only, not sure.
Do you have the SASC book? It explains all of this. I'm really not sure about this, I've never made a external function library that I had to call from C, I've done it by calling from assembly which is much simpler to understand. |
16 February 2011, 20:55 | #6 |
tulou
Join Date: Jun 2006
Location: Gothenburg / Sweden
Posts: 88
|
the libcall pragma declares the library vector offset for some given function, and the register arguments are given with hex digits afterwards (0-f corresponds to d0-a7). The last two digits is the output register (always 0/d0) and argument count. The actual types of the arguments are given by function prototypes. Maybe I should try to find some library that makes use of the fpu, and study it's .h-files...
|
16 February 2011, 23:55 | #7 |
Registered User
Join Date: Sep 2007
Location: Las Cruces, USA
Age: 71
Posts: 351
|
I dragged out my SASC books and the answer to your original question, 'can you pass arguments to an external lib with the fp registers using libcall', is no. The only way I can see to do that is with flibcall, the fpu registers use two digits per register in the magic number, so the total number of args is half. FP0=10, FP1=11 and so on. It appears but I'm not sure, you can not specify regular registers this way, seems kind of dumb if I'm right because you can't mix register types. They could have as an example used 00 or 01 for d0 and d1.
I don't believe there are any libraries in the OS that use the fpu registers to pass args, the most likely would be the double float math libs. As far as I know they all use the d0/d1 d2/d3 format. I don't personally know of any libraries outside the OS to look at. I hope this anwers your question. Last edited by Ed Cruse; 17 February 2011 at 00:05. |
17 February 2011, 13:58 | #8 | |
Registered User
Join Date: Jan 2002
Location: Germany
Posts: 6,985
|
Quote:
That's probably the reason why there is no way to use fp registers in libraries: AmigaOS was designed to run on machines without FPU but to take advantage of it if one is present. |
|
17 February 2011, 16:34 | #9 | |
Registered User
Join Date: Sep 2007
Location: Las Cruces, USA
Age: 71
Posts: 351
|
Quote:
|
|
17 February 2011, 16:45 | #10 |
Registered User
Join Date: Jan 2002
Location: Germany
Posts: 6,985
|
Certainly the library code itself may and should use the FPU and FPU registers if present. But the API (what is defined by #pragma libcall) may not use FPU registers. The libraries exist so that the application program does not need to care about hardware dependencies. It just calls the library functions using the defined API and runs on any machine, no matter if an FPU is present or not. Therefore the API needs to consist of processor registers only, which are available on machines without FPU, too.
|
17 February 2011, 17:38 | #11 |
tulou
Join Date: Jun 2006
Location: Gothenburg / Sweden
Posts: 88
|
flibcall appears to be the solution to my problem, thanks a lot for looking that up! I can't seem to find that part of the SAS/C documentation anywhere online. Now that I know what to look for however, I found a library called cyberGL, which makes extensive use of FPU arguments
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
|
|