Assembler







. - ,
SCAS.
AL AX ,
ES:DI. SCAS
, ,
, DI ,
.
 
SCAS REP
. ,
REP LODS , REP SCAS
.
REP - " " REPE "
" REPNE. REP,
CX .
REPE, , AL
( AX) ,
CX 0.
, .
REPNE REPE.
,
.
 
SCAS REPNE
. ,
.
. 4.24 , SCAS .
AL . SCAN_TABLE
, , CX
. REPNE SCASB
,
. DI ,
.
, DI
FOUND.
, ,
, .
JE .
,
: AL ,
REPNE, ; CX
.
,
. ,
.
FOUND ,
( ). , .
CX ,
, , .

Microsoft (R) Macro Assembler Version 5.00 1/1/80 04:01:36
. 4.24 Page 1-1
 
 
PAGE ,132
TITLE . 4.24
0000 CODE SEGMENT
ASSUME CS:CODE,DS:CODE,ES:CODE
 
;--------------------------------------
; AL
;--------------------------------------
 
0000 8D 3E 000C R LEA DI, SCAN_TABLE ;
0004 B9 000B 90 MOV CX, SCAN_TABLE_LENGTH ;
0008 F2/ AE REPNE SCASB ;
000A 74 00 JE FOUND ; ,
; ... ;
000C FOUND:
;-----
 
000C 89 96 93 8A 85 8D 83 SCAN_TABLE DB ''
98 99 87 95
 
= 000B SCAN_TABLE_LENGTH EQU $-SCAN_TABLE
 
0017 CODE ENDS
END
 
. 4.24
- CMPS.
, - . MOVS,
. CMPS
DS:SI ES:DI,
. SCAS,
REP , REPE REPNE
.

Microsoft (R) Macro Assembler Version 5.00 1/1/80 04:01:41
. 4.25 Page 1-1
 
PAGE ,132
TITLE . 4.25
0000 CODE SEGMENT
ASSUME CS:CODE,DS:CODE,ES:CODE
 
;--------------------------------------
; 5-
; 5- .
; .
;--------------------------------------
 
0000 FIG4_25 PROC NEAR
0000 8D 36 001D R LEA SI, ARGUMENT ;
0004 8D 3E 0022 R LEA DI, COMPARE_TABLE ;
0008 BB 0000 MOV BX, 0 ; BX c
000B COMPARE_LOOP:
000B 56 PUSH SI ;
000C 57 PUSH DI ;
000D B9 0005 MOV CX, 5 ; 5
0010 F3/ A6 REPE CMPS ARGUMENT,COMPARE_TABLE ;
0012 5F POP DI ;
0013 5E POP SI ;
0014 74 06 JE FOUND ;
0016 83 C7 05 ADD DI, 5 ;
;
0019 43 INC BX ;
001A EB EF JMP COMPARE_LOOP ;
 
001C FOUND:
001C C3 RET
001D FIG4_25 ENDP
 
001D 41 42 43 44 45 ARGUMENT DB 'ABCDE'
0022 COMPARE_TABLE LABEL BYTE
0022 51 57 45 52 54 50 4F DB 'QWERT','POIUY','ASDFG','LKJHG'
49 55 59 41 53 44 46
47 4C 4B 4A 48 47
0036 5A 58 43 56 42 4D 4E DB 'ZXCVB','MNBVC','VWXYZ','ABCDE'
42 56 43 56 57 58 59
5A 41 42 43 44 45
004A CODE ENDS
END
 
. 4.25
. 4.25 CMPS.

.
. , BX
. REPE,
,
.
, . JE
(", ") CMPS.
= ,
. CMPS
, CX ,
FOUND. ,
,
. ,
,
. ,
.