私はMASM &アーバイン32ビットアセンブリを使用していますが、配列A、B、Cがあり、配列Aの各項目[i]を配列で加算してA + B = 、例えば配列C.アレイを正しく集計する
に
arrA 1, 2, 4, 1
+
arrB 2, 1, 1, 3
=
arrC 3, 3, 5, 4
をBと書いて、私はポインタで動作するようにしようとしましたが、私は00、00、00、0F出力を持っていました。
StrHex_MYプロシージャには注意しないでください。出力配列でテストされます。
コード:
.586
.model flat, stdcall
ExitProcess PROTO, dwExitCode:DWORD
include \Irvine\Irvine32.inc
includelib \Irvine\kernel32.lib
includelib \Irvine\user32.lib
include module.inc
.data
CaptionGreet BYTE "Test me", 0
arrA DWORD 1, 2, 4, 1
arrB DWORD 2, 1, 1, 3
arrC DWORD 0, 0, 0, 0
toOut DB 64 dup(?)
.code
main PROC
mov edi, OFFSET arrA ; Address of arrA
mov esi, OFFSET arrB ; Address of arrB
mov eax, 0 ; Register with result
mov ecx, LENGTHOF arrA ; Lenght of arrays
L1:
add eax, [edi] ; Add current arrA element to eax
add eax, [esi] ; Add current arrB element to eax
add edi, TYPE arrA ; Move pointer to the next arrA element
add esi, TYPE arrB ; Move pointer to the next arrB element
mov arrC, eax ; Move current eax value to arrC
loop L1
; Converting result to HEX toOut. Don't pay attention to this part
; ----
push OFFSET toOut
push OFFSET arrC
push 256
call StrHex_MY
; ---
; Output result
INVOKE MessageBoxA, 0, ADDR toOut, ADDR CaptionGreet, 0
INVOKE ExitProcess,0
main ENDP
END main
だから、0Fを出力私は各arrC要素にアクセスし、arrA + arrBの現在の要素の合計で書き直しています。 – NLis