Question

Assembly Language For x86 Processors 7th edition When you write programs to solve the programming exercises,...

Assembly Language For x86 Processors 7th edition

When you write programs to solve the programming exercises, use multiple procedures when possible. Follow the style and naming conventions used in this book. Use explanatory comments in your programs at the beginning of each procedure and next to nontrivial statements.

Random Strings

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.

0 0
Add a comment Improve this question Transcribed image text
Answer #1
;Random Strings.

INCLUDE Irvine32.inc
TAB = 9                       ;ASCII code for Tab
strLen=10                     ;length of the string

.386
.model flat,stdcall
.stack 4096
ExitProcess PROTO, dwExitCode:DWORD

.data
str1 BYTE"The 20 random strings are:", 0
arr1 BYTE strLen DUP(?)

.code
main PROC
     mov ed x, OFFSET str1         ;"The c20 random strings are:"
     call WriteString              ;Writes string
     call Crlf                     ;Writes an end-of-line sequence to the console window.
     mov ecx,20                    ;Create 20 strings

 L1: mov esi,OFFSET arr1           ;ESI: array address
     mov eax,strLen                ;EAX: string length
     call RandomString             ;generates the random string
     call Display
     mov al,TAB
     call WriteChar                ;leaves a tab space
     exit
main ENDP

     RandomString PROC USES eax esi
     mov ecx,eax                   ;ECX = string length

L1:  mov eax, 26
     call RandomRange
     add eax,65                    ;EAX gets ASCII value of a capital letter
     mov arr1[esi],eax
     inc esi

     loop L1

     RandomString EXDP

     Display PROC USES eax esi     ;Displays the generated random string

     mov ecx,eax                   ;ECX=string length

L1:  mov eax, arr1[esi]            ;EAX = ASCII value
     call WriteChar                ;writes the letter

     inc esi

     loop L1

     Display ENDP


        call dumpregs

        INVOKE ExitProcess,0

END main
Add a comment
Know the answer?
Add Answer to:
Assembly Language For x86 Processors 7th edition When you write programs to solve the programming exercises,...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write this code using x86 assembly language using the irvine32 library

    Write this code using x86 assembly language using the irvine32 library Create a procedure that fills an array of doublewords with N random integers, making sure the values fall within the range j...k, inclusive. When calling the procedure, pass a pointer to the array that will hold the data, pass N, and pass the values of j and k. Preserve all register values between calls to the procedure. Write a test program that calls the procedure twice, using different values...

  • This is a question from Assembly Language for x86 7th Edition by Kip Irvine, but the...

    This is a question from Assembly Language for x86 7th Edition by Kip Irvine, but the solution is not there. Programming exercise 12.7 #2. The code must be in assembly language for Intel using Kip Irvine library. An example of the source code would be: INCLUDE Irvine32.inc .code main PROC mov ax,4000h mov bx,1000h mov cx,1500h sub ax,bx sub ax,cx call DumpRegs exit main ENDP END main Question: Write a procedure that receives a single-precision floating-point binary value and displays...

  • Assembly Language Programming Assignment program must be in: MASM assembly language / x86 architecture / irvine...

    Assembly Language Programming Assignment program must be in: MASM assembly language / x86 architecture / irvine library procedures Objectives: 1. using register indirect addressing 2. passing parameters 3. generating “random” numbers 4. working with arrays Description: Write and test a MASM program to perform the following tasks: 1. Introduce the program. 2. Generate ARRAYSIZE random integers in the range [LO = 10 .. HI = 29], storing them in consecutive elements of an array. ARRAYSIZE should be set to 200....

  • Needs Help with Java programming language For this assignment, you need to write a simulation program...

    Needs Help with Java programming language For this assignment, you need to write a simulation program to determine the average waiting time at a grocery store checkout while varying the number of customers and the number of checkout lanes. Classes needed: SortedLinked List: Implement a generic sorted singly-linked list which contains all of the elements included in the unsorted linked list developed in class, but modifies it in the following way: • delete the addfirst, addlast, and add(index) methods and...

  • Lab 6 Instructions Objectives: • Executing and experimenting with programs that handle array related topics such...

    Lab 6 Instructions Objectives: • Executing and experimenting with programs that handle array related topics such as declaration, initialization, storing, retrieving, and processing elements. • Effectively manipulating and using ArrayList objects. • Becoming familiar with the use of arrays as method arguments and how array elements are passed to and returned from the called method. • Mastering the use of various debugging tools available on the Eclipse IDU. Important: EVERY one of the following Activities MUST be in a separate...

  • Assignment Overview In Part 1 of this assignment, you will write a main program and several...

    Assignment Overview In Part 1 of this assignment, you will write a main program and several classes to create and print a small database of baseball player data. The assignment has been split into two parts to encourage you to code your program in an incremental fashion, a technique that will be increasingly important as the semester goes on. Purpose This assignment reviews object-oriented programming concepts such as classes, methods, constructors, accessor methods, and access modifiers. It makes use of...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT