Assume i'm trying to emit IMUL
into memory using this function:
void emit(unsigned char byte)
{
instruction_start[offset++] = byte;
}
IMUL
has this format: 0F AF /r
. If I emit 1 byte at a time, should I consider the endianness and reverse the bytes? meaning should I emit /r
first then OF AF
?
I am currently not reversing the bytes and emitting 1 byte as is and it's working, but not sure how.
Edit: It seems like instructions are treated as Strings, they area read 1 byte at a time and maintain their documented order, unless there are immediate values within them: https://stackoverflow.com/a/60905404