我是装配新手,我在生成随机数时遇到问题.
我的代码很简单:它在0-25范围内生成100个数字并将它们存储在一个数组中.
我遇到的问题是,当我在emu8086汇编程序上运行con时,它成功运行并生成100个随机数,这些数字存储在数组中.但是当我在masm611上运行它时,它会每4个周期生成一个新的随机数.这意味着数组中的值对于4个值是连续相同的数字,然后存储下一个随机值.
这是我的代码:
.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
我的代码中有问题吗?我需要添加一些东西吗?谢谢.