Question: Program Description We had an intern working on our thermometer data storage and he messed it up . The readings are good, but the order
Program Description
We had an intern working on our thermometer data storage and he messed it up The readings are good, but the order is reversed. We need you to write us a efficient little MASM program to read in the temperature measurements from a file, and print them out with their order corrected! This program must perform the following tasks as always, be sure to check the Requirements section:
Implement and test three macros for IO These macros should use Irvines ReadString to get input from the user, and WriteString and WriteChar procedures to display output.
mGetString: Display a prompt input reference then get the users keyboard input into a memory location output reference You may also need to provide acount input value for the length of input string you can accommodate and provide a number of bytes read output value by the macro.mDisplayString: Print the string which is stored in a specified memory location input referencemDisplayChar: Print an ASCIIformatted character which is provided as an immediate or constant input; immediate, constant, or register
Implement and test the following two procedures which use string primitive instructions
ParseTempsFromString: parameters:fileBuffer reference input tempArray reference output
fileBuffer will contain a number TEMPSPERDAYCONSTANT of stringformatted integer values, separated by a delimiter. The DELIMITER must be defined as a character CONSTANT so that we can change it during testing.
TEMPSPERDAY should be initially set to DELIMITER should be initially set to the comma character
Convert using string primitives the string of asciiformatted numbers to their numeric value representations. Some values will be negative and others will be positive.Store the converted temperatures in an SDWORD array output parameter, by reference
WriteTempsReverse:parameters:tempArray reference input
Print an SDWORD integer array to the screen, separated by a CONSTANTdefined DELIMITERcharacterThe integers must be printed in the reverse order that they are stored in the array.Invoke the mDisplayChar macro to print the DELIMITER character.
Write a test program in main which uses the ParseTempsFromStringand WriteTempsReverseprocedures above to:
Invoke the mGetString macro see parameter requirements above to get a file name from the user.Open this file and read the contents into a file buffer BYTE array File formatting follows...
The file will contain a series of positive or negative ASCIIformat integers, separated by a DELIMITER.Each line of numbers will have TEMPSPERDAYvaluesThe last number of each line also has a DELIMITERafter it
Use ParseTempsFromString to parse the first line of temperature readings, convert them from ASCII to numeric value, and store the numeric values in an array.Use WriteTempsReverse to print the temperature values in the reverse order that they were stored in the file print to the terminal window Crazy interns!
Program Requirements
WriteInt may be used to print the SDWORD array.
mDisplayStringmust be used to display all strings.
Conversion routines must appropriately use the LODSB andor STOSB operators for dealing with strings.
You may not use ParseInteger or other similar prewritten procedures to parse the temperatures.
All procedure parameters must be passed on the runtime stack using the STDCall calling convention see Module Exploration Passing Parameters on the Stack Strings also must be passed by reference.
Prompts, identifying strings, and other memory locations must be passed by address to the macros.
Used registers must be saved and restored by the called procedures and macros.
The stack frame must be cleaned up by the called procedure.
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 nominally static values used throughout a program which may dictate its execution method, similar to MINTEMPand MAXTEMP in Project
The program must use Register Indirect addressing or string primitives eg STOSD for integer SDWORD array elements, and BaseOffset addressing for accessing parameters on the runtime stack.
Procedures may use local variables when appropriate.
I wrote a file but it never has the temperatures from the txt file, it always outputs etc...
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
