Assembly Interpreter/Embedding C

Darrell news at dorb.com
Tue Oct 19 22:05:56 EDT 1999


I wouldn't try to do this in your own process space.
If it were me I'd create a simple process that can load a file
and execute it. Then you can use off the self debuggers
and isolate the GP faults from your main Python application.

Extra benefit will come from seeing that the debugger sees
the same code you think your writing.

Untested code:

#include <stdio.h>
void Goto(char *fn)
{
 const size_t BufSize=10000;
 FILE *fp=fopen(fn,"rb");
 char *buf=new char[BufSize];
 fread(buf,BufSize,sizeof(char), fp);
 typedef void (*FuncPtr)(void);
 FuncPtr functionPtr=(FuncPtr) buf;
 functionPtr();
}


--
--Darrell
Jeff Shipman - UC <jeff at nmt.edu> wrote in message
news:380B8EB5.B03BB07A at nmt.edu...
> I am building an interactive Intel Assembly interpreter using Python. I
> am now needing to add the part where my binary code is taken, loaded
> into memory and executed. I've heard the only way of doing this is to
> use C (how, I'm not quite sure yet *grin*). I am having trouble making
> up a module in Python. I've looked at the example in the handbooks I've
> found and they don't seem to work for me.  Could someone show me a
> working example and tell me what include files, etc I would need for it
> to compile correctly.
>
> If anybody knows of a better way to take binary code and execute it,
> then please feel free to tell me! =)
>
> --
> Jeff Shipman
>
> shippy at cs.nmt.edu
>
>
>
>
> --
> http://www.python.org/mailman/listinfo/python-list






More information about the Python-list mailing list