[求助]汇编--醉汉走路
INCLUDE Irvine32.inc walkmax=50 //一共走50步
startX=25 //初始坐标
startY=25
Walk STRUCT //定义结构体
path COORD walkmax DUP(<0,0>)
pathused word 0
Walk ENDS
DisPlayPosition PROTO currX:WORD,currY:WORD //输出当前坐标
.data
awalk Walk <>
.code
main PROC
mov esi,OFFSET awalk
call TakeWalk
exit
main ENDP
TakeWalk PROC //走路
Local currX:WORD,currY:WORD
pushad
mov edi,esi
add edi,OFFSET Walk.path
mov ecx,walkmax
mov currX,startX
mov currY,startY
L1:
mov ax,currX
mov (COORD PTR [edi]).X,ax
mov ax,currY
mov (COORD PTR [edi]).Y,ax
INVOKE DisPlayPosition,currX,currY
mov eax,4 //判断方向
call RandomRange
.IF eax==0 ;东
inc currX
.ELSEIF eax==1 ;西
dec currX
.ELSEIF eax==2 ;南
inc currY
.ELSE ;北
dec currX
.ENDIF
add edi,TYPE COORD
loop L1
mov awalk.pathused,walkmax
popad
ret
TakeWalk ENDP
DisPlayPosition PROC currX:WORD,currY:WORD //输出当前坐标
.data
fuhao BYTE ",",0
.code
pushad
mov edx,OFFSET fuhao
movzx eax,currX
call WriteDec
call WriteString
movzx eax,currY
call WriteDec
call Crlf
popad
ret
DisPlayPosition ENDP
END main
我的程序每次执行后输出的内容都是一样的,我想可能是Random引起的,我想知道怎样让它每次输出的内容都
不一样,谁告诉下谢谢.