![](/img/trans.png)
[英]How to move and display array values from one to another in Assembly Language?
[英]How to compare an array with another array in Assembly language
我試圖將array1與array2進行比較。 這是我的代碼的一部分,但無法正常工作。
mov si, 00
mov di, 00
Compare:
cmp array1[si], array2[di]
je checking
jmp compare
我正在執行一個匯編程序,該程序將要求用戶輸入字符串。 第一個字符串被標記為輸入。 第二個字符串是舊字符序列。 第三字符串是新替換的字符序列。
樣品:
輸入:hatatat
舊字符串:at
替換為:eh
輸出:heheheh
與大多數x86指令一樣,指令cmp
不能一次處理兩個內存位置。 您需要將一個參數加載到寄存器中。 例如:
mov al, [Array1+si]
cmp al, [Array2+di]
也許有一組指令可以同時處理兩個內存參數-字符串指令如lods, stos, cmps, movs, ...
這些指令始終與[si]和/或[di](esi)中的內存指針一起使用和edi(32位模式),並且不接受常量偏移。
mov si, Array1
mov di, Array2
cld
cmpsb ; compares two bytes - from [si] and [di] and then increments si and di by 1
請閱讀說明參考手冊以獲取更多詳細說明。
注意 :只要您沒有提供有關首選匯編語法的信息,我就在示例中使用FASM語法。 如果使用其他匯編程序,則可能應根據其語法編輯代碼。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.