-1

这是我的汇编代码。我还在语句中收到错误“不正确的操作数类型”CMP [SI+CI],SEARCH

.MODEL SMALL

.STACK 100H

.DATA

        MATR1 DW 0001H,0002H,0003H,0004H,0005H,0006H,0007H,0008H,0009H,000AH

        SEARCH DW 0003H

        LOWER DW 0000H

        HIGHER DW 000AH

        MID DW 0000H

        TEMP DW 0000H

    CI DW 0000H

        MSG1 DB 'NUMBER FOUND','$'

        MSG2 DB 'NUMBER NOT FOUND','$'

.CODE

MAIN PROC FAR

        MOV AX,@DATA

        MOV DS,AX

        MOV BX,0002H

        LEA DI,MATR1

        LEA SI,MATR1+0014H

NEXT:   MOV AX,LOWER

        MOV DX,HIGHER

        CMP AX,DX

        JGE TERM2

        MOV AX,0

        MOV DX,0

        MOV AX,LOWER

        ADD AX,HIGHER

        DIV BX

        MOV SI,0000H

        MOV SI,AX

        ;MOV AL,SEARCH

    MOV CI,AX

    MUL BX

    MOV CX,AX

    MOV AX,CI

    MOV CI,CX

        CMP [SI+CI],SEARCH

        JGE AGAIN

        MOV HIGHER,AX

        JMP NEXT

AGAIN:  MOV SI,0000H

        MOV SI,AX

        MOV DX,AX

    MOV CI,AX

    MUL BX

    MOV CX,AX

    MOV AX,CI

    MOV CI,CX

    MOV AX,0

        CMP [SI+CI],SEARCH

        JE TERM

        MOV LOWER,DX

        JMP NEXT

TERM:   LEA DX,MSG1

        MOV AH,09H

        INT 21H

        MOV AH,4CH

        INT 21H

TERM2:  LEA DX,MSG2

        MOV AH,09H

        INT 21H

        MOV AH,4CH

        INT 21H

MAIN ENDP

END
4

1 回答 1

0

CI是内存中的一个值,所以也是SEARCH。因此,CMP [SI+CI],SEARCH给定了两个内存操作数,这在 x86 程序集中不受支持。您可以通过首先将其中一个操作数加载到寄存器中然后进行比较来解决该问题,例如:

MOV CX, [SI+CI]
CMP CX, SEARCH
于 2013-09-06T10:22:15.483 回答