Tuto 3
Tuto 3
Janice Law
SHB 729
Outline
Recap: Flag Registers
Programming Model
Data Addressing Mode
Assembly Language & Instruction Set (I)
REP, REPZ, REPNZ
CMPS, SCAS
LOOPING
Summary
45E9h + 546Ah
General Registers
General use (like variables)
Special purpose
AX: stores the result of arithmetic and logic
instructions
BX: stores the base (offset) address in XLAT
instruction
CX: stores the loop count for instruction
Assume
ES=6000h, CS=4000h, SS=7000h, DS=5000h,
IP=43E8h, SP=0000h, BP=9468h, SI=4C00h,
DI=7D00h, AX=4235h, BX=075Ah, CX=0004h,
DX=3302h.
What is the next instruction’s physical address?
What is the physical address of the top of the stack?
Show the result of MOV ES:[BP], AH. Give the physical
address if a memory is affected.
Example
MOV AX, 0h
MOV BX, 1h
MOV CX, 0h
REP ADD AX, BX
What is the value of AX and BX?
LOOPING
JNZ : Conditional jump, jump not zero; if Z=0
Example
MOV CX, 0Ah
MOV AX, 5h
LOOOP: DEC CX, 1h
AND AX, CX
JNZ LOOOP
What are the values of AX and CX?
LOOPING
LOOPNZ : Jump if both CX and Z are nonzero
Example
MOV CX, 0Ah
MOV AX, 5h
LOOOP: AND AX, CX
LOOPNZ LOOOP
What are the values of AX and CX?