rahulchawla
rahulchawla

Reputation: 296

LC3 - Compute Square Assembly

Hi I'm writing a lc3 subroutine to compute the square of a value in n and then place that value in r0, i have wrote the code and it seems to be filling r0 with the sumofsums however at the end of the program the value in r0 ends up being x7fff - i'm not sure whats changing the value any ideas? my code is below

.orig x3FF8
 ld r1,n
ld r5,n
and r0,r0,#0
 square


add r0, r0,r1 ; add sum to r0

add r5,r5,#-1 ;decrement counter(amount of times to add sum)

brp square ;loop


theend



n .fill #4

.end

Upvotes: 0

Views: 318

Answers (0)

Related Questions