+-------+
+ 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 的值
根据返回结果设置 ZF 标志
循环方式:
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 的值
根据返回结果设置 ZF 标志
循环方式:
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