Here is my code for random number. I want to print random numbers in a loop or to call random numbers many time in a program. How can I get different value for each procedure call? Below program print same value for each call.
.model small
.stack 100
.data
var1 db 0
.code
main proc
; First call
call random
mov al,var1
mov ah,02h
int 21h
; Second call
call random
mov al,var1
mov ah,02h
int 21h
;Third call
call random
mov al,var1
mov ah,02h
int 21h
mov ah,4ch
int 21h
MAIN ENDP
;Random number procedure
random proc
MOV AH, 00h ; interrupts to get system time
INT 1AH ; CX:DX now hold number of clock ticks since midnight
mov ax, dx
xor dx, dx
mov cx, 5 ;Ending
div cx ; here dx contains the remainder of the division - from 0 to 9
add dl, '1' ; start--to ascii from '0' to '9'
mov var1,al
;mov ah, 2h ; call interrupt to display a value in DL
;int 21h
ret
random endp
END MAIN