![opcode 0xed opcode 0xed](https://i0.wp.com/apollo89.com/wordpress/wp-content/uploads/2014/01/5-1-30.png)
Lets rewrite table 2 with our known opcodes. this effectively decrements rcx register by one and jumps to the specified offset if the register is non-zero
![opcode 0xed opcode 0xed](https://miro.medium.com/max/1280/1*TegypYrgwtG0oRN3Qyz_HQ.png)
These are variants of the mov instruction.For us, this means that we prefix the register with the an r character (eg. An instruction starts with 48 to indicate that the operands are 64-bit wide.Here are a few things to take away from this table that will help us decode our program:
![opcode 0xed opcode 0xed](https://img2020.cnblogs.com/blog/1379525/202010/1379525-20201012155420054-265439530.png)
We can use the reference table from X86 Opcode and Instruction Reference to decode this machine code. It’s a non-trivial process to find the separation point between two instructions but the general idea is that a single instruction ends once it is fully described and any byte after that belongs to the next instruction. Some of them (such as the first one) are 3 bytes long whereas some (such as the second one) are 4 bytes long. Notice that the instructions are not fixed width.
#Opcode 0xed code#
To better understand the machine code above, lets separate the opcodes from the operands. The add is the verb and the x and y are the nouns or subjects.įor a computer, the verb is called an opcode and the noun is called an operand. For example, suppose you tell someone to add variables x and y. If you give someone an instruction to do something, the instruction itself includes a verb and one or more noun. First lets define what an instruction is to people and then what it is to a computer. I thought it would a nice educational experience to break this apart so we can understand it better. In that post, I also included the machine code of a very small program that reads a line of text and prints it out in upper case. In a previous post, I gave a brief explanation about a computer program.