const unsigned char machinecode[]={
/* your comma-separated bytes of x86 machine code here! */
};
int foo(void) {
return ((int (*)())machinecode)();
}
(Try this in NetRun now!)
If
you don't remember much x86 assembly (or never knew much!), you can
learn a lot by writing some simple C or C++ code and watching the
disassembly. In particular, "register int x=3;" should nearly do
the right thing as long as optimization is off. Keep in mind that
most disassembly already includes the machine code (on the left) as
well as the assembler instructions (on the right).