2014-11-02 19 views
0
String: db "Hello World" 
nonhuman: db 0 
move SI,String+4 
move ax,[SI] 
move [nonhuman],ax 
+2

請更具體地說明你在問什麼。在你所展示的內容中,用AL代替AX,否則MOVE SI將被覆蓋! – 2014-11-02 14:20:48

回答

0

聽起來像作業,所以沒有直接的答案。

使用MOV命令將字節存儲在內存中。一個論點可以是一個常數,另一個必須是一個regiater。如[SI + 4]中所示,您可以使用位移尋址。 Bytelong寄存器是AL/AH,BL/BH等。 AX,BX等是兩個字節長。

要從內存加載一個字節,您也使用MOV,但內存位置需要是第二個操作數,而不是第一個。記住

這樣,代碼雲:

load the replacement value from memory into a byte-sized register 
store that register in the string+4 (the position of O) 
store that same register in the string+10 (the position of D) 

也就是說,除非你的任務是替換的0和D的中的任意字符串,不只是在這一個。在這種情況下,您需要一個循環,您需要從字符串中讀取字節並進行比較,然後進行有條件的替換。