Instruction Set
4-199
REPNE
REPNE
Examples
This example scans a string of 16-bit integers in memory until it finds a particular integer
or the entire string is scanned. The microcontroller scans the words, one by one, from first
to last. If the string contains the integer, the following instructions save the segment and
offset of the integer.
; defined in SEG_S segment
STRING
DW
16 DUP (?)
INTEGER
DW
-1024
; FC00h
; notify assembler: DS and ES specify the same segment
ASSUME DS:SEG_S, ES:SEG_S
; set up segment registers with same segment
MOV
AX,SEG_S
; load segment into DS
MOV
DS,AX
; DS points to SEG_S
MOV
ES,AX
; ES points to SEG_S
; scan string for integer
; initialize and use string
...
; save ES
PUSH
ES
; set up registers and flags
MOV
AX,INTEGER
; AX = INTEGER
LEA
DI,STRING
; load offset (segment = DS)
MOV
CX,LENGTH STRING
; set up counter
CLD
; process string low to high
; scan string for integer
REPNE
SCASB
; if the string does not contain -1024, then jump
JNE
NOT_FOUND
; load segment of integer into ES and offset into DI
SUB
DI,2
; integer is back one word
LES
DI,STRING[DI]
JMP
FOUND
NOT_FOUND:
...
FOUND:
...
; restore ES
POP
ES
Содержание 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...