Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In Assembly, write and test a MASM program to perform the following tasks using Irvine 3 2 - Implement and test two * * macros

In Assembly, write and test a MASM program to perform the following tasks using Irvine32
- Implement and test two**macros**for string processing. These macros should use Irvines**`ReadString`**to get input from the user, and**`WriteString`**procedures to display output.
-**`mGetString`**: Display a prompt*(input parameter, by reference*), then get the users keyboard input into a memory location*(output parameter, by reference*). You may also need to provide acount*(input parameter, by value)*for the length of input string you can accommodate and a provide a number of bytes read (*output parameter, by reference)*by the macro.
-**`mDisplayString`**: Print the string which is stored in a specified memory location*(input parameter, by reference*).
- Implement and test two**procedures**for signed integers which use string primitive instructions
-**`ReadVal`**:
1. Invoke the**`mGetString`**macro (see parameter requirements above) to get user inputin the form of a string of digits.
2. Convert (using string primitives) the string of ascii digits to its numeric value representation (SDWORD), validating the users input is a valid number (no letters, symbols, etc).
3. Store this one value in a memory variable*(output parameter, by reference).*
-**`WriteVal`**:
1. Convert a numeric SDWORD value*(input parameter, by value*)**to a string of ASCII digits.
2. Invoke the**`mDisplayString`**macro to print the ASCII representation of the SDWORD value to the output.
- Write a test program (in**`main`**) which uses the**`ReadVal`**and**`WriteVal`**procedures above to:
1. Get 10 valid integers from the user. Your**`ReadVal`**will be called within the loop in**`main`**. Do not put your counted loop within**`ReadVal`**.
2. Stores these numeric values in an array.
3. Display the integers, their sum, and their truncated average.
-**`ReadVal`**will be called within the loop in**`main`**. Do not put your counted loop within**`ReadVal`**.
Program Requirements:
1. Users numeric input**must**be validated the hard way:
1. Read the user's input as a string andconvert the string to numeric form.
2. If the user enters non-digits other than something which will indicate sign (e.g.+ or -), or the number is too large for 32-bit registers, an error message should be displayed and the number should be discarded.
3. If the user enters nothing (empty input), display an error and re-prompt.
2.**`ReadInt`**,**`ReadDec`**,**`WriteInt`**, and**`WriteDec`**are**not allowed**in this program.
3.**`mDisplayString`**must be used to display all strings.
4. Conversion routines**must**appropriately use the**`LODSB`**and/or**`STOSB`**operators for dealing with strings.
5. All procedure parameters**must**be passed on the runtime stack using the**STDCall**calling convention. Strings also**must**be passed by reference.
6. Prompts, identifying strings, and other memory locations**must**be passed by address to the macros.
7. Used registers**must**be saved and restored by the called procedures and macros.
8. The stack frame**must**be cleaned up by the**called**procedure.
9. Procedures (except**`main`**)**must not**reference data segment variables by name.There is a**significant**penalty attached to violations of this rule. Some global constants (properly defined using EQU, =, or TEXTEQU and not redefined) are allowed. These**must**fit the proper role of a constant in a program (master values used throughout a program which, similar to**`HI`**and**`LO`**in Project 5).
10. The program**must**use*Register Indirect*addressing or string primitives (e.g. STOSD) for integer (SDWORD) array elements, and*Base+Offset*addressing for accessing parameters on the runtime stack.
11. Procedures**may**use local variables when appropriate.
Notes:
1. For this assignment you are allowed to assume that the total sum (and all pre-total sums) of the valid numbers will fit inside a 32 bit signed register.
2. We will be testing this program with positive***and***negative values.
3. When displaying the average, only display the integer part (that is, drop/truncate any fractional part).
Please provide 10 signed decimal integers.
Each number needs to be small enough to fit inside a 32 bit register. After you have finished inputting the raw numbers I will display a list of the
integers, their sum, and their average value.
You entered the following numbers:
156,34,-186,-145,16,23,51,0,56,11
The sum of these numbers is: 16
The truncated average is: 1
Thanks for playing!
image text in transcribed

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

Step: 3

blur-text-image

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

Advanced MySQL 8 Discover The Full Potential Of MySQL And Ensure High Performance Of Your Database

Authors: Eric Vanier ,Birju Shah ,Tejaswi Malepati

1st Edition

1788834445, 978-1788834445

More Books

Students also viewed these Databases questions

Question

Write formal proposal requests.

Answered: 1 week ago

Question

Assessment of skills and interests.

Answered: 1 week ago

Question

Psychological, financial, and career counseling.

Answered: 1 week ago