错误A2070:在汇编语言中使用嵌套的while循环时,无效的指令操作数

问题描述:

我正在尝试使用Masm在程序集中嵌套while循环.运行以下代码时,我在第15行(即内部while循环的endw指令)处收到错误A2070:无效的指令操作数".

I am trying nested while loop in assembly using masm. I am getting the "error A2070: invalid instruction operands" at line 15 i.e at the endw directive of internal while loop while running the following code.

INCLUDE Irvine32.inc
.data
i byte 1
j byte 2
.code
main PROC  
xor eax,eax
 .while i<5
mov j, 2
.while j<i
    mov al, j
    call writeDec
    call crlf
    inc j
.endw
inc i
 .endw
exit
main ENDP
END main

我找不到原因.谁能帮我吗?

I cant find the reason for this. Can anyone help me?

错误在这里:

.while j<i

您不能直接比较两个存储器的内容.可以将内存内容与寄存器进行比较,例如:

You cannot compare two memory contents directly. It is possible to compare a memory content with a register, e.g.:

mov dl, i
.while j<dl

顺便说一句:不要相信外星人"功能(Irvine的WriteDecCrlf).当寄存器无意中更改其内容时,这可能是由于这种功能造成的.

BTW: Don't trust an "alien" function (Irvine's WriteDec and Crlf). When a register unintentionally changes its contents, this can due to such a function.