English Amiga Board


Go Back   English Amiga Board > Coders > Coders. General

 
 
Thread Tools
Old 14 February 2011, 20:04   #1
dalton
tulou
 
dalton's Avatar
 
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.
dalton is offline  
Old 15 February 2011, 17:33   #2
Ed Cruse
Registered User
 
Join Date: Sep 2007
Location: Las Cruces, USA
Age: 71
Posts: 351
Quote:
Originally Posted by dalton View Post
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.

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.
Ed Cruse is offline  
Old 16 February 2011, 11:51   #3
dalton
tulou
 
dalton's Avatar
 
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) ?
dalton is offline  
Old 16 February 2011, 18:21   #4
Ed Cruse
Registered User
 
Join Date: Sep 2007
Location: Las Cruces, USA
Age: 71
Posts: 351
Quote:
Originally Posted by dalton View Post
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) ?
Now I understand your question. I don't believe so, regcall is for calling function from a link library. I think if you go and look at the Amiga includes you can see how libcall is used to call system functions. It should be the same thing as calling a non system .library, in both cases a6 has to set to the lib pointer which I think libcall takes care of.

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.
Ed Cruse is offline  
Old 16 February 2011, 20:33   #5
Ed Cruse
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.
Ed Cruse is offline  
Old 16 February 2011, 20:55   #6
dalton
tulou
 
dalton's Avatar
 
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...
dalton is offline  
Old 16 February 2011, 23:55   #7
Ed Cruse
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.
Ed Cruse is offline  
Old 17 February 2011, 13:58   #8
thomas
Registered User
 
thomas's Avatar
 
Join Date: Jan 2002
Location: Germany
Posts: 6,985
Quote:
the most likely would be the double float math libs
The math libs cannot use fp registers because they where designed to abstract the hardware from the software, i.e. they need to run also on machines without an FPU.

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.
thomas is offline  
Old 17 February 2011, 16:34   #9
Ed Cruse
Registered User
 
Join Date: Sep 2007
Location: Las Cruces, USA
Age: 71
Posts: 351
Quote:
Originally Posted by thomas View Post
The math libs cannot use fp registers because they where designed to abstract the hardware from the software, i.e. they need to run also on machines without an FPU.

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.
Maybe I'm just misunderstanding your message, but the math libs work nicely on machines with an fpu, they take advantage of the fpu if present and are considerably faster, however not as fast as inline fpu code.
Ed Cruse is offline  
Old 17 February 2011, 16:45   #10
thomas
Registered User
 
thomas's Avatar
 
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.
thomas is offline  
Old 17 February 2011, 17:38   #11
dalton
tulou
 
dalton's Avatar
 
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
dalton is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

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 06:59.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.40867 seconds with 12 queries