![background image](http://html1.mh-extra.com/html/amd/am186-series/am186-series_instruction-set_2921692128.webp)
Instruction Set
4-88
JCXZ
JCXZ
Examples
This example waits for a character from the serial port. DEC, JCXZ, and JMP implement
a construct equivalent to the C-language
do-while loop. CMP and JNE implement an
if statement within the loop.
Tips
Use JCXZ to determine if CX is 0 before executing a loop that does not check the value of
CX until the bottom of the loop.
Related Instructions
If you want to
See
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
Jump to the top of a loop if CX is not 0 and two compared components are not equal LOOPNE
; loop for a maximum number of times or until a
; serial-port character is ready
MOV
CX,100h
; set up counter
LOOP_TOP:
mCHAR_READY
; read character into AH (macro)
CMP
AH,0
; is a character ready?
JNE
GOT_CHAR
; if so, then jump out with character
DEC
CX
; subtract 1 from counter
JCXZ
NO_CHAR
; if CX is 0, jump out without character
JMP
LOOP_TOP
; if not, jump to top of loop
GOT_CHAR:
...
NO_CHAR:
...
Summary of Contents for Am186 Series
Page 1: ...Am186 and Am188 Family Instruction Set Manual February 1997...
Page 10: ...Table of Contents x...
Page 18: ...Programming 1 8...
Page 40: ...Instruction Set Listing 3 14...