字符串我讀了一本關於大會,它具有下面的代碼:大會 - 環比使用代表
.DATA
string1 db ’abcdfghi’,0
strLen EQU $ - string1
string2 db ’abcdefgh’,0
.CODE
.STARTUP
mov AX,DS ; set up ES
mov ES,AX ; to the data segment
mov ECX,strLen
mov ESI,string1
mov EDI,string2
cld ; forward direction
repe cmpsb
leaves ESI pointing to g in string1 and EDI to f in string2. Therefore, adding
dec ESI
dec EDI
leaves ESI and EDI pointing to the last character that differs. Then we can use,
ja str1Above
據writen,我們需要:
dec ESI
dec EDI
監守leaves ESI pointing to g in string1 and EDI to f in string2.
但是爲什麼?當我們在ESI
的'f'和EDI
中的'e'到達'f'時,repe
條件未滿足,因此我們將退出循環,其中'f'在ESI
中,'e'在EDI
中。爲什麼它說我們繼續再次掃描字符串?
repe還檢查是否esi = edi,否?在我們的例子中,它退出循環,因爲esi <> edi,而不是因爲ecx = 0。 – 2012-03-10 11:26:39
當然 - 錯過了,謝謝。關鍵是,退出條件是開始。這就是爲什麼你需要調整指針。 – 2012-03-10 19:38:47