汇编新手。。error A2070:invalid instruction operands
INCLUDEIrvine32.inc.datatableBDWORD10h,20h,30h,40h,50hRowSizeB=($-tableB)DWORD60h,70h...
INCLUDE Irvine32.inc
.data
tableB DWORD 10h, 20h, 30h, 40h, 50h
RowSizeB = ($ - tableB)
DWORD 60h, 70h, 80h, 90h, 0A0h
DWORD 0B0h, 0C0h, 0D0h, 0E0h, 0F0h
tableW DWORD 10h, 20h, 30h, 40h, 50h
RowSizeW = ($ - tableW)
DWORD 60h, 70h, 80h, 90h, 0A0h
DWORD 0B0h, 0C0h, 0D0h, 0E0h, 0F0h
tableD DWORD 10h, 20h, 30h, 40h, 50h
RowSizeD = ($ - tableD)
DWORD 60h, 70h, 80h, 90h, 0A0h
DWORD 0B0h, 0C0h, 0D0h, 0E0h, 0F0h
index DWORD ?
msg1 BYTE "Enter row number: ",0
msg2 BYTE "The sum is: ",0
.code
main PROC
mov edx,OFFSET msg1 ; "Enter row number:"
call WriteString
call Readint ; EAX = row number
mov index,eax
; byte array:
push OFFSET tableB ; array offset
push RowSizeB ; row size
push TYPE BYTE ; array type
push index ; row index
call calc_row_sum ; EAX = sum
mov edx,OFFSET msg2 ; "The sum is:"
call WriteString
call WriteHex ; write sum in EAX
call Crlf
; word array:
push OFFSET tableW ; array offset
push RowSizeW ; row size
push TYPE WORD ; array type
push index ; row index
call calc_row_sum ; EAX = sum
mov edx,OFFSET msg2 ; "The sum is:"
call WriteString
call WriteHex ; write sum in EAX
call Crlf
; doubleword array:
push OFFSET tableD ; array offset
push RowSizeD ; row size
push TYPE DWORD ; array type
push index ; row index
call calc_row_sum ; EAX = sum
mov edx,OFFSET msg2 ; "The sum is:"
call WriteString
call WriteHex ; write sum in EAX
call Crlf
exit
main ENDP
;------------------------------------------------------------
calc_row_sum PROC
;
; Calculates the sum of a row in a two-dimensional table
; of any type.
; Receives: array offset, row size in bytes, array type, row index.
; Returns: EAX = sum.
;------------------------------------------------------------
_arrayOffset EQU DWORD PTR [ebp+20]
_rowSize EQU DWORD PTR [ebp+16]
_arrayType EQU DWORD PTR [ebp+12]
_rowindex EQU DWORD PTR [ebp+8]
push ebp
mov ebp,esp
mov eax,_rowIndex
mul DWORD PTR _rowSize
mov ebx,_arrayOffset
add ebx,eax ; row offset
; Convert row size to a loop counter.
mov ecx,_rowSize
.IF _arrayType == 2
shr ecx, 1
.ELSEIF _arrayType == 4
shr ecx, 2
.ENDIF
mov eax,0 ; accumulator
mov esi,0 ; column index
; Loop through the columns.
L1:
.IF _arrayType == 1
movzx edx,BYTE PTR[ebx + esi] ; get a byte
.ELSEIF _arrayType == 2
movzx edx,WORD PTR[ebx + esi*2] ; get a word
.ELSEIF _arrayType == 4
mov edx,DWORD PTR[ebx + esi*4] ; get a doubleword
.ENDIF
add eax,edx ; add to accumulator
inc esi ; next value in row
loop L1
pop ebp
ret 16
calc_row_sum ENDP
END main
为什么push RowSizeB,push RowSizeW,push RowSizeD都是invalid instruction operands呢?~ 展开
.data
tableB DWORD 10h, 20h, 30h, 40h, 50h
RowSizeB = ($ - tableB)
DWORD 60h, 70h, 80h, 90h, 0A0h
DWORD 0B0h, 0C0h, 0D0h, 0E0h, 0F0h
tableW DWORD 10h, 20h, 30h, 40h, 50h
RowSizeW = ($ - tableW)
DWORD 60h, 70h, 80h, 90h, 0A0h
DWORD 0B0h, 0C0h, 0D0h, 0E0h, 0F0h
tableD DWORD 10h, 20h, 30h, 40h, 50h
RowSizeD = ($ - tableD)
DWORD 60h, 70h, 80h, 90h, 0A0h
DWORD 0B0h, 0C0h, 0D0h, 0E0h, 0F0h
index DWORD ?
msg1 BYTE "Enter row number: ",0
msg2 BYTE "The sum is: ",0
.code
main PROC
mov edx,OFFSET msg1 ; "Enter row number:"
call WriteString
call Readint ; EAX = row number
mov index,eax
; byte array:
push OFFSET tableB ; array offset
push RowSizeB ; row size
push TYPE BYTE ; array type
push index ; row index
call calc_row_sum ; EAX = sum
mov edx,OFFSET msg2 ; "The sum is:"
call WriteString
call WriteHex ; write sum in EAX
call Crlf
; word array:
push OFFSET tableW ; array offset
push RowSizeW ; row size
push TYPE WORD ; array type
push index ; row index
call calc_row_sum ; EAX = sum
mov edx,OFFSET msg2 ; "The sum is:"
call WriteString
call WriteHex ; write sum in EAX
call Crlf
; doubleword array:
push OFFSET tableD ; array offset
push RowSizeD ; row size
push TYPE DWORD ; array type
push index ; row index
call calc_row_sum ; EAX = sum
mov edx,OFFSET msg2 ; "The sum is:"
call WriteString
call WriteHex ; write sum in EAX
call Crlf
exit
main ENDP
;------------------------------------------------------------
calc_row_sum PROC
;
; Calculates the sum of a row in a two-dimensional table
; of any type.
; Receives: array offset, row size in bytes, array type, row index.
; Returns: EAX = sum.
;------------------------------------------------------------
_arrayOffset EQU DWORD PTR [ebp+20]
_rowSize EQU DWORD PTR [ebp+16]
_arrayType EQU DWORD PTR [ebp+12]
_rowindex EQU DWORD PTR [ebp+8]
push ebp
mov ebp,esp
mov eax,_rowIndex
mul DWORD PTR _rowSize
mov ebx,_arrayOffset
add ebx,eax ; row offset
; Convert row size to a loop counter.
mov ecx,_rowSize
.IF _arrayType == 2
shr ecx, 1
.ELSEIF _arrayType == 4
shr ecx, 2
.ENDIF
mov eax,0 ; accumulator
mov esi,0 ; column index
; Loop through the columns.
L1:
.IF _arrayType == 1
movzx edx,BYTE PTR[ebx + esi] ; get a byte
.ELSEIF _arrayType == 2
movzx edx,WORD PTR[ebx + esi*2] ; get a word
.ELSEIF _arrayType == 4
mov edx,DWORD PTR[ebx + esi*4] ; get a doubleword
.ENDIF
add eax,edx ; add to accumulator
inc esi ; next value in row
loop L1
pop ebp
ret 16
calc_row_sum ENDP
END main
为什么push RowSizeB,push RowSizeW,push RowSizeD都是invalid instruction operands呢?~ 展开
展开全部
RowSizeB = ($ - tableB)
...
push RowSizeB
这种语句在 RadASM 上是可以通过编译的
;-------------------------------------------
另外:
建议在 calc_row_sum 子程序中,让编译器自动平衡堆栈(与您的问题无关,只是建议)
...
push RowSizeB
这种语句在 RadASM 上是可以通过编译的
;-------------------------------------------
另外:
建议在 calc_row_sum 子程序中,让编译器自动平衡堆栈(与您的问题无关,只是建议)
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
这个。。是不是汇编器的问题啊
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询