Question: Objectives : Code and test simple assembly programs. Step1. Reverse a String Towson University with the following requirements: Use a loop with indexed addressing Push

Objectives: Code and test simple assembly programs.

Step1. Reverse a String Towson University with the following requirements:

Use a loop with indexed addressing

Push each character to the stack

Start at the beginning of the string, pop the stack in reverse order, insert each character back into the string

Insert the following lines to declare data:

strTU byte Towson University, 0

strSize = ($ - strTU) - 1

Insert the following lines to display a string:

edx,OFFSET

Writestring

Insert the following line to generate a new line:

crlf ; new-line creater

Prerequisite for Step2:

ReadString (from Irvine32 Library) The ReadString procedure reads a string from the keyboard, stopping when the user presses the Enter key. Pass the offset of a buffer in EDX and set ECX to the maximum number of characters the user can enter, plus 1 (to save space for the terminating null byte). The procedure returns the count of the number of characters typed by the user in EAX. Sample call:

.data

buffer BYTE 21 DUP(0) ; input buffer

byteCount DWORD ? ; holds counter

.code

mov edx,OFFSET buffer ; point to the buffer

mov ecx,SIZEOF buffer ; specify max characters

call ReadString ; input the string

mov byteCount,eax ; number of characters

ReadString automatically inserts a null terminator in memory at the end of the string. The following is a hexadecimal and ASCII dump of the first 8 bytes of buffer after the user has entered the string ABCDEFG:

41 42 43 44 45 46 47 00 ABCDEFG

The variable byteCount equals 7.

Step2. Extend Step1 to get a string from an user using ReadString procedure. Please comment out the declarations of variables used in Step1 rather than deleting them.

Step3. Write a program that does the following:

Assigns integer values to EAX, EBX, ECX, EDX, ESI, EDI, EBP

Use PUSHAD to push the general-purpose registers on the stack

Using a loop, your program should pop each integer from the stack and display it on the screen

Insert the following lines to display integers:

mov eax,

WriteDec ; load a decimal value currently stored in EAX register

crlf

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!