在MASM中的if语句期间无效的指令操作数错误

时间:2013-04-12 20:30:54

标签: if-statement assembly x86 masm irvine32

我是MASM的新手,我遇到了if语句的问题。我得到的编译错误是:RNG.asm(61):错误A2070:无效的指令操作数。 (第61行从底部向上五)

这是我的代码:

;=====================================================================
; RNG.asm
;
; Reads in: a low int, a high int, and the number of times to generate
; a random number inbetween the low and high value.
;
;Author: Ian Johnson
;Date Created: 4/12/13
;=====================================================================
.386
.model flat,stdcall
.stack

include \masm32\include\irvine32.inc
include \masm32\include\kernel32.inc
includelib \masm32\lib\irvine32.lib
includelib \masm32\lib\kernel32.lib

.data
  min   BYTE "Please enter the min value:"           , 10,0
  max   BYTE "Please enter the max value:"           , 10,0
  times BYTE "please enter the number of iterations:", 10,0

  minInt   DWORD ?          ;minimum value
  maxInt   DWORD ?          ;max value
  timesInt DWORD ?          ;number of iterations
  prevInt  DWORD ?          ;previous random number or initial value
  count    DWORD ?


.code
  main proc   ;start of main procedure
    mov EDX, offset min     ;move min to EDX
    call WriteString        ;print min string
    call ReadInt            ;readin int to EAX
    mov minInt, EAX         ;store EAX value in minInt

    mov EDX, offset max     ;move max to EDX
    call WriteString        ;print max string
    call ReadInt            ;readin int to EAX
    mov maxInt, EAX         ;store EAX value in maxInt

    mov EDX, offset times   ;move times to EDX
    call WriteString        ;print times string
    call ReadInt            ;readin int to EAX
    mov timesInt, EAX       ;store EAX value in timesInt 

    call GetMseconds        ;stores Mseconds in EAX
    mov prevInt, EAX        ;store getMseconds in prevInt
    mov count,0
L1:    
    mov EAX, minInt         ;move minInt to EAX
    mov ECX, prevInt        ;move prevInt to ECX
    mul ECX                 ;EAX = minInt * prevInt
    mov EBX, maxInt         ;move maxInt to EBX
    div EBX                 ;EAX = (min*prev) / max
    mov prevInt, EDX        ;EDX holds remainder from divison
    mov EAX, EDX            ;move random number to EAX
    call WriteInt           ;write random number
    INC count               ;increment count
    .IF count < timesInt    ;if count < timesInt continue
         LOOP L1            ;jump to L1
    .ENDIF                  ;end IF

    invoke ExitProcess,0    ;exit process
  main endp
  end main
谢谢你的时间,

伊恩

1 个答案:

答案 0 :(得分:1)

根据Operators Reference的关系运算符是

EQ等于
GE大于或等于
GT大于
LE小于或等于
LT低于
NE不等于

我建议将<更改为LT,这样可以解决您的问题。