Question

In MIPS / MARS Be able to input to display your name and show how many...

In MIPS / MARS

Be able to input to display your name and show how many hours you worked this week, hourly wage.

Example:

Please enter your name: John Doe

You entered: John Doe

Please enter number of hours worked: 40

You entered: 40

Please enter your hourly wage: $15

You entered: $15

Your paycheck is $600 for the week.

Homework Answers

Answer #1

Code-

===================================================================

.data
name_prompt:
   .asciiz   "Please enter your name: "
hours_prompt:
.asciiz "Please enter number of hours worked: "
rate_prompt:
.asciiz "Please enter your hourly wage: $"
message:
   .asciiz   "You entered: "
rate_message:
   .asciiz   "You entered: $"
paycheck_1:
.asciiz "Your paycheck is $"
paycheck_2:
.asciiz " for the week."
name:
   .space   20  

.text
main:
   #Print name_prompt
   li $v0, 4
   la $a0, name_prompt
   syscall

   #Read name
   li $v0, 8
   la $a0, name
   li $a1, 40
   syscall

   #Print message
   li $v0, 4
   la $a0, message
   syscall

   #Print name
   li $v0, 4
   la $a0, name
   syscall
  
   #Print hours_prompt
   li $v0, 4
   la $a0, hours_prompt
   syscall
  
   #Reading Hours
   li $v0, 5
   syscall
  
   #Storing hours worked in $t0
   move $t0, $v0
  
   #Print message
   li $v0, 4
   la $a0, message
   syscall

#Printing the hours worked
li $v0, 1
move $a0, $t0
syscall
  
#Storing hours worked in $t0 again for later multiplication
move $t0, $a0
  
#Print rate_prompt
   li $v0, 4
   la $a0, rate_prompt
   syscall
  
   #Reading rate
   li $v0, 5
   syscall
  
   #Storing rate or hourly wage in $t1
   move $t1, $v0
  
   #Print message
   li $v0, 4
   la $a0, rate_message
   syscall

#Printing the hours worked
li $v0, 1
move $a0, $t1
syscall
  
#Storing hours worked in $t1 again for later multiplication
move $t0, $a0
  
#calculating paycheck by multiplying hourly wage and hours worked
mult $t0, $t1
mflo $s0
  
#Printing paycheck line 1
li $v0, 4
   la $a0, paycheck_1
   syscall
  
   #Printing calculated paycheck
   li $v0, 1
   add $a0, $zero, $s0
   syscall
  
   #Printing remaining paycheck line
li $v0, 4
   la $a0, paycheck_2
   syscall
  
#Telling system that the main is ended here
   li $v0, 10
   syscall

=============================================================

mflo means move from low register as mult stores the result in one of the two registers lo and hi and you can store result from the registers to another register to be used later

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Description Write a program that reads in the name, hourly rate and number of hours worked...
Description Write a program that reads in the name, hourly rate and number of hours worked for 5 people. Print the name of each person, the number of hours worked, their weekly pay based on the number of hours they worked and how much they owe in taxes. Assume that taxes take 20% of the paycheck. Don’t forget to take the taxes out of the pay check. If they work more than 40 hours they get overtime. The hourly rate...
Create a function in MIPS using MARS to determine whether a user input string is a...
Create a function in MIPS using MARS to determine whether a user input string is a palindrome or not. Assume that the function is not part of the same program that is calling it. This means it would not have access to your .data segment in the function, so you need to send and receive information from the function itself. The program should be as simple as possible while still using necessary procedures. Follow the instructions below carefully. Instructions: ●...
Prepare a worksheet that allows the user to enter ONLY these fields: Start Time and End Time per day...
Prepare a worksheet that allows the user to enter ONLY these fields: Start Time and End Time per day on a 5 day workweek (10 cells) and Hourly Wage (1 cell), Total Hours Worked (1 cell), and Total Earnings (1 cell). So there should ONLY be 13 data entry fields for the user.  Each of those fields should have a title, so there should be an additional 13 title cells explaining each data cell. Make sure that the title fields are properly labeled. So, there should be 26 cells used in total.  The user will...
Create a C# application You are to create a class object called “Employee” which included eight...
Create a C# application You are to create a class object called “Employee” which included eight private variables: firstN lastN dNum wage: holds how much the person makes per hour weekHrsWkd: holds how many total hours the person worked each week. regHrsAmt: initialize to a fixed amount of 40 using constructor. regPay otPay After going over the regular hours, the employee gets 1.5x the wage for each additional hour worked. Methods:  constructor  properties  CalcPay(): Calculate the regular...
MIPS ASSEMBLY Have the user input a string and then be able to make changes to...
MIPS ASSEMBLY Have the user input a string and then be able to make changes to the characters that are in the string until they are ready to stop. We will need to read in several pieces of data from the user, including a string and multiple characters. You can set a maximum size for the user string, however, the specific size of the string can change and you can’t ask them how long the string is (see the sample...
Please make sure to display your thought process? It is imperative to be able to follow...
Please make sure to display your thought process? It is imperative to be able to follow how the answer was deduced. Please be as thorough as possible. Please address all parts of this question. A recent social survey asked the following question sent to a random sample of 1,500 Americans: “After an average workday, how many hours do you have [at your disposal] to relax?” According to the study, the average relaxation time was 1.65 hours per day. Determine the...
Part A. Input Validation (Name your C program yourLastName_yourFirstName_Lab4a.c) 1. Place the code you developed in...
Part A. Input Validation (Name your C program yourLastName_yourFirstName_Lab4a.c) 1. Place the code you developed in Lab 2 to obtain a diameter value from the user and compute the volume of a sphere (we assumed that to be the shape of a balloon) in a new program, and implement the following restriction on the user’s input: the user should enter a value for the diameter which is at least 8 inches but not larger than 60 inches. Using an if-else...
Problem: A company wants a program that will calculate the weekly paycheck for an employee based...
Problem: A company wants a program that will calculate the weekly paycheck for an employee based on how many hours they worked. For this company, an employee earns $20 an hour for the first 40 hours that they work. The employee earns overtime, $30 an hour, for each hour they work above 40 hours. Example: If an employee works 60 hours in a week, they would earn $20/hr for the first 40 hours. Then they would earn $30/hr for the...
Note: In this chapter and in all succeeding work throughout the course, unless instructed otherwise, calculate...
Note: In this chapter and in all succeeding work throughout the course, unless instructed otherwise, calculate hourly rates and overtime rates as follows: 1. Carry the hourly rate and the overtime rate to 3 decimal places and then round off to 2 decimal places (round the hourly rate to 2 decimal places before multiplying by one and one-half to determine the over-time rate). 2. If the third decimal place is 5 or more, round to the next higher cent. 3....
Kipley Company is a small manufacturing firm located in Pittsburgh, Pennsylvania. The company has a workforce...
Kipley Company is a small manufacturing firm located in Pittsburgh, Pennsylvania. The company has a workforce of both hourly and salaried employees. Each employee is paid for hours actually worked during each week, with the time worked being recorded in quarter-hour increments. The standard workweek consists of 40 hours, with all employees being paid time and one-half for any hours worked beyond the 40 regular hours. Wages are paid every Friday, with one week's pay being held back by the...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT