;Use irvine.lib subroutines to generate random number ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; .model small .586 .stack 100h ;Set maximum stack size to 256 bytes ;; declare externally used subroutines extrn Writestring:proc, Crlf:proc, Clrscr:proc, Writeint:proc extrn Random_range:proc, Randomize:proc, Readint:proc .data msg1 db "Enter max value for random number: ", 0h msg2 db "32 Random numbers are: ",0h max dw 0 ; space for maximum value .code START: mov ax, @data ;ax <-- data segment start address mov ds, ax ;ds <-- initialize data segment register call Randomize ; initialize random number gen call clrscr ; clear screen mov dx, offset msg1 call Writestring ;prompt for number call Readint ; get decimal number mov max,ax ;save maximum value call Crlf mov dx, offset msg2 call Crlf mov cx,20h ; will print out 32 random numbers LP1: mov ax, max ;get maximum value call Random_range ; get random value, returns in AX mov bx, 10 ; print number as decimal number call Writeint call Crlf loop lp1 EXIT: mov ax, 4c00h ;ax <-- 4c DOS 21h program halt function int 21h ;DOS service interrupt END START