設置方向標誌指令
CLD、STDide
串處理指令
MOVSB / MOVSW
STOSB / STOSW
LODSB / LODSW
CMPSB / CMPSW
SCASB / SCASWpost
串重複前綴spa
REP 3d
REPE / REPZcode
REPNE / REPNZblog
與 REP 配合工做的 MOVS / STOS / LODSget
REP repeat
執行操做:
(1) 如 (CX)=0 則退出 REP,不然轉(2)
(2) (CX) ← (CX) -1
(3) 執行 MOVS / STOS / LODS
(4) 重複 (1) ~ (3)string
MOVS DST, SRC move string DST目的操做數destination SRC源it
MOVSB (字節)
MOVSW (字)io
data segment mess1 db ‘personal_computer’ data ends extra segment mess2 db 17 dup (?) extra ends code segment code ends data segment mess1 db ‘personal_computer’ data ends extra segment mess2 db 17 dup (?) extra ends code segment mov ax, data mov ds,ax mov ax, extra mov es, ax lea si, mess1 lea di, mess2 mov cx, 17 cld rep movsb … code ends data segment mess1 db ‘personal_computer’ mess2 db 17 dup (?) data ends code segment mov ax, data mov ds, ax mov es, ax lea si, mess1 lea di, mess2 mov cx, 17 cld rep movsb … code ends
STOS DST store into string
STOSB (字節)
STOSW (字)
執行操做:
字節操做:((DI))←(AL), (DI)←(DI)±1
字操做:((DI))←(AX), (DI)←(DI)±2
例:把 附加段 中的 10 個字節緩衝區置爲 20H
lea di, mess2
mov al, 20H
mov cx, 10
cld
rep stosb
lea di, mess2
mov ax, 2020H
mov cx, 5
cld
rep stosw
LODS SRC load from string
LODSB (字節)
LODSW (字)
執行操做:
字節操做:(AL)←((SI)), (SI)←(SI)±1
字操做:(AX)←((SI)), (SI)←(SI)±2
注意:
* LODS 指令通常不與 REP 聯用
* 源串通常在數據段中(容許使用段跨越前綴來修改),目的串必須在附加段中
* 不影響條件標誌位
與 REPE / REPZ(REPNE / REPNZ)配合工做的
CMPS 和 SCAS
REPE / REPZ
REPNE / REPNZ
執行操做:
(1) 如 (CX)=0 或 ZF=0 (ZF=1) 則退出串操做,
不然轉(2)
(2) (CX)←(CX) -1
(3) 執行 CMPS / SCAS
(4) 重複 (1) ~ (3)
CMPS SRC, DST compare string
CMPSB (字節)
CMPSW (字)
執行操做:
(1) ((SI)) - ((DI))
根據比較結果置條件標誌位:相等 ZF=1
不等 ZF=0
(2) 字節操做:(SI)←(SI)±1, (DI)←(DI)±1
字操做: (SI)←(SI)±2, (DI)←(DI)±2
SCAS DST scan string
SCASB (字節)
SCASW (字)
執行操做:
字節操做:(AL) - ((DI)), (DI)←(DI)±1
字操做: (AX) - ((DI)), (DI)←(DI)±2