title: Generating random numbers in assembly
body: <p>I am new to assembly, and I am having problems generating random numbers.</p>
  
  <p>My code is simple: it generates 100 numbers in the <code>0-25</code> range and stores them in an array.</p>
  
  <p>The problem I am experiencing is that when I run the con on the <code>emu8086</code> assembler it runs successfully and generates 100 random numbers, that are stored in the array. But when I run it on the <code>masm611</code>, it generates a new random number every 4 cycles. Which means the values in the array are consecutive same number for 4 values and then next random value is stored.</p>
  
  <p>Here is my code:</p>
  
  <pre><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
  </code></pre>
  
  <p>Is there is a problem in my code? Do I need to add something? Thanks.</p>