Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

my lab 2 homework: .data V: .word 0 0 0 0 0 0 0 0 VPrime: .word 0 0 0 0 0 0 0 0

my lab 2 homework:

.data

V: .word 0 0 0 0 0 0 0 0

VPrime: .word 0 0 0 0 0 0 0 0

VCheck: .word 0 0 0 0 0 0 0 0

input: .asciiz "Enter 8-digit integer value as string: "

output1: .asciiz " Input VPrime: "

output2: .asciiz "CheckResult: "

digitString: .space 8

.text

li $v0,4

la $a0,input

syscall

li $v0,8

la $a0, digitString

li $a1, 9

move $t0,$a0

syscall

la $t1,V

li $t2,0

loop:

beq $t2,8,copy

lb $t3,0($t0)

add $t3,$t3,-48

sw $t3,0($t1)

addi $t0,$t0,1

addi $t1,$t1,4

addi $t2,$t2,1

j loop

copy:

la $t0,V

la $t1,VPrime

li $t2,0

loopCopy:

beq $t2,8,print

lw $t3,0($t0)

sw $t3,0($t1)

addi $t0,$t0,4

addi $t1,$t1,4

addi $t2,$t2,1

j loopCopy

print:

la $a0,output1

li $v0,4

syscall

la $a0,VPrime

jal printArray

difference:

la $t0,V

la $t1,VPrime

la $t2,VCheck

li $t3,0

loopDifference:

beq $t3,8,sum

lw $t4,0($t0)

lw $t5,0($t1)

sub $t4,$t4,$t5

sw $t4,0($t2)

addi $t0,$t0,4

addi $t1,$t1,4

addi $t2,$t2,4

addi $t3,$t3,1

j loopDifference

sum:

la $t0,VCheck

li $t1,0

li $t2,0

loopSum:

beq $t2,8,result

lw $t3,0($t0)

add $t1,$t1,$t3

addi $t0,$t0,4

addi $t2,$t2,1

j loopSum

result:

la $a0,output2

li $v0,4

syscall

move $a0,$t1

li $v0,1

syscall

exit:

li $v0,10

syscall

printArray:

li $t2,0

move $t0,$a0

loopPrint:

beq $t2,8,ret

li $v0,1

lw $a0,0($t0)

syscall

li $v0,11

li $a0,10

syscall

addi $t0,$t0,4

addi $t2,$t2,1

j loopPrint

ret:

jr $ra

thank you for now, i will like ur answerimage text in transcribedimage text in transcribed

Requirements 1. Mac, Windows or Linux PC 2. Java standard edition (SE) version 9 or higher. 3. MARS Java program Introduction In this lab, you will use MARS (MIPS Assembler and Runtime Simulator) to write and run a program that reads in a 4 x 4 matrix of numbers stored as an Integer array. You will take the program written for Lab 2 and expand it for this lab. The purpose of this lab is to learn to use "procedures." As before, if you have any problems running MARS refer to the instructions in Lab 1. There are two different ways to convert the ASCII into integers; arithmetic and logic. If your student ID ends in an even number, then you use arithmetic. If your student ID ends in an odd number, then you use logic. Note: this is the opposite from Lab 2. Exercise 1 1. Make a new version of lab 2 called Lab 3" 2. Convert your vector read routine in Lab 2 to a procedure that reads in a vector of length 4. 3. Call the vector read routine 4 times to read in the matrix M, use the "jal instruction. 4. Between each call, store the results into the 16-entry integer array M. Note: This will be storing the matrix into the array in row major order. Same as Lab2, use only whole numbers (0-9). The input on the screen should look like a matrix just as below: Row 1: 3 4 2 9 Row 2: 4 6 0 1 Row 3: 5 5 3 3 Row 4: 1 2 3 4 (with the matrix values input by the user on the console) After reading all 4 rows of the matrix into the array: Write a loop routine that sums all the elements of the array. The loop routine should have only one branch at the end of the loop. (Loop practice) Use an if then else construct to print O or l if the sum is even or odd. (If then else practice) Sum: 1 Lab 3(Procedures) Start Assignment In this lab, you will use MARS to write and run a program that reads in a 4 x 4 matrix of numbers stored as an Integer array. You will take the program written for Lab 2 and expand it for this lab. The purpose of this lab is to learn to use procedures." Follow the instructions here. Make sure you follow good coding practices, indent any nested code for readability. Upload your finished program to Canvas

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

Oracle Database 19c DBA By Examples Installation And Administration

Authors: Ravinder Gupta

1st Edition

B09FC7TQJ6, 979-8469226970

More Books

Students also viewed these Databases questions

Question

Tell the merits and demerits of Mendeleev's periodic table.

Answered: 1 week ago