Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I want to know what's wrong with my project. there is code: .data Prompt: .asciiz Please input a value for N = :

I want to know what's wrong with my project. there is code:

.data

Prompt: .asciiz " Please input a value for N = : "

Result: .asciiz " The sum of integers from 1 to N is: "

Bye: .asciiz " CS is not easy try harder."

JW: .asciiz " The number will truncated to integer: "

.globl main

.text

main:

li $v0, 4 #System call code for Print String

la $a0, Prompt #load address of prompt into $a0

syscall #Print the Prompt message

li $v0, 6 #Read value into $vo

syscall

blez $v0, End

li $t1,0 #new access

mfc1 $t1, $f0 #copy floating number

#get expoent

srl $t2, $t1, 23

add $t3, $t2, -127

#get the fraction

sll $t4, $t1, 9

srl $t5, $t4, 9 #shift back to original position, $t5 is the fraction

add $t6, $t5, 8388608 #adding the implied bit to the number

add $t7, $t3, 9

sllv $t4, $t6, $t7 #sheft left value of $t7

rol $t4, $t6, $t7 #Rotate the bits

#shift left 31 -exp to zreo out the other bits

li $t5, 31

sub $t2, $t5, $t3 #shift value

sllv $t5, $t4, $t2 #zero out the Fraction part

srlv $s5, $t5, $t2 #resst integer bits in $s5

move $v0, $s5 #move the integer into $v0

li $t0, 0 #zero goes out $t0

blez $t1, End #if 0 here, branch to end

beqz $s4, Loop #if no value here,branch to Loop

bne $s4, 0, ToJW #branch to JW

ToJW: li $v0, 4 #system call code for Print String

la $a0, JW #print the message

syscall

li $v0, 1 #print integer

move $a0, $s5 #move the address of integer to $a0

syscall

move $v0, $s5 #put the value of the integer to Loop

b Loop #branch to Loop

loop:

add $t0, $t0, $v0 # sum of integers in register $t0

addi $v0, $v0, -1 # summing integers in reverse order

bnez $v0, loop # branch to loop if $v0 is != zero

li $v0, 4 # system call code for Print String

la $a0, result # load address of message into $a0

syscall # print the string

li $v0, 1 # system call code for Print Integer

move $a0, $t0 # move value to be printed to $a0

syscall # print sum of integers

b main # branch to main

end: li $v0, 4 # system call code for Print String

la $a0, bye # load address of msg. into $a0

syscall # print the string

li $v0, 10 # terminate program run and

syscall # return control to system

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

Practical Neo4j

Authors: Gregory Jordan

1st Edition

1484200225, 9781484200223

More Books

Students also viewed these Databases questions

Question

Explain the Neolithic age compared to the paleolithic age ?

Answered: 1 week ago

Question

What is loss of bone density and strength as ?

Answered: 1 week ago

Question

What is the Definition for Third Normal Form?

Answered: 1 week ago

Question

Provide two examples of a One-To-Many relationship.

Answered: 1 week ago