Address
Address
Address
Addressing Modes
When the 8088 executes an instruction, it performs the specified function on data These data, called operands,
May be a part of the instruction May reside in one of the internal registers of the microprocessor May be stored at an address in memory
AL=?
BEED
DS (Shifted Left) + SI = 13698. With little endian convention: Low address 13698 High Address 13699 FE 17
] + 1234h
BX AX
3AH
DS
1234
Example: What is the physical address MOV [DI-8],BL if DS=200 & DI=30h ? DS:200 shift left once 2000 + DI + -8 = 2028
PA=
CS SS DS ES
BX SI : BP + DI +
MOV BX, 0600h MOV SI, 0010h ; 4 records, 4 elements each. MOV AL, [BX + SI + 3]
OR
MOV BX, 0600h MOV AX, 004h ; MOV CX,04; MUL CX MOV SI, AX MOV AL, [BX + SI + 3]
9
10
Default Segment
Alternate Segment
none none CS,ES,SS CS,ES,SS None
Offset
Instruction Fetch CS Stack Operations General Data String Source String Destination
Brey
SS DS DS ES
Segment override
Instruction Examples Override Segment Used Default Segment
MOV AX,CS:[BP]
CS:BP
SS:BP
MOV DX,SS:[SI]
SS:SI
DS:SI
MOV AX,DS:[BP]
DS:BP
SS:BP
MOV CX,ES:[BX]+12
ES:BX+12
DS:BX+12
MOV SS:[BX][DI]+32,AX
SS:BX+DI+32
DS:BX+DI+32
12
a) BP
Show the contents of the related memory locations after the execution of this instruction MOV [BP][SI]+10,DX if DS=2000, SS=3000,CS=1000,SI=4000,BP=7000,DX=1299 (all hex)
SS(0)=30000 30000+4000+7000+10=3B010
13
Assembly Language
There is a one-to-one relationship between assembly and machine language instructions What is found is that a compiled machine code implementation of a program written in a high-level language results in inefficient code
More machine language instructions than an assembled version of an equivalent handwritten assembly language program
14
Assembly language: perform real-time operations High-level languages: Those operations mostly not critical in time.
15
An instruction can be coded with 1 to 6 bytes Byte 1 contains three kinds of information:
Opcode field (6 bits) specifies the operation such as add, subtract, or move Register Direction Bit (D bit)
Tells the register operand in REG field in byte 2 is source or destination operand
1:Data flow to the REG field from R/M 0: Data flow from the REG field to the R/M
Continued
REG field is used to identify the register for the first operand REG
000 001 010 011 100 101 110 111
W=0
AL CL DL BL AH CH DH BH
W=1
AX CX DX BX SP BP SI DI
17
Continued
2-bit MOD field and 3-bit R/M field together specify the second operand
18
Examples
MOV BL,AL Opcode for MOV = 100010 Well encode AL so
D = 0 (AL source operand)
W bit = 0 (8-bits) MOD = 11 (register mode) REG = 000 (code for AL) R/M = 011 OPCODE D W MOD REG R/M
100010
11
000
011
MOV BL,AL => 10001000 11000011 = 88 C3h ADD AX,[SI] => 00000011 00000100 = 03 04 h ADD [BX][DI] + 1234h, AX => 00000001 10000001 __ __ h => 01 81 34 12 h
19
Software
The sequence of commands used to tell a microcomputer what to do is called a program Each command in a program is called an instruction 8088 understands and performs operations for 117 basic instructions The native language of the IBM PC is the machine language of the 8088 A program written in machine code is referred to as machine code In 8088 assembly language, each of the operations is described by alphanumeric symbols instead of just 0s or 1s.
Destination operand
20
21
22
23
Example
Copy the contents of a block of memory (16 bytes) starting at location 20100h to another block of memory starting at 20120h MOV AX,2000 MOV DS,AX MOV SI, 100 MOV DI, 120 MOV CX, 10 MOV AH, [SI] MOV [DI], AH INC SI INC DI DEC CX JNZ NXTPT
100-10f
NXTPT:
120-12f
24