Instruction Set
4-229
STC
STC
This example scans a string in memory until it finds a character or the entire string is
scanned. The microcontroller scans the bytes, one by one, from first to last. If the string
contains the character, the microcontroller sets the Carry Flag (CF) to 1; otherwise, it clears
CF to 0.
; defined in SEG_R segment
STRING
DB
10 DUP (?)
AT_SIGN
EQU
’@’
; 40h
; notify assembler: DS and ES specify the
; same segment of memory
ASSUME DS:SEG_R, ES:SEG_R
; set up segment registers with same segment
MOV
AX,SEG_R
; load segment into DS and ES
MOV
DS,AX
; DS points to SEG_R
MOV
ES,AX
; ES points to SEG_R
; scan string for character
; initialize and use string
...
; set up registers and flags
MOV
AL,AT_SIGN
; copy character to AL
LEA
DI,STRING
; load offset (segment = ES)
MOV
CX,LENGTH STRING
; set up counter
CLD
; process string low to high
; scan string for character
REPNE
SCASB
; if string contains character
JE
FOUND
; else
JMP
NOT_FOUND
FOUND:
STC
; indicate found
JMP
CONTINUE
NOT_FOUND:
CLC
; indicate not found
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...