Properly writing a hexadecimal value to an address in x86 machine language

185 views Asked by At

I'm trying to learn how to write x86 machine code as hexadecimal (as part of putting text to the monitor on a qemu cold start.) My guess from reading a few sites was that the proper instruction to write 0x78073807 to 0xB8000 should be something along the lines of C7 00 80 0B 00 07 38 07 78 00 00 00 00 00 00 00. However, when putting this into a disassembler, the information it returns appears to indicate that this syntax is wrong. What am I missing here? Thank You!

1

There are 1 answers

0
Sep Roland On

The code is missing the modr/m byte between the opcode C7 and the displacement and immediate.

mov dword [0x000B8000], 0x78073807

C7, 05, 00, 80, 0B, 00, 07, 38, 07, 78