Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.
"Just in time compiling" (by a beginer)
Good evening Sirs!
I use this site for the first time, so please forgive me if i do anything wrong.
I am writing a compiler for the Brainfuck language.
(This project is just for fun (I'm 16 and interested in programming).)
My compiler generates intel bytecode into an array in the memory and than runs the array as if it were a function.
typedef void* (*procedure_t) ();
It sounds strange but it works, i can modify memory with it, and it can return as if it were a normal function.
I have a problem when i call a library function from it.
(And when i call my own function wich calls the library function.)
When i call putchar it writes out the character, but the program signals a SIG_SEGV and terminates.
Is there any special thing i must consider when calling library functions?
I am using mingw gcc 3 and 4.
I think my bytecode is basicaly good because if i call one of my own functions instead of the library function it seems to work great.
With thanks for reading it, and helping:
0 · ·