Question: CS 5 0 8 Computer Organization and Design Spring 2 0 2 4 Assignment # 9 Subroutines, System Calls, Console I / O , Using

CS 508
Computer Organization and Design
Spring 2024
Assignment #9
Subroutines, System Calls, Console I/O, Using the Stack, Working with Floating-Point Numbers
Due Date: Friday, April 26,2024 @ 11:59 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 C=(F-32)\times 59.
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:
F_temp (.float)
C_temp (.float)
The value 32(byte)
The value 5(byte)
The value 9(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 non-pseudo instructions.
Document your program with the required header comments, register usage, and other comments in your program as necessary, especially those related to console I/O, subroutine and stack usage. Register usage must include all general purpose and floating-point registers used in the program.
What to submit on Blackboard:
1. A copy of your program as an assembly language program file (.asm).
2. A screen shot or copy/paste of the Run I/O window contents showing the I/O from your program.
Grading criteria:
1. Inclusion of the required header comments
and the register usage section 5 points
2. Correct data definitions in the data segment as
described in the assignment 5 points
3. Correct system calls for console I/O 10 points
4. Correct definition of subroutine and call from
main program 10 points
5. Correct conversion of integers to floating-point values
and correct arithmetic calculation 10 points
7. Correct use of stack for passing values 10 points
8. Storing values to correct memory locations 5 points
9. Use of appropriate comments in code 5 points
Total points 60 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 (4 instructions)
convert integers to floating-point (3 instructions)
system call to prompt user to enter a temperature in Fahrenheit. (3 instructions)
system call to read user input. (2 instructions)
Push return value onto the stack & store to memory. (3 instructions)
subroutine call to calculate temperature conversion. (1 instruction)
system call to output the conversion message. (3 instructions)
pop value from stack. (2 instructions)
system call to output converted value. (2 instructions)
exit program. (2 instructions)
In subroutine:
pop value from stack. (2 instructions)
perform calculation. (3 instructions)
push result onto the stack & store to memory. (3 instructions)
return from subroutine. (1 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 25 instructions and the subroutine will consist of 9 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 floating-point values before used in arithmetic operations as indicated.
CS 5 0 8 Computer Organization and Design Spring

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!