# 串处理指令

+-------+
+ CMPSB +
+-------+

ES:[DI] 与 DS:[SI] 作字节比较

DS:[SI] - ES:[DI]

OF, SF, ZF, AF, PF, CF

if DF = 0 then
SI = SI + 1
DI = DI + 1
else
SI = SI - 1
DI = DI - 1

+-------+
+ CMPSW +
+-------+

ES:[DI] 与 DS:[SI] 作字比较

Algorithm: Compare words: ES:[DI] from DS:[SI].

DS:[SI] - ES:[DI]

OF, SF, ZF, AF, PF, CF

if DF = 0 then
SI = SI + 2
DI = DI + 2
else
SI = SI - 2
DI = DI - 2

+-------+
+ SCASB +
+-------+

AL 与 ES:[DI] 作字节比较

ES:[DI] - AL

OF, SF, ZF, AF, PF, CF

if DF = 0 then
DI = DI + 1
else
DI = DI - 1

+-------+
+ SCASW +
+-------+

AX 与 ES:[DI] 作比较

ES:[DI] - AX

OF, SF, ZF, AF, PF, CF

if DF = 0 then
DI = DI + 2
else
DI = DI - 2

+------+
+ REPE +
+------+

ZF=1 时循环执行 CMPSB, CMPSW, SCASB, SCASW，循环执行的次数为 CX 的值

check_cx:
if CX <> 0 then
do following chain instruction
CX = CX - 1

if ZF = 1 then:
go back to check_cx
else
exit from REPE cycle
else
exit from REPE cycle

+-------+
+ REPNE +
+-------+

ZF=0 时循环执行 CMPSB, CMPSW, SCASB, SCASW，循环执行的次数为 CX 的值

check_cx:
if CX <> 0 then
do following chain instruction
CX = CX - 1
if ZF = 0 then:
go back to check_cx
else
exit from REPE cycle
else
exit from REPE cycle

• 本文已收录于以下专栏：

举报原因： 您举报文章：串处理指令 色情 政治 抄袭 广告 招聘 骂人 其他 (最多只允许输入30个字)