1. question about how to add a machine_func to eu ver. 3.11

I have added a machine_func to ver. 3.11 
 
The actual function resides in execute.e 
and has all the necessary constants in the normal places machine.e, etc.  
 
The function returns an ATOM. 
-- 
global function foo(sequence a, sequence b) 
-- runs some code here 
return my_atom 
end function 
-- 
If I translate the code using ( ec.exe -wat eu.ex ) and run the translated 
interpreter the machine_func works fine with no problems.  
-- 
Then I COMPILE the code after editing be_machine.c and I get this error: 
 
---------------------------------------------------------------- 
compiling the back-end files... 
linking all the files... 
Error! E2028: foo_ is an undefined reference 
file be_machine.obj(C:\1000\SOURCE\be_machine.c): undefined symbol foo_ 
---------------------------------------------------------------- 
 
It appears that I am not decorating the function properly. 
How do I indicate to the compiler that the c code is calling 
a euphoria function in execute.e ? 
 

new topic     » topic index » view message » categorize

2. Re: question about how to add a machine_func to eu ver. 3.11

BRyan said...

compiling the back-end files... 
linking all the files... 
Error! E2028: foo_ is an undefined reference 
file be_machine.obj(C:\1000\SOURCE\be_machine.c): undefined symbol foo_ 

It appears that I am not decorating the function properly. How do I indicate to the compiler that the c code is calling a euphoria function in execute.e ?

Yes, this is somewhat tricky. Basically, you need to call it as a callback. I think that the easiest way to do this is probably to add another machine function that takes the address of your function as a callback. Then you can store that in a function pointer in be_machine.c, and call the callback when that machine func is invoked.

Matt

new topic     » goto parent     » topic index » view message » categorize

3. Re: question about how to add a machine_func to eu ver. 3.11

Thanks Matt
Bernie

new topic     » goto parent     » topic index » view message » categorize

4. Re: question about how to add a machine_func to eu ver. 3.11

mattlewis said...

Yes, this is somewhat tricky. Basically, you need to call it as a callback. I think that the easiest way to do this is probably to add another machine function that takes the address of your function as a callback. Then you can store that in a function pointer in be_machine.c, and call the callback when that machine func is invoked.

Matt

Matt: 
 
I can not use a callback because it will not work in DOS 
 
I would like to use this code in be_machine.c : 
 
            case M_CALL_FOO: 
                return call_func(foo_id, {x}); 
                break; 
 
Can you please show me how I can do this in "C" or assembler in be_machine.c 
 
I need to accomplish this to be able to build the 3.11 binaries.  
 

new topic     » goto parent     » topic index » view message » categorize

5. Re: question about how to add a machine_func to eu ver. 3.11

BRyan said...

I can not use a callback because it will not work in DOS

I would like to use this code in be_machine.c :

case M_CALL_FOO: return call_func(foo_id, {x}); break;

Can you please show me how I can do this in "C" or assembler in be_machine.c

This already works in 4.0, where we pass routine ids around and call them from the C backend, but it is complicated.

BRyan said...

I need to accomplish this to be able to build the 3.11 binaries.

Uh, what? Since when? Huh?

... 
... 
... 

...Why?

new topic     » goto parent     » topic index » view message » categorize

6. Re: question about how to add a machine_func to eu ver. 3.11

Jim: Because 4.0 has become to complicated, overloaded with features and don't support dos.
I want to build my own less complicated version of 3.11

new topic     » goto parent     » topic index » view message » categorize

7. Re: question about how to add a machine_func to eu ver. 3.11

BRyan said...

Jim: I want to build my own less complicated version of 3.11

You want to make 3.11 less complicated .. by adding a new machine_func() that's implemented via Euphorian routine ids?

Why do you want to add a new machine_func() to 3.11? What are you trying to do with it?

new topic     » goto parent     » topic index » view message » categorize

8. Re: question about how to add a machine_func to eu ver. 3.11

I mean a version of 3.11 that can use DOS on XP

new topic     » goto parent     » topic index » view message » categorize

9. Re: question about how to add a machine_func to eu ver. 3.11

BRyan said...

I mean a version of 3.11 that can use DOS on XP

1. Why do you need to build this yourself?

2. Why do you need to add a machine_func() to do this?

3. Why do you want to do it by calling an Euphorian routine id from the C based backe end?

new topic     » goto parent     » topic index » view message » categorize

10. Re: question about how to add a machine_func to eu ver. 3.11

jimcbrown said...
BRyan said...

I mean a version of 3.11 that can use DOS on XP

1. Why do you need to build this yourself?

2. Why do you need to add a machine_func() to do this?

3. Why do you want to do it by calling an Euphorian routine id from the C based backe end?

I have all my code working using a translated version of EU.EX .
I now want to build binaries using my source ( using BUILD.BAT ) to create the
the binaries that will then contain my NEW FEATURES.
If I don't do that a user can not translate a program that contains my features.

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu