DATAS SEGMENT ;此处输入数据段代码 arr db 200 dup(?) len db 0 time db 0 ni db 0 ; 线性同余法生成随机数 nii = (A * ni + B) % p nii db 0 p db 36 A db 13 B dw 24 ten db 10 one db 0 two db 0 DATAS ENDS DATASS segment message db 'illegal input' DATASS ENDS STACKS SEGMENT ;此处输入堆栈段代码 STACKS ENDS CODES SEGMENT ASSUME CS:CODES,DS:DATAS, ES:DATASS, SS:STACKS start: MOV AX, DATAS MOV DS, AX MOV AH, 2CH INT 21H MOV time, dl ; AH = 2CH号功能,得到系统时间,dl = 秒钟。 lea si, arr ; 所以第一个随机数的种子就是time,就是秒钟 ; 也就是ni = time,然后nii = (A * ni + B) % p + 1 xor ax, ax mov al, time div p inc ah mov al, ah inc al xor ah, ah mov ni, al mov nii, al inc len mov [si], al inc si div ten mov one, al add one, 48 mov two, ah add two, 48 ;******************output one two xor ax, ax mov ah, 02h mov dl, one int 21h mov ah, 02h mov dl, two int 21h mov ah, 02h mov dl, 20h int 21h ;******************output one two random: cmp len, 7 jz exit xor ax, ax mov al, ni mul A add ax, B div p inc ah ;00号 mov ni, ah xor ax, ax mov al, ni mov nii, al inc ni div ten mov one, al add one, 48 mov two, ah add two, 48 mov cl, len lea di, arr check: xor ax, ax mov al, [di] cmp al, nii jz random inc di loop check inc len mov al, ni mov [si], al inc si ;******************output one two xor ax, ax mov ah, 02h mov dl, one int 21h mov ah, 02h mov dl, two int 21h mov ah, 02h mov dl, 20h int 21h ;******************output one two jmp random exit: MOV AH, 4ch INT 21H CODES ENDS end start