In: Computer Science
Using MIPS (MARS) - Assembly Language Assignment
( PLEASE USE COMMENTS TO DESCRIBE EACH STEP )
Take input of name,
the input of hours worked,
and input of hourly wage,
and use input of hourly wage and hours worked to calculate total paycheck and print Name,
and paycheck.
Please find the answer below.
Please do comments in case of any issue. Also, don't forget to rate
the question. Thank You So Much.
.data
prompt: .asciiz "Enter hours worked in a week: "
prompt2: .asciiz "Enter hourly wage rate in dollars: "
prompt3: .asciiz "\nThe total wage for the week is $"
prompt4: .asciiz "\nEnter your name : " #prompt for string
input: .space 300 #string butter of 300 digit
prompt5: .asciiz "\nHello " #prompt for string
.text
li $v0, 4
la $a0, prompt4 #prompt for input
syscall
li $v0, 8
la $a0, input #wait for input
li $a1, 100
syscall
li $v0,4
la $a0,prompt #it will print prompt
syscall
li $v0,5
syscall
move $s0,$v0 #store worked hours
li $v0,4
la $a0,prompt2 #it will print prompt
syscall
li $v0,5
syscall
move $s1,$v0 #store hour pay
li $t0,0 #store result
bgt $s0,40,greaterThanLimit
mul $t0,$s0,$s1
j exit
greaterThanLimit:
mul $t0,$s1,40
sub $s0,$s0,40
mul $s0,$s0,2
mul $s0,$s0,$s1
add $t0,$t0,$s0
exit:
li $v0, 4
la $a0, prompt5 #prompt for input
syscall
li $v0, 4
la $a0, input #prompt for input
syscall
li $v0,4
la $a0,prompt3 #it will print prompt
syscall
li $v0,1
move $a0,$t0 #store worked hours
syscall