x86汇编错误:“错误错误A2008:语法错误:cqd”和“错误A2008:语法错误:indiv”

时间:2018-02-23 18:43:39

标签: assembly x86 masm

我正在尝试制作一个我从教科书中复制出来的程序。我正在尝试学习x86程序集的数组,但这个例子给了我一个错误,尽管它是一个例子的副本。它不喜欢命令cqdindiv,这些命令分别表示“扩展总和为四字”和“计算平均值”。以下是我的代码:

;given an array of double word integers, 1.) find their average and 2.) add 10 to each number 
;smaller than average

.586    
.MODEL FLAT
.STACK 4096                 ; reserve 4096-byte stack

.DATA
nbrArray DWORD 25,47,15,50,32,95 DUP (?)
nbrElts DWORD 5

.CODE
main    PROC

; find sum and average
mov eax, 0              ; sum := 0
lea ebx,nbrArray        ; get address of nbrArray
mov ecx,nbrElts         ;count := nbrElts
jecxz quit              ;quit if no numbers
forCount1: 
    add eax, [ebx]      ;add number to sum
    add ebx,4           ;get address of next array elt
    loop forcount1      ;repeat nbrElts times
    cqd                 ;extend sum to quadword
    indiv nbrElts       ;calculate average

; add 10 to each array element below average
    lea ebx, nbrArray   ;get address of nbrArray
    mov ecx,nbrElts     ;count := nbrElts
forCount2:
    cmp [ebx], eax      ;Number < average ?
    jnl endIfSmall      ;continue if not less
    add DWORD PTR [ebx], 10 ;add 10 to number
endifSmall:
    add ebx,4           ;get address of next array elt
    loop forCount2      ;repeat
quit:
    mov eax,0       ;exit with return code 0
    ret
main ENDP
END

0 个答案:

没有答案