我必须创建一个从 27 到 58 的 100 个数字的随机范围,然后将 100 个位置中的所有数字相加得到总数。但是,当我这样做时,我得到一个随机数和九十九个 32。我到处搜索并尝试了可能的解决方案,但我得到相同的结果或随机垃圾。有人可以提供一些帮助吗?
INCLUDE irvine32.inc
.data
a DWORD 27
b DWORD 58
delta DWORD ?
source DWORD 100 DUP(?)
prompt BYTE "The sum of the 100 counts in array is ",0
.code
main PROC
Call Randomize
mov edi, 0
mov edi, OFFSET delta
mov esi, OFFSET source
mov eax, b
sub eax, a
inc eax
mov delta, eax
mov ecx, LENGTHOF source
mov eax, 0
L1:
mov eax, delta
call randomrange
add eax, a
mov source, eax
call writedec
mov al, " "
call writechar
loop L1
call crlf
call crlf
mov ecx, SIZEOF source
mov edx, OFFSET prompt
call writestring
l2:
add eax,[esi]
add esi, TYPE delta
call writedec
mov al, " "
call writechar
loop l2
exit
main ENDP
END main