It wokrs here!

I used this example posted here a looong time ago by jesse:
__attribute__((packed)) struct TIteration3Dext {
double Cw,Rold,RStopD,x,y,z,w; // use with neg indizes before C1. w is also used for 3d ifs and abox analytic DE
double Px, Py, Pz; // actual position, never change these! Can be used as input.
double Cx, Cy, Cz; //+24 these are the constants for adding. Pxyz or the julia seed. Cw is @-56 (begin of struct)
void* PVar; //+48 the actual formulas adress of constants and vars, constants at offset 0 increasing, user vars below -8
float SmoothItD; //+52
double Rout; //+56 the square of the vector length, can be used as input
int ItResultI; //+64
int maxIt; //+68
float RStop; //+72
int nHybrid[6]; //+76 all formulas iteration counts or single weights in interpol-hybrid
void* fHPVar[6]; //+100 all formulas pointer to constants+vars, PVars-8=0.5, use PVar for the actual formula
void* fHybrid[6]; //+124 the formulas adresses
int CalcSIT; //+148
int DoJulia; //+152
float LNRStop; //+156
int DEoption; //+160
float fHln[6]; //+164 for SmoothIts
int iRepeatFrom; //+188
double OTrap; //+192
double VaryScale; //+200 to use in vary by its
int bFirstIt; //+208 used also as iteration count, is set to 0 on it-start
int bTmp; //+212 tmpBuf, free of use.
double Dfree1; //+216
double Dfree2; //+224
double Deriv1; //+232 for 4D first deriv or as full derivs
double Deriv2; //+240
double Deriv3; //+248
float SMatrix4[4][4]; //+256 for 4d rotation, used like most other values only by the programs iteration loop procedure
};
// fastcall is not quite delphi fastcall.
// first two args are ok, third is in ecx in delphi, on stack here.
void __attribute__((fastcall)) formula(
double* x, // [eax]
double* y, // [edx]
double* arg, // [ebp+8], points to TIteration3Dext.C1
void* dummy // so we end w/ ret 8 as delphi expects
) {
// Compute ptr to proper start of TIteration3Dext struct.
struct TIteration3Dext* cfg = (struct TIteration3Dext*)(arg-7);
// Read / write some fields as demonstration.. not a real formula ;-)
double r = cfg->x + cfg->y - cfg->z * cfg->w;
cfg->Deriv1 = r;
}
compile with 'gcc -c -Os -m32'.
Objdump -D can be used to show the generated code.
Transformed it a little:
#include <math.h>
__attribute__((packed)) struct TIteration3Dext {
double Cw,Rold,RStopD,x,y,z,w; // use with neg indizes before C1. w is also used for 3d ifs and abox analytic DE
double Px, Py, Pz; // actual position, never change these! Can be used as input.
double Cx, Cy, Cz; //+24 these are the constants for adding. Pxyz or the julia seed. Cw is @-56 (begin of struct)
void* PVar; //+48 the actual formulas adress of constants and vars, constants at offset 0 increasing, user vars below -8
float SmoothItD; //+52
double Rout; //+56 the square of the vector length, can be used as input
int ItResultI; //+64
int maxIt; //+68
float RStop; //+72
int nHybrid[6]; //+76 all formulas iteration counts or single weights in interpol-hybrid
void* fHPVar[6]; //+100 all formulas pointer to constants+vars, PVars-8=0.5, use PVar for the actual formula
void* fHybrid[6]; //+124 the formulas adresses
int CalcSIT; //+148
int DoJulia; //+152
float LNRStop; //+156
int DEoption; //+160
float fHln[6]; //+164 for SmoothIts
int iRepeatFrom; //+188
double OTrap; //+192
double VaryScale; //+200 to use in vary by its
int bFirstIt; //+208 used also as iteration count, is set to 0 on it-start
int bTmp; //+212 tmpBuf, free of use.
double Dfree1; //+216
double Dfree2; //+224
double Deriv1; //+232 for 4D first deriv or as full derivs
double Deriv2; //+240
double Deriv3; //+248
float SMatrix4[4][4]; //+256 for 4d rotation, used like most other values only by the programs iteration loop procedure
};
// fastcall is not quite delphi fastcall.
// first two args are ok, third is in ecx in delphi, on stack here.
void __attribute__((fastcall)) formula(
double* x, // [eax]
double* y, // [edx]
double* arg, // [ebp+8], points to TIteration3Dext.C1
void* dummy // so we end w/ ret 8 as delphi expects
) {
// Compute ptr to proper start of TIteration3Dext struct.
struct TIteration3Dext* cfg = (struct TIteration3Dext*)(arg-7);
// Read / write some fields as demonstration.. not a real formula ;-)
cfg->x=fabs(cfg->x);
cfg->y=fabs(cfg->y);
cfg->z=fabs(cfg->z);
}
Compiled it using gcc:
gcc -c -O3 -msse2 MB3D-formula-ex.c
Then used objdump:
objdump -D MB3D-formula-ex.o >> out.asm
out.asm looks like this:
MB3D-formula-ex.o: file format pe-i386
Disassembly of section .text:
00000000 <@formula@16>:
0: 55 push %ebp
1: 89 e5 mov %esp,%ebp
3: 8b 45 08 mov 0x8(%ebp),%eax
6: 83 e8 38 sub $0x38,%eax
9: dd 40 18 fldl 0x18(%eax)
c: d9 e1 fabs
e: dd 58 18 fstpl 0x18(%eax)
11: dd 40 20 fldl 0x20(%eax)
14: d9 e1 fabs
16: dd 58 20 fstpl 0x20(%eax)
19: dd 40 28 fldl 0x28(%eax)
1c: d9 e1 fabs
1e: dd 58 28 fstpl 0x28(%eax)
21: c9 leave
22: c2 08 00 ret $0x8
25: 90 nop
26: 90 nop
27: 90 nop
Notice how it doesn't call any external function. I wanted it to use SSE2 but it used FPU don't know why because I'm a noob.
keeping only the machine code and adding MB3D formula stuff gives this:
[OPTIONS]
.Version = 2
.DEoption = -1
[CODE]
5589e58b450883e838dd4018d9e1dd5818dd4020d9e1dd5820dd4028d9e1dd5828c9c20800
[END]
Description:
Test of compiling a formula with GCC.
It simply set (x,y,z)=abs(x,y,z)
saved as gccAbsxyz.m3f and it works!

So it is definitely possible to automate it: formula.c --> formula.m3f. Of course there are a lot of details that must be taken into account. (What DEoption means for example?)
[/code]