簡體   English   中英

匯編語言x86 Irvine

[英]Assembly Language x86 Irvine

我有兩個任務:

  • 打印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

您只需要從第一個數組中讀取WORDs(每個項目的大小為2)並將它們復制到第二個包含DWORDs(每個項目的大小為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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM