Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

.data largestPrimeFactor: .word 0 .text main: li $t0, 2 li $t1, 1 li $t2, 100 loop: div $t3, $t2, $t0 mfhi $t3 bne $t3, $0,

.data

largestPrimeFactor: .word 0

.text

main:

li $t0, 2

li $t1, 1

li $t2, 100

loop:

div $t3, $t2, $t0

mfhi $t3

bne $t3, $0, notFactor

li $t1, 0

li $t4, 2

innerLoop:

div $t5, $t0, $t4

mfhi $t5

bne $t5, $0, notPrime

li $t1, 1

notPrime:

addi $t4, $t4, 1

blt $t4, $t0, innerLoop

bne $t1, $0, update

notFactor:

addi $t0, $t0, 1

blt $t0, $t2, loop

update:

sw $t0, largestPrimeFactor($0)

li $v0, 1

lw $a0, largestPrimeFactor($0)

syscall

li $v0, 10

syscall

This Assembly MIPS instructions give me the wrong answer 2 instead of the right answer 5.

Can you correct this code and give me the corrected code?

Please make sure the code is working correctly by using Online MIPS Simulator, I asked more than once and all the code answers has been wrong

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

Graph Databases New Opportunities For Connected Data

Authors: Ian Robinson, Jim Webber, Emil Eifrem

2nd Edition

1491930896, 978-1491930892

More Books

Students also viewed these Databases questions

Question

In most cases, medication is prescribed by physicians.

Answered: 1 week ago

Question

5. Describe how contexts affect listening

Answered: 1 week ago