0

我有两个变量,我需要将值从 string1 移动到 string2。

string1 DB 20, 22 dup('?')
string2 DB 20, 22 dup('?')

我知道如何使用寄存器(si)和循环来做到这一点,例如:

LEA si, string1
LEA di, string2
mov cx, 5
change:
mov ax, [si]
mov [di], ax
loop change

我想知道是否有更短的方法。

4

1 回答 1

1

您正在寻找的是REP(Repeat) 和MOVSB(* MOV *e * S *tring * B *yte 的助记符)。

例子:

lea     si,[string1] ;si points to string1
lea     di,[string2] ;di points to string2
mov     cx,5         ;number of bytes in string1
rep     movsb        ;copy the string

也可以看看:

MOVSW (Move String Word - Copies 2 bytes at a time)
MOVSD (Move String DWord - Copies 4 bytees at a time)
于 2013-06-24T00:02:57.397 回答