
Instruction Set
4-29
CLD
Clear Direction Flag
CLD
What It Does
CLD clears the Direction Flag (DF) to 0, causing subsequent repeated
string instructions
to process the components of a string from a lower address to a higher address.
Syntax
Description
CLD clears DF, causing subsequent string operations to increment the index registers on
which they operate: SI and/or DI.
Operation It Performs
Flag Settings After Instruction
Examples
This example fills a string in memory with a character. Because the Direction Flag (DF) is
cleared to 0 using CLD, the bytes are filled, one by one, from first to last.
Form
Opcode
Description
Clocks
Am186 Am188
CLD
FC
Clear Direction Flag so the Source Index (SI) and/or the
Destination Index (DI) registers will increment during
string instructions
2
2
CLD
/* process string components from lower to higher addresses */
DF = 0;
15
14
13
12
11
10
9
8
7
6
5
4
3
2
1
0
Processor Status
Flags Register
reserved
OF DF
IF TF SF ZF
AF
PF
CF
? = undefined; – = unchanged
–
0
–
–
–
– res – res – res –
STRING
DB
128 DUP (?)
POUND
DB
’#’
; 2Ah
; fill string with character
; set up registers and flags
MOV AX,SEG
STRING
MOV ES,AX
MOV
AL,POUND
; copy character to AL
LEA
DI,STRING
; load offset (segment = ES)
MOV
CX,LENGTH STRING
; set up counter
CLD
; process string going forward
; fill string
REP
STOSB
Содержание Am186 Series
Страница 1: ...Am186 and Am188 Family Instruction Set Manual February 1997...
Страница 10: ...Table of Contents x...
Страница 18: ...Programming 1 8...
Страница 40: ...Instruction Set Listing 3 14...