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

So we want to represent the square root if it\'s bigger than. This we have the f

ID: 3789728 • Letter: S

Question

So we want to represent the square root if it's bigger than. This we have the following assignment where it says activities to math.s. The above photo is the math.s code. And the bellow photo is the implementation of the code that was worked on.

ent main this will tell the assembler where to enter the routine called main this is where main will begin main The lw instructions is for load word it will take the values at the address of numbers to use and add an offest, then store the new value into the designated register lw so, rs to use (0x00 $20 lw 1, numbers to use 0x04 $20 lw s2, numbers to use (0x08 E10 lw s3, numbers to use 0x0C $10 lw rs to use 0x10 lw as, numbers to use +0x14 $5 lw s6, numbers to use (0x18 lw 37, numbers to use +0x1C $0 the li instruction is for load imamediate it is a combination of the load upper immediate lui and or immediate ori instructions It loads the designated 32 bit value inta a given register li to, 0 li tl, 0x100 $values can be designated in hex or decimal li t2, 0x000 li a3 0x000 math beg t0 50 end m this will check t0 50 and branch to end m if it is we ALWAYS need a nop no operation after branching and jumping instructions nop add t0, t0 0x01 this will add to to and put the result back into to add a0, s4, s4 84 84 add a 1 s5 s5 al mul 2, a 0, al 2 al add a 3 a2, a3 aw 3, mem lock+0 this will store the register value of a3 into the memory location mem lock with an offset of zero this will unconditionally branch back to the math label b math. nop end m this is an infinate loop nop b end m nop this is where main ends nd main PIC32M

Explanation / Answer

.ent main
main:
li v0,0
li t0,0
li t1,2 # start with two
li t2,2 # increment of two for even numbers
li v1,0
li t3,2147483647 #max value of 32 bit integer
Sum:
beg t1,1000,findSquare
nop
add v0,v0,t1 # sum
add t1,t1,t2 # increment by 2
b Sum
nop
findSquare:
mul t0,v0,v0 # square
ble t0,t3,less # if t0 <= max value of 32 bit int
nop
add v1,v1,-1 # else assign -1 to v1
b final # unconditional branch to end
less:
nop
add v1,v1,t0 # assign square value to t0
final:
.end main

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