Instruction Set
4-27
CLC
CLC
This example scans a string in memory until it finds a character or until 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.
STRING
DB
10 DUP (?)
NULL
EQU
0
; notify assembler that DS and ES specify
; the same segment of memory
ASSUME DS:DATASEG, ES:DATASEG
; set up segment registers with same segment
MOV
AX,DATASEG
; copy data segment to AX
MOV
DS,AX
; copy AX to DS
MOV
ES,AX
; copy AX to ES
; initialize and use string
...
; set up registers and flags
MOV
AL,NULL
; 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...