x86 Assembly

Moderators: None (Apply to moderate this forum)
Number of threads: 4563
Number of posts: 16029

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
"Just in time compiling" (by a beginer) Posted by kennysp2 on 13 Aug 2009 at 11:33 AM
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) ();
((procedure_t)arrayName)();

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:

Danyluk Tamas

Report
Re: "Just in time compiling" (by a beginer) Posted by kennysp2 on 15 Aug 2009 at 3:36 AM
Sorry I forgot the number 1 rule:

A function will destroy all values in your registers.

I think it is solved now.



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.