Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need to convert the psudoinstruction ( the bolded code) to a simple mips code ____________________________________________________ .data num1: .word 0 num2: .word 0 answer: .asciiz

I need to convert the psudoinstruction ( the bolded code) to a simple mips code 

____________________________________________________

.data num1: .word 0 num2: .word 0 answer: .asciiz "The product is " prompt: .asciiz " Enter a positive number : " #prompt for string # add other strings at this point as needed

.text .globl main

main:

jal getpos # get a positive number for the loop

addi $s0, $v0, 0 # save input value

repeat:

beq $s0, $0, end # while there are more repeats

lui $a0, 0x1001 # get address of first word

addiu $a1, $a0, 4 # get address of second word

jal getinput # call function to get input, store into addresses

lui $t0, 0x1001 # get address of first word

lw $a0, 0($t0) # get the first value from memory

lw $a1, 4($t0) # get the second value from memory

jal multiply # multiply the values, result in $v0

addi $a0, $v0, 0 # get value to print from $v0

lui $a1, 0x1001 # get start of data section

addi $a1, $a1, 8 # get start of the product output string

jal print # print results

addi $s0, $s0, -1 # decrement counter

j repeat # do it agin

end: ori $v0, $0, 10 # set command to stop program,

syscall # end program

getpos : #get position loop until user not enter positive number

loop : #loop for input li $v0, 4 la $a0, prompt #prompt for string syscall li $v0,5 syscall #ask user input move $t1,$v0 sgt $t3,$t1,$zero beqz $t3,Else #check if equal zero go to zero j endIf #jump to end if Else : j loop endIf : move $v0,$t1 jr $ra #return value

getinput: #get two input and set result to given locations move $t7,$ra #store return address in t7 move $t6,$a0 #store address of a0 to t6 jal getpos # get a positive number for the loop addi $s1, $v0, 0 # save input value sw $s1,0($t6) #store at t6 that is a0 location jal getpos # get a positive number for the loop addi $s2, $v0, 0 # save input value sw $s2,0($a1) #store at location a1 move $ra,$t7 #move address from t7 back to ra jr $ra #return value

multiply: #multiply and return result mul $a0,$a0,$a1 move $v0,$a0 jr $ra print: move $t1,$a0 li $v0,4 la $a0,0($a1) #it will print message from address syscall move $a0,$t1 #it will print integer li $v0,1 syscall jr $ra

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Relational Database And Transact SQL

Authors: Lucy Scott

1st Edition

1974679985, 978-1974679980

More Books

Students also viewed these Databases questions

Question

2. What is the impact of information systems on organizations?

Answered: 1 week ago

Question

Evaluate the impact of technology on HR employee services.

Answered: 1 week ago