Login
Username:

Password:

Remember me



Lost Password?

Register now!

Sections

Who's Online
94 user(s) are online (65 user(s) are browsing Forums)

Members: 0
Guests: 94

more...

Headlines

 
  Register To Post  

problem with a .library for PPC OS4 called from 68k with float args
Not too shy to talk
Not too shy to talk


See User information
Hello guys

I will explain a problem (bug?) that gave me some headaches:
(Hope it will help someone someday...)

I have maded a Microbe3D.library for PPC OS4
I have also maded stubs for calling this PPC library from a 68k prog
mydemo(68k) --> Microbe3D.library (ppc)

But it wasnt working well : some functions are called with bad args
Looks like a float arg is allways trashed
like this function

void U3D_Unitize(APTR Object,float size)

size is allways bad
The explanation is in the 68k to ppc stub

static void stub_U3D_UnitizePPC(uint32 *regarray)
{
struct Library *Base = (struct Library *) regarray[REG68K_A6/4];
struct ExtendedLibrary *ExtLib = (struct ExtendedLibrary *) ((uint32)Base + Base->lib_PosSize);
struct Microbe3DIFace *Self = (struct Microbe3DIFace *) ExtLib->MainIFace;

Self->U3D_Unitize(
(APTR)regarray[8],
(float)regarray[0]
);
}

d0 is in regarray[0] but ALREADY as a float
So converting again uint32 to float give a false value

here it is my solution:

static void stub_U3D_UnitizePPC(uint32 *regarray)
{
struct Library *Base = (struct Library *) regarray[REG68K_A6/4];
struct ExtendedLibrary *ExtLib = (struct ExtendedLibrary *) ((uint32)Base + Base->lib_PosSize);
struct Microbe3DIFace *Self = (struct Microbe3DIFace *) ExtLib->MainIFace;
float* floatregarray=(float*)regarray;

Self->U3D_Unitize(
(APTR)regarray[8],
floatregarray[0]
);
}

regarray[] still contain uint32 but now is "seen as float" with floatregarray[]

Alain Thellier

Go to top
Re: problem with a .library for PPC OS4 called from 68k with float args
Just can't stay away
Just can't stay away


See User information
Not sure but I thought from m68k.exe calling a PPC_lib was not possible, alas PPC.exe call m68_lib (creating ppc stub) yes.

http://www.os4coding.net/blog/kas1e/h ... d-ppc-stubs-68k-libraries

But nice to see that you manage to solve it.

Go to top
Re: problem with a .library for PPC OS4 called from 68k with float args
Home away from home
Home away from home


See User information
@jabirulo

Quote:
but I thought from m68k.exe calling a PPC_lib was not possible


That's how 68k program run under AmigaOS4, they all call PPC libraries.

The library JMP table is optional, for example if you create a new library you don't need a JMP table as there are 680x0 program using that library, but maybe you want that library to exist as PPC version and 68k version, then you need JMP table, so 680x0 programs can use the powerpc library.

Under AmigaOS4, the JMP table does not point to routines direct, the PPC stubs translate between 68k registers and PowerPC native functions.

Quote:
But nice to see that you manage to solve it.


He has not solved anything, he is asking for help how to handel float values.
most of the 680x0 CPU's do not have a FPU, and so this is a mystery to me as well.

A float number is like

1.2 * 10 exp 3 = 1200
1.2 * 10 exp -3 = 0,0012

a float number can be extremely big or extremely small, but it never precise.


Edited by LiveForIt on 2014/6/20 19:06:36
Edited by LiveForIt on 2014/6/20 19:08:13
(NutsAboutAmiga)

Basilisk II for AmigaOS4
AmigaInputAnywhere
Excalibur
and other tools and apps.
Go to top
Re: problem with a .library for PPC OS4 called from 68k with float args
Just can't stay away
Just can't stay away


See User information
@LiveForIt

You're right, I see now, mixed ppc<->m68k.
So m68k.exe should work ok with those ppc_lib he created, maybe he is missing some kind of 16/32bit allignament.

Better stop talking about things I don't know

Go to top
Re: problem with a .library for PPC OS4 called from 68k with float args
Quite a regular
Quite a regular


See User information
@thellier
If you are passing float values in emulated 68k registers (or plain ints for that matter), you should cast them to float like this:
*(float*)&regarray[0]

This is just like television, only you can see much further.
Go to top
Re: problem with a .library for PPC OS4 called from 68k with float args
Not too shy to talk
Not too shy to talk


See User information
Hello all

>He has not solved anything, he is asking for help how to handel float values.
No no I am not asking for help : the problem is fixed with the method I wrote

Now all the demos(68k) works well with Microbe3D.library(ppc)
But as all ppc demos works too this is not so usefull

>most of the 680x0 CPU's do not have a FPU, and so this is a mystery to me as well.
If the cpu got an FPU then the float registers may be used
(see StormMesa's agl.library that use fp0, fp1, etc ...) but the lib will only works on some cpu (>68020)
If the cpu dont have an FPU then the data registers are used
(like in my microbe.library that use d0,d1,etc....)

>bszili
>*(float*)®array[0]
You are right this is the good & academic syntax but I was too tired to remember this syntax

Alain





Go to top
Re: problem with a .library for PPC OS4 called from 68k with float args
Home away from home
Home away from home


See User information
@thellier

Quote:

>bszili
>*(float*)®array[0]
You are right this is the good & academic syntax but I was too tired to remember this syntax


Really must try to remember that next time I need to pass a float through a taglist! Saves a hour or two of WTF! WTF! why why why? Ah! whilst programming.


Go to top
Re: problem with a .library for PPC OS4 called from 68k with float args
Not too shy to talk
Not too shy to talk


See User information
@broadblues

finally I have used this syntax that looks more clear to me (and it works)
/*======================================================*/
#define ASFLOAT *(float*)&
[...]
static void stub_U3D_UnitizePPC(uint32 *regarray)
{
struct Library *Base = (struct Library *) regarray[REG68K_A6/4];
struct ExtendedLibrary *ExtLib = (struct ExtendedLibrary *) ((uint32)Base + Base->lib_PosSize);
struct Microbe3DIFace *Self = (struct Microbe3DIFace *) ExtLib->MainIFace;

Self->U3D_Unitize(
(APTR)regarray[8],
ASFLOAT regarray[0]
);
}
/*======================================================*/
And so it just need to replace all
(float)regarray[
with
ASFLOAT regarray[

Go to top
Re: problem with a .library for PPC OS4 called from 68k with float args
Home away from home
Home away from home


See User information
@thellier

Looks compressed, but I think you can do better with macros.
Hide the regarray[x] stuff and the init code in all the stub files.

(NutsAboutAmiga)

Basilisk II for AmigaOS4
AmigaInputAnywhere
Excalibur
and other tools and apps.
Go to top

  Register To Post

 




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




Powered by XOOPS 2.0 © 2001-2023 The XOOPS Project