0

I am very new to MASM and am having trouble with an if statement. The compilation error I get is: RNG.asm(61) : error A2070: invalid instruction operands. (line 61 is five up from the bottom)

here is my code:

;=====================================================================
; 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

thank you for your time,

Ian

rkhb
  • 14,159
  • 7
  • 32
  • 60
still learning
  • 157
  • 2
  • 14

1 Answers1

1

The relational operators according to Operators Reference are

EQ for equal
GE for greater than or equal
GT for greater than
LE for less than or equal
LT for less than
NE for not equal

I'd suggest changing the < to LT and that should fix your problem.

Magoo
  • 77,302
  • 8
  • 62
  • 84