Instruction Set
4-149
LOOPE
LOOPE
Flag Settings After Instruction
Examples
This example searches one row of a table in memory for a number other than 0. If the row
contains a number other than 0, 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 not equal LOOPNE
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 –
ROW
DW
8 DUP (?)
TABLE
DW
20 * (SIZE ROW) DUP (?)
; 20 x 8 table
; initialize and use table
...
; point to third row
MOV
BX,2 * (SIZE ROW)
; SIZE ROW = 16 bytes
MOV
SI,-2
; set up row index
MOV
CX,LENGTH ROW
; set up counter
SEARCH:
ADD
SI,2
; point to word in row (ADD before
; CMP to avoid changing flags)
CMP
TABLE[BX][SI],0
; is word 0?
LOOPZ
SEARCH
; while CX is not 0 (and word is 0),
; jump to top of loop
; if word is not 0, then jump
JNE
OTHER
; indicate that all words are 0
CLC
JMP
CONTINUE
OTHER:
STC
; indicate that at least one word is not 0
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...