From: Cyrill G. <gor...@gm...> - 2011-07-19 22:07:50
|
On Tue, Jul 19, 2011 at 11:57:34PM +0000, Mahmoud Jaoune wrote: > I have changed the #define EMIT_REX() in assemble.c file to a real > function, I have used 2 ways, and one of them is a comment beneath > the first one. You may have to change anything that depends on > normal defining. > EMIT_REX() takes no parameters. > > Please support me by changing any mistakes I have done ;). > > We really have to find a name for the 64 bytes (case 64; return "";) > thing :P > > I like sending the whole source file without using patches or > merging or anything similar, is that OK? > > Best, > Mahmoud Jaoune Mahmoud, even if you're sending the whole assemble.c instead of patch (or whatever) it must be compilable at least. The essential snippeted which has been changed is /*EMIT_REX takes no parameters*/ void EMIT_REX(){ /*If this doesn't work try another type or leave it as a define*/ if (!(ins->rex & (REX_D|REX_V)) && (ins->rex & REX_REAL) && (bits == 64)) { ins->rex = (ins->rex & REX_REAL)|REX_P; out(offset, segment, &ins->rex, OUT_RAWDATA, 1, NO_SEG, NO_SEG); ins->rex = 0; offset += 1; } } /*Or we could use but doesn't differ much static void EMIT_REX(){ If this doesn't work try another type or leave it as a define if (!(ins->rex & (REX_D|REX_V)) && (ins->rex & REX_REAL) && (bits == 64)) { ins->rex = (ins->rex & REX_REAL)|REX_P; out(offset, segment, &ins->rex, OUT_RAWDATA, 1, NO_SEG, NO_SEG); ins->rex = 0; offset += 1; } } */ Note while being macro it touchs local vars now it tries to access globals, this is not good at all. It should be something like static void emit_rex(insn *ins, int bits, int32_t segment, int64_t *offset) { if (!(ins->rex & (REX_D|REX_V)) && (ins->rex & REX_REAL) && (bits == 64)) { ins->rex = (ins->rex & REX_REAL) | REX_P; out(*offset, segment, &ins->rex, OUT_RAWDATA, 1, NO_SEG, NO_SEG); ins->rex = 0; *offset += 1; } } and probably with 'if' test even more simplified. The idea is to make code simplier and escape macros if they work like a functions (which allow us to catch problems in a type of arguments passed). I think so ;) Cyrill |