【发布时间】:2015-07-23 14:46:39
【问题描述】:
我正在使用平面汇编程序处理汇编语言中的 movsb 和 movsw 指令。现在,我注意到当执行 movsb 指令时,SI 和 DI 寄存器增加 1,而 movsw 指令将 SI 和 DI 寄存器增加 2。我有点困惑为什么?谁能解释一下原因。我在下面为 cmets 的指令添加了我的代码。请帮帮我。谢谢!
使用 movsb 指令(平面汇编器)
cld ;clear direction flag
lea si,[val] ;the memory address of source is loaded in the source register
lea di,[v];the memory address of the destination is loaded in the destination register
mov cx,5 ; the counter basically executes for the number of characters in the array
rep movsb ; repeats the instruction for 5 times
val:
db 'A'
db 'B'
db 'C'
db 'D'
db 'E'
v db 5 DUP(?)
使用 movsw 指令(平面汇编器)
cld ;clear the direction flag
lea si,[a];load the address of a in source
;register
lea di,[b] ;load the address of b in destination
;register
mov cx,3
rep movsw ;copy each word from source to
;destination and increment the source register
;by 2 and destination register by 2
a:
dw '1'
dw '2'
dw '3'
b dw 3 DUP(?)
【问题讨论】: