Assembly 汇编语言x86 Irvine

Assembly 汇编语言x86 Irvine,assembly,x86,irvine32,Assembly,X86,Irvine32,我有两项任务: 打印ar2的长度 将元素从ar1移动到ar2,每项递增1 我需要汇编语言x86 IR32的帮助。我必须做上述两件事。我第一个答对了,但第二个我有点迷路了。你是怎么做到的?以下是我目前掌握的情况: 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

我有两项任务:

  • 打印
    ar2的长度
  • 将元素从
    ar1
    移动到
    ar2
    ,每项递增1
我需要汇编语言x86 IR32的帮助。我必须做上述两件事。我第一个答对了,但第二个我有点迷路了。你是怎么做到的?以下是我目前掌握的情况:

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

您只需从第一个数组中读取单词(每个项目的大小为2),然后将它们复制到包含DWORDs的第二个数组中(每个项目的大小为4):

主进程

  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