.BSS セクションで作成された変数に文字列を格納する必要があるとします。
var1 resw 5 ; this is "abcde" (UNICODE)
var2 resw 5 ; here I will copy the first one
NASMでこれを行うにはどうすればよいですか? 私はこのようなことを試しました:
mov ebx, var2 ; Here we will copy the string
mov dx, 5 ; Length of the string
mov esi, dword var1 ; The variable to be copied
.Copy:
lodsw
mov [ebx], word ax ; Copy the character into the address from EBX
inc ebx ; Increment the EBX register for the next character to copy
dec dx ; Decrement DX
cmp dx, 0 ; If DX is 0 we reached the end
jg .Copy ; Otherwise copy the next one
したがって、最初の問題は、文字列が UNICODE ではなく ASCII としてコピーされ、その理由がわかりません。第 2 に、一部のレジスタの使用が推奨されていない可能性があることを私は知っています。最後に、これを行うためのより迅速な方法があるかどうか疑問に思います (文字列を使用したこの種の操作用に特別に作成された命令があるかもしれません)。私は8086プロセッサについて話している。