Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Hi there, I am having trouble continuing my MIPS program and was hoping to find

ID: 3553121 • Letter: H

Question

Hi there, I am having trouble continuing my MIPS program and was hoping to find some help with it.


Here is what is asked: Write a MIPS Assembly Language Programming to input a 3x3 integer array and compute and print the determinant of the 3x3 array.


I already have the main portion set up for a 2x2 I just do not know how to implement as a 3x3. Here is my code thus far.


.data

A: .space 36 #allocates 36 bytes for the 3x3 integer matrix, each integer needs 4 bytes space

A00: .asciiz "Enter A(0,0): "

A10: .asciiz "Enter A(0,1): "

A20: .asciiz "Enter A(0,2): "

A01: .asciiz "Enter A(1,0): "

A11: .asciiz "Enter A(1,1): "

A21: .asciiz "Enter A(1,2): "

A02: .asciiz "Enter A(2,0): "

A12: .asciiz "Enter A(2,1): "

A22: .asciiz "Enter A(2,2): "

nextLine: .asciiz " "

sum: .asciiz "sum of the main diagonal elements in matrix= "

.text #subsequent items are put in the user text segment

.globl main

main:

la $t0, A #loads matrix into base address t0

#Enter Integer A(0,0)

li $v0, 4 #system call code for print_str

la $a0, A00 #address of string to print

syscall #print the string

li $v0, 5 #read user int for A(0,0)

syscall #print

sw $v0, 0($t0) #save it to A

#Enter Integer A(0,1)

li $v0, 4

la $a0, A10

syscall

li $v0, 5

syscall

sw $v0, 4($t0)

#Enter Integer A(0,2) li $v0, 4

la $a0, A20

syscall

li $v0, 5

syscall

sw $v0, 8($t0)

#Enter Integer A(1,0)

li $v0, 4

la $a0, A01

syscall

li $v0, 5

syscall

sw $v0, 12($t0)

#Enter Integer A(1,1)

li $v0, 4

la $a0, A11

syscall

li $v0, 5

syscall

sw $v0, 16($t0)

#Enter Integer A(1,2)

li $v0, 4

la $a0, A21

syscall

li $v0, 5

syscall

sw $v0, 20($t0)

#Enter Integer A(2,0)

li $v0, 4

la $a0, A02

syscall

li $v0, 5

syscall

sw $v0, 24($t0)

#Enter Integer A(2,1)

li $v0, 4

la $a0, A12

syscall

li $v0, 5

syscall

sw $v0, 28($t0)

#Enter Integer A(2,2)

li $v0, 4

la $a0, A22

syscall

li $v0, 5

syscall

sw $v0, 32($t0)


# Call function det to compute determinant

la $a0,x

jal det

move $t8,$v0

# Print label and value of determinant

li $v0,4

la $a0,result

syscall

li $v0,1

move $a0,$t8

syscall

li $v0,4

la $a0,endl

syscall

li $v0,10

syscall

# Determinant Function

det: lw $t2,0($a0)

lw $t3,4($a0)

lw $t4,8($a0)

lw $t5,12($a0)

mul $t6,$t2,$t5

mul $t7,$t3,$t4

sub $v0,$t6,$t7

jr $ra

Explanation / Answer

lw $t2,16($a0)

lw $t3,32($a0)

lw $t4,28($a0)

lw $t5,20($a0)

mul $t6,$t2,$t3

mul $t7,$t5,$t4

sub $v0,$t6,$t7

lw $t2,0($a0)

mul $v0,$t2,$v0 #first component

lw $t2,12($a0)

lw $t3,32($a0)

lw $t4,24($a0)

lw $t5,20($a0)

mul $t6,$t2,$t3

mul $t7,$t5,$t4

sub $v1,$t6,$t7

lw $t2,4($a0)

mul $v1,$t2,$v1 #second component

sub $v0,$v0,$v1 # first-second

lw $t2,12($a0)

lw $t3,28($a0)

lw $t4,24($a0)

lw $t5,16($a0)

mul $t6,$t2,$t3

mul $t7,$t5,$t4

sub $v1,$t6,$t7

lw $t2,8($a0)

mul $v1,$t2,$v1 #third component

add $v0,v1,$v0 first-second+third component

0 1 2 3 4 5 6 7 8
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote