Chapter Four
Chapter Four
Chapter Four
Instruction Format
Instruction Format
To convert an assembly language program to machine code, we must convert
each assembly language instruction to its equivalent machine code instruction.
In general, for an instruction, the machine code specifies things like :
What operation is to be performed
What operand or operands are to be used
Whether the operation is performed on byte or word data
Whether the operation involves operands that are located in registers or
storage location in memory
If one of the operands is in memory, how its address is to be generated
Cont…..
The 2- bit MOD field and 3-bit R/M field together specify the second operand.
Encoding for these fields are shown in Fig (c) and (d), respectively.
MOD indicates whether the operand is in a register or memory.
Notice that in the case of a second operand that is in a register, the MOD field is always
11.
The R/M field along with the W bit from byte 1 selects the register.
For a second operand that is located in memory, there are a number of different ways its
location can be specified. That is, any of the addressing modes supported by the 8086
microprocessor can be used to generate its address.
The addressing mode is also selected with the MOD and R/M fields.
Here we find that the 16-bit register AX and the 8 bit register AL are specified by the
same binary code.
Notice that the decision whether to use AX or AL is made based on the setting of the
operation size (W) bit in byte 1.
The 2- bit MOD field and 3-bit R/M field together specify the second operand.
Encoding for these fields are shown in the tables below
MOD indicates whether the operand is in a register or memory.
Notice that in the case of a second operand that is in a register, the MOD field is always
11.
The R/M field along with the W bit from byte 1 selects the register.
For a second operand that is located in memory, there are a number of different ways its
location can be specified. That is, any of the addressing modes supported by the 8086
microprocessor can be used to generate its address.
The addressing mode is also selected with the MOD and R/M fields.
Notice that the addressing mode for an operand in memory is indicated by one of
the other three values (00, 01, and 10) in the MOD field and an appropriate R/M
code.
The different ways in which the operand’s address can be generated are shown in
the effective address calculation part of the table
CODE Explanation
00 Memory Mode, no displacement follows*
01 Memory Mode, 8 –bit displacement follows
10 Memory Mode, 16-bit displacement follows
11 Register Mode ( no displacement)
1 0 1 1 1 0 1 0
•1
•0In Instruction Register
•1
•1
•1
•0
•1
•0