Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Assambly programming In class Project & Homework Assignment. Create a menu for a program as shown below. (This will be done in class) Option 1

Assambly programming

In class Project & Homework Assignment. Create a menu for a program as shown below. (This will be done in class)

Option 1 will request a string from the user. This string may contain any character on the keyboard, both upper and lowercase letters (for now the strings are limited to a length of 50 characters.

Option 2 will convert all elements of the string to lower case.

Option 3 will remove all nonletter elements.

Option 4 will determine if the string is a palindrome.

Option 5 will display the string to the screen.

Option 6 exits the program.

If the user enters something other than 1 6 there should be an error displayed to the screen. We will develop the menu in class.

Your homework will be to complete the functionality of the program.

All the menu options dealing with strings require an offset to the input string to be passed to a procedure.

At the end of every string procedure, the original string will reflect the changes caused by a given option.

For example: If the user input string is : a#d A&B.

After Option 2 is executed: The string will look like : a#d a&b.

After Option 3 is executed: The string will look like : adab

There are no rules on the other that procedures are executed other than a string must be entered before any string modifications can take place. You must create your own procedures to copy a string, compare a string, convert a string to uppercase, clear a string. Use of Irvine Library functions to copy a string or compare a string is specifically not allowed for this program. You may only use the following Irvine Library string operations: ReadString and WriteString. All other nonstring Irvine Library procedures are available for your use. Do not use DumpRegs except for troubleshooting.

Menu 1. Enter a string

2. Convert the string to lower case

3. Remove all non-letter elements

4. Is it a palindrome?

5. Print the string

6. Quit

******** here is code in class**********

** Option 3, 4, and 5 please********

;// In class Homework 5

INCLUDE Irvine32.inc

maxStringLength = 51d

clearEAX TEXTEQU clearEBX TEXTEQU clearECX TEXTEQU clearEDX TEXTEQU clearESI TEXTEQU clearEDI TEXTEQU

.data

UserOption BYTE 0h theString BYTE maxStringLength DUP (0) theStringLength BYTE ? ;// user entered string length NOT the max length .code main PROC ;//clear registers

clearEAX clearEBX clearECX clearEDX clearESI clearEDi startHere: call DisplayMenu call ReadHex mov UserOption, al

;// Procedure selection process ;// setting up for future procedure calls. mov edx, OFFSET theString mov ecx, lengthof theString

opt1: cmp UserOption, 1 jne Opt2 call clrscr mov ecx, maxstringlength call option1 mov theStringLength, al jmp startHere

opt2: cmp UserOption, 2 jne Opt3 movzx ecxheStringLength call option2 jmp startHere

opt3: cmp UserOption, 3 jne Opt4 movzx ecx, theStringLength call clrscr call option3 jmp startHere

opt4: cmp UserOption, 5 jne Opt4 movzx ecx, theStringLength call option4 jmp startHere

opt5: cmp UserOption, 5 jne Opt6 movzx ecx, theStringLength call option5 jmp startHere

opt6: cmp UserOption, 6 je quitit call oops jmp startHere

quitit: exit main ENDP

displayMenu PROC uses EDX ;Description: Displays menu ;Receives: Nothing ;Returns: Nothing ; .data Menuprompt1 BYTE 'MAIN MENU', 0Ah, 0Dh, '=========', 0Ah, 0Dh, '1. Enter a string', 0Ah, 0Dh, '2. Convert the string to lower case', 0Ah, 0Dh, '3. Remove all non-letter elements', 0Ah, 0Dh, '4. Is the string a palindrome?', 0Ah, 0Dh, '5. Print the string', 0Ah, 0Dh, '6. Quit', 0Ah, 0Dh, 0h .code call clrscr mov edx, Offset Menuprompt1 call WriteString ret displayMenu ENDP

option1 Proc uses ecx ;//description : get string from user ;//receives: offset of string in edx, maxlength in ecx ;//returns: user entered string Offset not changed ;// length of string returned in eax .data

userPrompt1 byte "enter your string --> ", 0

.code push edx ;//save offset of string to stack mov edx, Offset userPrompt1 call writeString pop edx ;//restore offset of string call ReadString ;//get user input

ret option1 ENDP

option2 Proc uses edx ecx edi ;//Description : Converts all Capital Letters to lowercase ;//Receives: Offset of the string in edx ;// string length in ecx ;//Returns: Original string with all capital letters ;// converted to lower case

loop2: mov al, byte ptr [edx+edi] ;//grab element of string cmp al, 41h jb keepgoing cmp al, 5Ah ja keepgoing add al, 20h mov byte ptr [edx+edi], al keepgoing: inc edi loop loop2

ret option2 ENDP

option3 Proc

ret option3 ENDP

option4 Proc

ret option4 ENDP

option5 Proc

ret option5 ENDP

oops Proc USES EDX ;Description: Prints error message ;Receives nothing ;returns nothing .data Caption BYTE "*** Error ***",0 OopsMsg BYTE "You have chosen an invalid option!", 0ah, 0dh, 0

.code mov edx, Offset Caption mov edx, offset OopsMsg call msgBox ret Oops ENDP

END main

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

MongoDB Applied Design Patterns Practical Use Cases With The Leading NoSQL Database

Authors: Rick Copeland

1st Edition

1449340040, 978-1449340049

More Books

Students also viewed these Databases questions

Question

Explain the significance of employee selection.

Answered: 1 week ago

Question

2 What supply is and what affects it.

Answered: 1 week ago