Beruflich Dokumente
Kultur Dokumente
Qi Cheng
Chapters 3: Overview
Memory/IO addressing details focus on locations of two operands Instruction addressing Stack addressing
Note that MOV DS,1000H is an illegal instruction (not defined). initializing segment register: MOV MOV AX,1000H DS,AX
Example: What is the function of MOV CX,7? Sol: CX=16bit, then 7=0007H,
(2)
Register addressing
Example: If AX=1000H, BL=80H, what is the result of MOV AL,BL? Sol: BLAL, result is AX=1080H.
Example: MOV [7000H],AX ? If DS=1000H. Sol: copy 16-bit number in AX 2 memory locations DS:7000H, DS:7001H but where? Physical address=10000H+7000H=17000H. Result: copy AL to 17000H and AH to 17001H.
Example: Assume that SI=2000H, DS=0800H. MOV DL,[SI] ? Sol: copy 8-bit number in a memory location DL but where? Physical address = 08000 H+2000H = 0A000H. Result: copy the number in 0A000H to DL Machine code: 8A 14 (2 bytes) MOV MOV DL, ES:[SI] ? ES:[DI],AL ? 10
Example: MOV AX,[BX+4] ? if DS=0100H, BX=0600H. Sol: copy 16-bit number in 2 memory locations AX but where? Physical address=01000H+0600H+0004H=01604H Result: copy the number in 01604H to AL the number in 01605H to AH Machine code: 8B 47 04 (3 bytes)
11
Example: MOV AX,[BP+4] ? if SS=0200H, BP=0100H. Sol: copy 16-bit number in 2 memory locations AX SS:0104H, SS:0105H but where? Physical address=02000H+0100H+00004H=02104H Result: copy the number in 02104H to AL the number in 02105H to AH
Machine code:
12
AX, ES:[3000H] ( AX 16-bit number in ES:3000H, ES:3001H) AX, SS:[3000H] ( AX 16-bit number in SS:3000H, SS:3001H) AX, CS:[3000H] ( AX 16-bit number in CS:3000H, CS:3001H)
13
14
15
(9) Based indexed with displacement addressing (left as exercise) (10) String addressing MOVSB move a string one byte
before
SI DI DS ES 8760H 7860H
after
8761H 7861H
16
17
80x86
MOV IN OUT
18
PUSH, POP
19
20
21
22
23
Default Segment Base Alternate Segment Base CS SS DS DS ES SS DS None None CS, ES, SS CS, ES, SS None CS, DS, ES CS, ES, SS
Instruction Fetch/Program transfer Stack Operation Data Transfer (except following) - String Source - String Destination - BP used as Base Register - BX Used as Base Register
Default Segment Base Alternate Segment Base DS DS DS CS, ES, SS CS, ES, SS CS, ES, SS
24
Chapter 3: Summary
1 Addressing modes
25