Question: CS 5 0 8 Computer Organization and Design Spring 2 0 2 4 Assignment # 9 Subroutines, System Calls, Console I / O , Using
CS
Computer Organization and Design
Spring
Assignment #
Subroutines, System Calls, Console IO Using the Stack, Working with FloatingPoint Numbers
Due Date: Friday, April @ : PM
Read through the entire assignment before doing any work. Note the restriction on pseudoinstructions.
In this assignment, you will write an assembly language program to convert a temperature value given in Fahrenheit to Celsius. The formula to be implemented is CFtimes
The program will issue a prompt to the console requesting the user to enter a value for the Fahrenheit temperature. The entered value will be read via a system call in the main program and the calculation of the Celsius conversion is to be done in a subroutine that is called from the main program. Subsequently, the calculated value is to be output to the console with an appropriate message.
For guidance, here is an example of what the console should contain after the program runs:
The following values are to be defined in the data segment:
Ftemp float
Ctemp float
The value byte
The value byte
The value byte
Prompt for input string
Message for output string
The stack is to be used for passing the Fahrenheit value to the subroutine and for returning the calculated Celsius value back to the main program. Since only a single value is being passed, dynamic stack allocation should be implemented for this.
Both the Fahrenheit and the calculated Celsius values are to be stored in the allocated memory locations defined in the data segment.
Note: the only pseudoinstruction allowed in the program is the load address la instruction specifically for printing the strings to the console. All other instructions must be native nonpseudo instructions.
Document your program with the required header comments, register usage, and other comments in your program as necessary, especially those related to console IO subroutine and stack usage. Register usage must include all general purpose and floatingpoint registers used in the program.
What to submit on Blackboard:
A copy of your program as an assembly language program file asm
A screen shot or copypaste of the Run IO window contents showing the IO from your program.
Grading criteria:
Inclusion of the required header comments
and the register usage section points
Correct data definitions in the data segment as
described in the assignment points
Correct system calls for console IO points
Correct definition of subroutine and call from
main program points
Correct conversion of integers to floatingpoint values
and correct arithmetic calculation points
Correct use of stack for passing values points
Storing values to correct memory locations points
Use of appropriate comments in code points
Total points points
To help guide the development of your program, the following is a sequence of tasks required in the text segment:
define memory base address & load numeric values instructions
convert integers to floatingpoint instructions
system call to prompt user to enter a temperature in Fahrenheit. instructions
system call to read user input. instructions
Push return value onto the stack & store to memory. instructions
subroutine call to calculate temperature conversion. instruction
system call to output the conversion message. instructions
pop value from stack. instructions
system call to output converted value. instructions
exit program. instructions
In subroutine:
pop value from stack. instructions
perform calculation. instructions
push result onto the stack & store to memory. instructions
return from subroutine. instruction
This is a sequential program with no loops. There are also no branches. Each task listed above represents one or more instructions that execute in sequence as indicated. If implemented as specified above, the main program will consist of instructions and the subroutine will consist of instructions.
Note: the task list above indicates where it is appropriate to read values from and store values to memory. You dont have to follow this recommendation. Based on the data definitions, some values must be read as integers and converted to floatingpoint values before used in arithmetic operations as indicated.
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
