I'm trying to create a procedure that generates a random string of length L, containing all capital letters. This procedure receives the length of the string (L) in EAX, and the pointer to a byte array in ESI where the random string will be saved. Returns the pointer to a byte array in ESI held the random string.
;.386
;.model flat,stdcall
;.stack 4096
;ExitProcess PROTO, dwExitCode:DWORD
INCLUDE Irvine32.inc
str_len = 10
.data
str_index BYTE str_len DUP(0), 0
.code
main proc
call Clrscr
mov esi, OFFSET str_index
call Randomize
mov ecx, 20
L1:
call Random32
call CreateRandomString
loop L1
invoke ExitProcess,0
main endp
CreateRandomString PROC
; Receives: Length of the string (L) in EAX, the pointer
; to a byte array in ESI where the random string will be saved
; Returns: Pointer to a byte array in ESI held the random string
;-----------------------------------------------------
mov ecx, LENGTHOF str_index
L2:
mov eax, 26
call RandomRange
add eax, 65
mov[esi], eax
call WriteChar
loop L2
call Crlf
ret
CreateRandomString ENDP
end main
This is my implementation so far which returns random strings so length 11. I'm a bit confused on how Randomize and Random32 work. I know the random value generated is stored in eax but how do I retrieve it, and how do I specify the range in which the value should be between (ex: between 1-100)? Thanks for the help in advance!