3-12 TRANSLATION OF ASSEMBLER INSTRUCTIONS

The translation from assembler instructions to machine instructions is, in most cases, quite straightforward. All of the 8086 machine instructions consist of 1 or 2 bytes of op code and addressing mode designations with from 0 to 4 bytes of immediate, displacement, or segment address information appended to them.

The number of appended bytes depends on the addressing modes. If the addressing modes call for both an immediate operand and a displacement the displacement will appear first, and if both an offset and a segment address are present, the offset will appear first.

Figure 3-71 Machine code for the 8086/8088 instructions. (Reprinted by permission of Intel Corporation. Copyright 1979.)

AL - 8-bit accumulator
AX - 16-bit accumulator
CX - Count register
DS - Data segment
ES - Extra segment
Above/below refers to unsigned value
Greater = more positive;
Less = less positive (more negative) signed values
if d = 1 then "to" reg; if d = 0 then "from" reg
if w = 1 then word instruction; if w = 0 then byte instruction
if s w = 01 then 16 bits of immediate data form the operand
if s w = 11 then an immediate data byte is sign extended to form the 16-bit operand
if v = 0 then "count" = 1 if v = 1 then "count" in (CL)
x = don't care
z is used for string primitives for comparison with ZF FLAG
SEGMENT OVERRIDE PREFIX
  
if mod = 11 then r/m is treated as a REG field
if mod = 00 then DISP = 0* disp-low and disp-high are absent
if mod = 01 then DISP = disp-low sign-extended to 16-bits, disp-high is absent
if mod = 10 then DISP = 0 disp-high disp-low
if r/m = 000 then EA = (BX) + (SI) + DISP
if r/m = 001 then EA = (BX) + (DI) + DISP
if r/m = 010 then EA = (BP) + (SI) + DISP
if r/m = 011 then EA = (BP) + (DI) + DISP
if r/m = 100 then EA = (SI) + DISP
if r/m = 101 then EA = (DI) + DISP
if r/m = 110 then EA = (BP) + DISP
if r/m = 111 then EA = (BX) + DISP
DISP follows 2nd byte of instruction (before data if required)

*except if mod = 00 and r/m = 110 then EA = disp-high disp-low
REG is assigned according to the following table
16-Bit (w 1)8-Bit (w 0)Segment
000 AX000 AL00 ES
001 CX001 CL01 CS
010 DX010 DL10 SS
011 BX011 BL11 DS
100 SP100 AH
101 BP101 CH
110 SI110 DH
111 DI111 BH

Instructions which reference the flag register-file as a 16-bit object use the symbol FLAGS to represent the file

FLAGS X X X X (OF) (DF) (IF) (TF) (SF) (ZF) X (AF) X (PF) X (CF)
8086/8088 Instruction Encoding
DATA TRANSFER
MOV = Move:
7 6 5 4 3 2 1 0
7 6 5 4 3 2 1 0
7 6 5 4 3 2 1 0
7 6 5 4 3 2 1 0
7 6 5 4 3 2 1 0
7 6 5 4 3 2 1 0
Register/memory to/from register
1 0 0 0 1 0 d w
 mod   reg  r/m
(DISP-LO)
(DISP-HI)
Immediate to register/memory
1 1 0 0 0 1 1 w
 mod  0 0 0 r/m
(DISP-LO)
(DISP-HI)
data
data if w=1
Immediate to register
1 0 1 1 w  reg 
data
data if w=1
Memory to accumulator
1 0 1 0 0 0 0 w
addr-lo
addr-hi
Accumulator to memory
1 0 1 0 0 0 1 w
addr-lo
addr-hi
Register/memory to segment register
1 0 0 0 1 1 1 0
 mod  0  SR r/m
(DISP-LO)
(DISP-HI)
Segment register to register/memory
1 0 0 0 1 1 0 0
 mod  0  SR r/m
(DISP-LO)
(DISP-HI)
PUSH = Push:
Register/memory
1 1 1 1 1 1 1 1
 mod  1 1 0 r/m
(DISP-LO)
(DISP-HI)
Register
0 1 0 1 0  reg 
Segment register
0 0 0 reg 1 1 0
POP = Pop:
Register/memory
1 0 0 0 1 1 1 1
 mod  0 0 0 r/m
(DISP-LO)
(DISP-HI)
Register
0 1 0 1 1  reg 
Segment register
0 0 0 reg 1 1 1

Table of Contents | Next page | Previous page

This is page 55.