Instruction Set
4-49
DEC
DEC
Examples
This example sends events to another device. CMP, JE, DEC, and JMP implement a
construct equivalent to the C-language
while loop.
Tips
Use SUB instead of DEC when you need to detect either a borrow to the highest bit of an
unsigned result, or an integer result that is too large to fit in the destination.
Use DEC within a loop when you want to decrease a value by 1 each time the loop is
executed.
The LOOP instruction can be used to combine the decrement (DEC CX only) and conditional
jump into one instruction.
Related Instructions
If you want to
See
Add 1 to a number
INC
Set CF to 1 if there is a borrow to the highest bit of the unsigned result,
or set OF to 1 if the integer result is too large to fit in the destination
SUB
COUNT
DW
1048
; number of events to send
; send events to another device
SEND:
CMP
COUNT,0
; is count 0?
JE
DONE
; if so, then jump out of loop
CALL
SEND_EVENT
; send an event
DEC
COUNT
; subtract 1 from counter
JMP
SEND
; jump to top of loop
DONE:
...
Содержание 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...