我有两个任务:
ar2
ar1
移至ar2
,将每个项目递增1 我需要汇编语言x86 Irvine32的帮助。我必须做上面描述的这两件事。我得到了第一个正确的,但我在第二个中丢失了。你怎么做到这一点?这是我到目前为止所做的:
INCLUDE Irvine32.inc
.data
ar1 WORD 1,2,3
ar2 DWORD 3 DUP(?)
.code
main PROC
mov eax, 0
mov eax, LENGTHOF ar2
mov bx, ar1
mov ebx, ar2
inc ebx
call DumpRegs
exit
main ENDP
END main
答案 0 :(得分:0)
您只需要从第一个数组中读取WORD(每个项目的sizeof为2),然后将它们复制到包含DWORD的第二个(每个项目的sizeof为4):
主要PROC
mov ecx, LENGTHOF ar2 ; ECX should result in '3'
lea esi, ar1 ; source array - load effective address of ar1
lea edi, ar2 ; destination array - load effective address of ar2
loopECX:
movzx eax, word ptr [esi] ; copies a 16 bit memory location to a 32 bit register extended with zeroes
inc eax ; increases that reg by one
mov dword ptr [edi], eax ; copy the result to a 4 byte memory location
add esi, 2 ; increases WORD array 'ar1' by item size 2
add edi, 4 ; increases DWORD array 'ar2' by item size 4
dec ecx ; decreases item count(ECX)
jnz loopECX ; if item count(ECX) equals zero, pass through
; and ...
call DumpRegs ; ... DumpRegs
exit
main ENDP
END main