I am currently looking for the best method for performing an n power2 function. In short, the code in MIPS should calculate 2n. n being a positive number stored in $a0
. However, as of right now my results are coming one power less.
My Attempt
main:
# initialize
la $a0,3 #n counter
li $s0,2 #base number
li $s1,0 #calculated value
While:
beq $a0,$zero,exit #Checks if n is zero, if yes exit program
sllv $s1,$s0,$a0 #Shift left logical by n, this should do the math 2^n
exit: