I am new to assembly and am having trouble generating random numbers.
My code is simple: it generates 100 numbers in a range 0-25and stores them in an array.
The problem I'm experiencing is that when running con in assembler, emu8086it starts up successfully and generates 100 random numbers that are stored in the array. But when I run it on masm611, it generates a new random number every 4 cycles. This means that the values ββin the array have the same serial number for 4 values, and then the next random value is written.
Here is my code:
.model small
.stack 100h
.data
range db 25
i db 0 ;iterator
arr db 15 dup(0) ; an array
.code
mov ax,@data
mov ds,ax
mov bx,offset arr ;getting the adress of the arr in bx
L1:
mov ah,2ch
int 21h
mov ah,0
mov al,dl ;using dl by seeing 2ch details
div range ; so the number is in range
mov [bx],ah ;ah has remainder as using 8 bits div and
inc bx ;moving to the next index
inc i
cmp i,100
jbe L1
mov ah,4ch ;returning control
int 21h
end
Is there a problem in my code? Do I need to add something? Thank.