Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

(I do not understand why my Mips Assembly code is not working please help!!) I am using Qtspim to run my code. .data jnum: .word

(I do not understand why my Mips Assembly code is not working please help!!) I am using Qtspim to run my code.

.data jnum: .word 8 Num: .word 0,0,7,6,5,4,8,7 Max: .asciiz "max:" Min: .asciiz "min:" Average: .asciiz "avg:" Rema: .asciiz "/" Nextline: .asciiz " " Bye: .asciiz "Adios!" .text .global

main:

jal MaxIs jal MinIs

la $a0,Num lw $t4,jnum add $t0,$zero,$zero add $t3,$zero,$zero

loop: lw $t2,0($a0) add $t3,$t3,$t2 add $a0,$a0,4 addi $t0,$t0,1 slti $t1,$t0,9 bne $t1,$zero,loop div $t3,$t4 mfhi $t5 mflo $s6 li $v0,4 la $a0,Average syscall

li $v0,1 move $a0,$t5 syscall

li $v0,4 la $a0,rema syscall

li $v0,1 move $a0,$s6 syscall

li $v0,4 la $a0,Nextline syscall

li $v0,4 la $a0,Bye syscall

li $v0,10 syscall

.end main

MinIs: la $a0, lw $t4,0($a0) add $t0,$zero,$zero

loopa: slti $t1,$t0,4 beq $t1,$zero,print lw $t1,0($a0) add $a0,$a0,4 lw $t2,0($a0) ble $t1,$t2,set j setelse

setelse: ble $t2,$t4,setelsef add $a0,$a0,4 addi $t0,$t0,1

j loopa setelsef: move $t4,$t2 add $a0,$a0,4 addi $t0,$t0,1

j loopa set: ble $t1,$t4,setf add $a0,$a0,4 addi $t0,$t0,1

j loopa setf: move $t4,$t1 add $a0,$a0,4 addi $t0,$t0,1

j loopa print: li $v0,4 la $a0,Min syscall

li $v0,1 move $a0,$t4 syscall

li $v0,4 la $a0,Nextline syscall

jr $ra .end MinIs

MaxIs: la $a0,Num add $t0,$zero,$zero

loopb: slti $t1,$t0,5 beq $t1,$zero,printb lw $t1,0($a0) add $a0,$a0,4 lw $t2,0($a0) bgt $t1,$t2,seta j setelsea

setelsea: bgt $t2,$t4,setelsefa add $a0,$a0,4 addi $t0,$t0,1

j loopb setelsefa: move $t4,$t2 add $a0,$a0,4 addi $t0,$t0,1

j loopb seta: bgt $t1,$t4,setfa add $a0,$a0,4 addi $t0,$t0,1

j loopb setfa: move $t4,$t1 add $a0,$a0,4 addi $t0,$t0,1

j loopb printb: li $v0,4 la $a0,Max syscall

li $v0,1 move $a0,$t4 syscall

li $v0,4 la $a0,Nextline syscall

jr $ra .end MaxIs

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

Step: 3

blur-text-image

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

Computer Aided Database Design

Authors: Antonio Albano, Valeria De Antonellis, A. Di Leva

1st Edition

0444877355, 978-0444877352

More Books

Students also viewed these Databases questions

Question

1. Explain the concept of diversity and equality in the workplace.

Answered: 1 week ago