MIPS Assembly Language (Power2) -
i looking best method performing n power2 function. in short, code in mips should calculate 2n. n being positive number stored in $a0
. however, of right results coming 1 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 zero, if yes exit program sllv $s1,$s0,$a0 #shift left logical n, should math 2^n exit:
"failed" isn't informative statement. anyway, correct syntax beg $a0,$zero,j exit
beq $a0, $zero, exit
don't need check. should load $s0
1
not 0
since 2^0
1
, sll $s0, 2, $a0
should sllv $s0, $s0, $a0
.
Comments
Post a Comment