Question: For Assembly (MASM 32-bit using VS17 Community)... So I want to generate a random string, in which the length of the string is defined by
For Assembly (MASM 32-bit using VS17 Community)...
So I want to generate a random string, in which the length of the string is defined by the user (n).
Using Randomize and RandomRange from the Irvine32 library, I want to generate random numbers within the range displayed on the ASCII table for uppercase letters (65-90).
After that, I want to create another procedure called StringPrint (which uses writechar) to convert and output into string chars.
This is the code I have so far...
| INCLUDE c:\Irvine\Irvine32.inc ExitProcess proto,dwExitCode:dword .data prompt byte "Please enter a number between 1 and 50: ",0dh,0ah,0 prompt2 byte "The generated string is... ",0dh,0ah,0 space byte " ",0 n dword ? rangeup dword ? .code main proc mov ebx, 65 mov eax, 90 mov rangeup, eax mov edx, offset prompt call WriteString call ReadInt mov n, eax call Crlf mov edx, offset prompt2 call WriteString call Randomize mov ecx, n L1: pushad ;//save all 32bit registers call GenerateNumbers call WriteInt mov edx, offset space call WriteString popad ;//restore all 32bit registers loop L1 call Crlf call Crlf invoke ExitProcess, 0 main endp GenerateNumbers proc add rangeup, ebx call randomrange sub rangeup, ebx ret GenerateNumbers endp end main |
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
