我正在使用MASM & Irvine 32位程序集,并且我有数组A,B,C和堆叠执行A + B = C,将数组A的每个[i]项与数组B和写入阵列C正确地求和数组
例如,
arrA 1, 2, 4, 1
+
arrB 2, 1, 1, 3
=
arrC 3, 3, 5, 4
我试图用指针来工作,但我有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