;***********************************************************************
;TITLE 生成20个随机数
;***********************************************************************
;***********************************************************************
;程序运行平台
.386
.MODEL FLAT,STDCALL
option casemap:none
;***********************************************************************
;***********************************************************************
;文件包含
INCLUDE Irvine32.inc
;***********************************************************************
;***********************************************************************
;宏定义
RANDOM_COUNT=20
;***********************************************************************
;***********************************************************************
;数据段定义
.data
rVal dword RANDOM_COUNT dup(0)
strEnter byte 0dh,0ah,0
;***********************************************************************
;***********************************************************************
;代码段定义
.code
;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;函数定义:生成0-40之间的随机数,然后减去20,变成-20~20之间的随机数,而后
; 输出随机数,同时输出换行
GenerateRandom proc uses ecx eax edx
mov eax,40
call RandomRange
sub eax,20
call WriteInt
;输出换行
mov edx, offset strEnter
call WriteString;
ret;
GenerateRandom endp
;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;函数定义:延时过程ffff*ffff
DelayProc proc uses ecx
mov ecx,0ffffh;
D2:
push ecx
D1: loopd D1;
pop ecx;
loopd D2;
ret;
DelayProc endp
;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
main proc
;生成随机数种子
call Randomize
;设置范围
mov ecx,RANDOM_COUNT
LProc:
call DelayProc;
call GenerateRandom
loopw LProc
exit
main endp
end main
标签:汇编,20,延时,+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
From: https://blog.51cto.com/u_15995156/6166910