Tuesday 11 October 2016

Constructing the Machine Codes for 8086 Instructions

- Since there are such a large number of possible codes for the 8086 instructions, it is impractical to list them all in a simple table.

- Instead, we use a template for each basic instruction type and fill in bits within this template to indicate the desired addressing mode, data type, etc.

- In other words we build up the instruction code on a bit by bit basis.


MOV instruction coding format

- At least 2 code bytes are required for the instruction.

- The upper 6 bits of the first byte are an opcode which indicates the general type of instruction.

- The 'W' bit in first word is used to indicate whether a byte of a word is being moved. If byte, make W=0 else if word make W=1.

- In this instruction one operand must always be a register, so 3 bits in the second byte are used to indicate which register is involved.

- The 'D' bit in the first byte of the instruction is used to indicate whether the data is being moved to the register identified in 'REG' field of the second byte or from that register.

- If the instruction is moving data to the register identified in the REG field, make D=1.

- If the instruction is moving data from that register, make D=0.

- The 2-bit field labelled 'MOD' and the 3-bit field labeled 'R/M' in the second byte of the instruction code are used to specify the desired addressing mode for the other operand.