我对 MASM 非常陌生,并且在使用 if 语句时遇到了麻烦。我得到的编译错误是:RNG.asm(61) : error A2070: invalid instruction operands。(第 61 行从下往上 5 个)
这是我的代码:
;=====================================================================
; 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
感谢您的时间,
伊恩