Answered step by step
Verified Expert Solution
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 Irvine
Implement and test twomacrosfor string processing. These macros should use IrvinesReadStringto get input from the user, andWriteStringprocedures to display output.
mGetString: Display a promptinput parameter, by reference then get the users keyboard input into a memory locationoutput parameter, by reference You may also need to provide acountinput parameter, by valuefor the length of input string you can accommodate and a provide a number of bytes read output parameter, by referenceby the macro.
mDisplayString: Print the string which is stored in a specified memory locationinput parameter, by reference
Implement and test twoproceduresfor signed integers which use string primitive instructions
ReadVal:
Invoke themGetStringmacro see parameter requirements above to get user inputin the form of a string of digits.
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
Store this one value in a memory variableoutput parameter, by reference
WriteVal:
Convert a numeric SDWORD valueinput parameter, by valueto a string of ASCII digits.
Invoke themDisplayStringmacro to print the ASCII representation of the SDWORD value to the output.
Write a test program inmain which uses theReadValandWriteValprocedures above to:
Get valid integers from the user. YourReadValwill be called within the loop inmain Do not put your counted loop withinReadVal
Stores these numeric values in an array.
Display the integers, their sum, and their truncated average.
ReadValwill be called within the loop inmain Do not put your counted loop withinReadVal
Program Requirements:
Users numeric inputmustbe validated the hard way:
Read the user's input as a string andconvert the string to numeric form.
If the user enters nondigits other than something which will indicate sign eg or or the number is too large for bit registers, an error message should be displayed and the number should be discarded.
If the user enters nothing empty input display an error and reprompt.
ReadIntReadDecWriteInt andWriteDecarenot allowedin this program.
mDisplayStringmust be used to display all strings.
Conversion routinesmustappropriately use theLODSBandorSTOSBoperators for dealing with strings.
All procedure parametersmustbe passed on the runtime stack using theSTDCallcalling convention. Strings alsomustbe passed by reference.
Prompts, identifying strings, and other memory locationsmustbe passed by address to the macros.
Used registersmustbe saved and restored by the called procedures and macros.
The stack framemustbe cleaned up by thecalledprocedure
Procedures exceptmainmust notreference data segment variables by name.There is asignificantpenalty attached to violations of this rule. Some global constants properly defined using EQU, or TEXTEQU and not redefined are allowed. Thesemustfit the proper role of a constant in a program master values used throughout a program which, similar toHIandLOin Project
The programmustuseRegister Indirectaddressing or string primitives eg STOSD for integer SDWORD array elements, andBaseOffsetaddressing for accessing parameters on the runtime stack.
Proceduresmayuse local variables when appropriate.
Notes:
For this assignment you are allowed to assume that the total sum and all pretotal sums of the valid numbers will fit inside a bit signed register.
We will be testing this program with positiveandnegative values.
When displaying the average, only display the integer part that is droptruncate any fractional part
Please provide signed decimal integers.
Each number needs to be small enough to fit inside a 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:
The sum of these numbers is:
The truncated average is:
Thanks for playing!
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started