Instruction Set
4-151
LOOPNE
LOOPNE
Flag Settings After Instruction
Examples
This example searches a list of characters stored in memory for a null character. If the list
contains a null character, the microcontroller sets the Carry Flag (CF) to 1; otherwise, it
sets CF to 0.
Related Instructions
If you want to
See
Jump to another sequence of instructions if CX is 0
JCXZ
Jump unconditionally to another sequence of instructions
JMP
Jump to the top of a loop if CX is not 0
LOOP
Jump to the top of a loop if CX is not 0 and two compared components are equal LOOPE
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
–
–
–
–
–
– res – res – res –
CHARS
DB
128 DUP (?)
NULL
DB
0
; search a list for a null character
; initialize and use list
...
; set up registers
MOV
SI,-1
; set up list index
MOV
CX,LENGTH CHARS
; set up counter
SEARCH:
INC
SI
; point to byte in list (INC before
; CMP to avoid changing flags)
CMP
CHARS[SI],NULL
; is byte a null?
LOOPNE
SEARCH
; while CX is not 0 (and byte is not
; a null), jump to top of loop
; if byte is a null, then jump
JE
FOUND
; else, indicate that list doesn’t contain a null
CLC
JMP
CONTINUE
FOUND:
STC
; indicate that list contains a null
CONTINUE:
...
Содержание 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...