title: Assembly Language Random Number Generator
body: <p>I have recently started to learn assembly language. For a project I am working on I have to make a random number generator using linear congruence. I am suppose to take in three numbers. An upper bound, a lower bound and a number of how many random numbers I want. As for the formula for getting a random number I came up with.... </p>
  
  <p>randomNumber = (seed % (upper-lower) + lower)</p>
  
  <p>I then tried to put this into code. 
  I came up with this </p>
  
  <pre><code>.data
    upper BYTE 100      ;setting upper limit 100
    lower BYTE 0        ;setting lower limit 0
    number BYTE 5       ;number of random numbers
  
  .code
  call main
  exit
  
  main proc
  
     cls    
     mov bx,upper            ;moving upper bound into bx
     mov dx,lower            ;moving lower bound into dx
     mov ax,2914017          ;taking a random number for this trial
     mov ecx,number          ;setting the loop counter
  L1:
     sub bx,dx               ;(upper-lower)
     div bx               
     add ah,dx               ;(randomNumber mod (bx) + lower
  
  main endp
  </code></pre>
  
  <p>I am curious how I would print out the random number at the end of each loop cycle. And if the above code makes any sense.</p>
  
  <p>Thanks in advance!</p>