`add sum,gapArr [esi]`产生A2070:无效的指令操作数

时间:2015-11-15 23:11:38

标签: assembly 32-bit masm32 irvine32

我目前仍然坚持这个MASM计划,我必须为家庭作业写作。我目前得到MASM32错误A2070:此行上的指令操作数无效:

add sum, gapArr[esi]

导致此错误的原因是什么,我该如何解决?

在代码的注释中,它说明了程序应该做什么。我的代码是:

; Chapter 4, Exercise 3: Summing the Gaps between Array Values

Comment !
Description: Write a program with a loop and indexed addressing that calculates the sum of all the
gaps between successive array elements. The array elements are doublewords, sequenced in nondecreasing
order.
!

.386
.model flat,stdcall
.stack 4096
ExitProcess proto,dwExitCode:dword
INCLUDE Irvine16.inc

.data

arr1 DWORD 11, 12, 30, 40, 55, 61, 70, 84
arrSize = ($-arr1)/TYPE arr1
gapArr DWORD arrSize-1 DUP(?)
sum DWORD ?

.code

main PROC 

;Call the procedure

call Clrscr

;Initialize ESI pointer 

mov esi, 0 
mov ecx, arrSize
dec ecx

L1:
mov eax, arr1[esi+1]
sub eax, arr1[esi]
mov gapArr[esi], eax
inc esi

loop L1

;Calculate the sum of gaps

mov sum, 0
mov esi, 0

mov ecx, arrSize
dec ecx

L2:
add sum, gapArr[esi]
inc esi

loop L2


        INVOKE ExitProcess,0
main ENDP
END main

0 个答案:

没有答案