Question

In: Computer Science

In Assembly Language (Visual Studio 2017), create a procedure that generates a random string of Length...

In Assembly Language (Visual Studio 2017), create a procedure that generates a random string of Length L, containing all capital letters. When calling the procedure, pass the value of L in EAX, and pass a pointer to an array of byte that will hold the random string. Write a test program that calls your procedure 20 times and displays the strings in the console window. In your program, the random string size shall be preset as a constant.

Please include output.

Objectives:

  1. Write user defined procedures
  2. Call and test user defined procedures
  3. Use Irvine.inc library to take input and display output. (INCLUDE Irvine32.inc)

How to See Result

You may notice that your console window will show up then quickly disappear. You have two ways to view your result from console window. One way is to set the break point at exit statement in main procedure. Another way is to add the following statement before exit statement in main procedure:

Call ReadChar

This will hold the console window to wait for your input. You can hit any key to close the console window. It is better if you add a prompt to tell user what to do. For instance: “Press any key to continue…”. To do so, you simply add

prompt BYTE “Press any key to continue…”, 0

in your .data section and add the following code before Call ReadChar:

move dx, OFFSET prompt

Call WriteString

Solutions

Expert Solution

.LC0:

.string "Before swapping"

.LC1:

.string "a = "

.LC2:

.string "b = "

.LC3:

.string "\nAfter swapping"

main:

push rbp

mov rbp, rsp

sub rsp, 16

mov DWORD PTR [rbp-4], 1

mov DWORD PTR [rbp-8], 2

mov esi, OFFSET FLAT:.LC0

mov edi, OFFSET FLAT:std::cout

call std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)

mov esi, OFFSET FLAT:std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&)

mov rdi, rax

call std::basic_ostream<char, std::char_traits<char> >::operator<<(std::basic_ostream<char, std::char_traits<char> >& (*)(std::basic_ostream<char, std::char_traits<char> >&))

mov esi, OFFSET FLAT:.LC1

mov edi, OFFSET FLAT:std::cout

call std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)

mov rdx, rax

mov eax, DWORD PTR [rbp-4]

mov esi, eax

mov rdi, rdx

call std::basic_ostream<char, std::char_traits<char> >::operator<<(int)

mov esi, OFFSET FLAT:std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&)

mov rdi, rax

call std::basic_ostream<char, std::char_traits<char> >::operator<<(std::basic_ostream<char, std::char_traits<char> >& (*)(std::basic_ostream<char, std::char_traits<char> >&))

mov esi, OFFSET FLAT:.LC2

mov edi, OFFSET FLAT:std::cout

call std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)

mov rdx, rax

mov eax, DWORD PTR [rbp-8]

mov esi, eax

mov rdi, rdx

call std::basic_ostream<char, std::char_traits<char> >::operator<<(int)

mov esi, OFFSET FLAT:std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&)

mov rdi, rax

call std::basic_ostream<char, std::char_traits<char> >::operator<<(std::basic_ostream<char, std::char_traits<char> >& (*)(std::basic_ostream<char, std::char_traits<char> >&))

lea rdx, [rbp-8]

lea rax, [rbp-4]

mov rsi, rdx

mov rdi, rax

call swap(int&, int&)

mov esi, OFFSET FLAT:.LC3

mov edi, OFFSET FLAT:std::cout

call std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)

mov esi, OFFSET FLAT:std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&)

mov rdi, rax

call std::basic_ostream<char, std::char_traits<char> >::operator<<(std::basic_ostream<char, std::char_traits<char> >& (*)(std::basic_ostream<char, std::char_traits<char> >&))

mov esi, OFFSET FLAT:.LC1

mov edi, OFFSET FLAT:std::cout

call std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)

mov rdx, rax

mov eax, DWORD PTR [rbp-4]

mov esi, eax

mov rdi, rdx

call std::basic_ostream<char, std::char_traits<char> >::operator<<(int)

mov esi, OFFSET FLAT:std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&)

mov rdi, rax

call std::basic_ostream<char, std::char_traits<char> >::operator<<(std::basic_ostream<char, std::char_traits<char> >& (*)(std::basic_ostream<char, std::char_traits<char> >&))

mov esi, OFFSET FLAT:.LC2

mov edi, OFFSET FLAT:std::cout

call std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)

mov rdx, rax

mov eax, DWORD PTR [rbp-8]

mov esi, eax

mov rdi, rdx

call std::basic_ostream<char, std::char_traits<char> >::operator<<(int)

mov esi, OFFSET FLAT:std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&)

mov rdi, rax

call std::basic_ostream<char, std::char_traits<char> >::operator<<(std::basic_ostream<char, std::char_traits<char> >& (*)(std::basic_ostream<char, std::char_traits<char> >&))

mov eax, 0

leave

ret

swap(int&, int&):

push rbp

mov rbp, rsp

mov QWORD PTR [rbp-24], rdi

mov QWORD PTR [rbp-32], rsi

mov rax, QWORD PTR [rbp-24]

mov eax, DWORD PTR [rax]

mov DWORD PTR [rbp-4], eax

mov rax, QWORD PTR [rbp-32]

mov edx, DWORD PTR [rax]

mov rax, QWORD PTR [rbp-24]

mov DWORD PTR [rax], edx

mov rax, QWORD PTR [rbp-32]

mov edx, DWORD PTR [rbp-4]

mov DWORD PTR [rax], edx

nop

pop rbp

ret

__static_initialization_and_destruction_0(int, int):

push rbp

mov rbp, rsp

sub rsp, 16

mov DWORD PTR [rbp-4], edi

mov DWORD PTR [rbp-8], esi

cmp DWORD PTR [rbp-4], 1

jne .L6

cmp DWORD PTR [rbp-8], 65535

jne .L6

mov edi, OFFSET FLAT:std::__ioinit

call std::ios_base::Init::Init()

mov edx, OFFSET FLAT:__dso_handle

mov esi, OFFSET FLAT:std::__ioinit

mov edi, OFFSET FLAT:std::ios_base::Init::~Init()

call __cxa_atexit

.L6:

nop

leave

ret

_GLOBAL__sub_I_main:

push rbp

mov rbp, rsp

mov esi, 65535

mov edi, 1

call __static_initialization_and_destruction_0(int, int)

pop rbp

ret


Related Solutions

MUST BE WRITTEN IN ASSEMBLY LANGUAGE ONLY AND MUST COMPILE IN VISUAL STUDIO You will write...
MUST BE WRITTEN IN ASSEMBLY LANGUAGE ONLY AND MUST COMPILE IN VISUAL STUDIO You will write a simple assembly language program that performs a few arithmetic operations. This will require you to establish your programming environment and create the capability to assemble and execute the assembly programs that are part of this course. Your \student ID number is a 7-digit number. Begin by splitting your student ID into two different values. Assign the three most significant digits to a variable...
USING VISUAL STUDIO 2017, LANGUAGE VISUAL C# I have struggled on this program for quite some...
USING VISUAL STUDIO 2017, LANGUAGE VISUAL C# I have struggled on this program for quite some time and still can't quite figure it out. I'm creating an app that has 2 textboxes, 1 for inputting customer name, and the second for entering the number of tickets the customer wants to purchase. There are 3 listboxes, the first with the days of the week, the second with 4 different theaters, and the third listbox is to display the customer name, number...
Please write in x86 Assembly language on Visual Studio Write a program to compare two strings...
Please write in x86 Assembly language on Visual Studio Write a program to compare two strings in locations str1 and str2. Initialize str1 to Computer and initialize str2 to Compater. Assume Str1 holds the correct spelling and str2 may have an incorrect spelling. Use string instructions to check if str2 is correct and if not correct the mistake in str2.
Please write in x86 Assembly language on Visual Studio. IRVINE32 Write a program to copy one...
Please write in x86 Assembly language on Visual Studio. IRVINE32 Write a program to copy one array of size 24 to another array of size 24 using string instructions. Write 3 versions of this code. One code must copy byte at a time. One code must copy word at a time and one code must copy double word at a time. Cut and paste the array in memory to show your code is working.
Please use assembly language x86 Visual Studio Write a program to add the following word size...
Please use assembly language x86 Visual Studio Write a program to add the following word size numbers:15F2, 9E89, 8342, 99FF, 7130 using adc instruction and a loop. The result must be in DX, AX. Show the result in debug window.
Create a question bank. The language is visual studio c++. Description: Question bank computerizes the MCQ...
Create a question bank. The language is visual studio c++. Description: Question bank computerizes the MCQ based exams.It takes input from a file having questions and their answers and presents randomly before the exam takers. Required skill set: OOP, STL(Vector), Arrays and file handling
Assembly Language Visual Studio. Problem 1 College Registration Using the College Registration example from Section 6.7.3...
Assembly Language Visual Studio. Problem 1 College Registration Using the College Registration example from Section 6.7.3 (textbook) as a starting point, do the following: 1. Recode the logic using CMP and conditional jump instructions (instead of the .IF and .ELSEIF directives). 2. Perform range checking on the credits value; it cannot be less than 1 or greater than 30. If an invalid entry is discovered, display an appropriate error message. 3. Prompt the user for the grade average and credits...
In Assembly Language Write a program that generates 10 random numbers (0~99). Save the numbers into...
In Assembly Language Write a program that generates 10 random numbers (0~99). Save the numbers into arrayInt and calculate the sum. .data arrayInt Byte 10 DUP(?) Displays the array and the sum as follows: The random numbers are: xx xx xx xx xx xx …. The sum is   xxxx
Make a Program in Visual Studio / Console App (.NET Framework) # language Visual Basic You...
Make a Program in Visual Studio / Console App (.NET Framework) # language Visual Basic You will be simulating an ATM machine as much as possible Pretend you have an initial deposit of 1000.00. You will Prompt the user with a Main menu: Enter 1 to deposit Enter 2 to Withdraw Enter 3 to Print Balance Enter 4 to quit When the user enters 1 in the main menu, your program will prompt the user to enter the deposit amount....
In Assembly Language MASM Write a program that generates 10 random numbers (0~99). Save the numbers...
In Assembly Language MASM Write a program that generates 10 random numbers (0~99). Save the numbers into arrayInt and calculate the sum. .data arrayInt Byte 10 DUP(?) Displays the array and the sum as follows: The random numbers are: xx xx xx xx xx xx …. The sum is   xxxx
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT