如何在MIPS汇编中对数字求平方

时间:2019-02-03 19:49:05

标签: assembly mips

我很难弄清楚如何将$ 8平方。我需要不使用乘法或除法。

addi $8, $0, 1 #seed value
addi $9, $0, 0x2010 #starting memory address
addi $12, $0, 16 #so it can loop 16 times
Loop:
addu $8, $8, $8 #$8 = 8 + 8 #i need to square this value
sw $8, ($9) #the value of $8 gets stored into memory
addi $12, $12, ,-1
addi $9, $9, 4 #increments the address by 4
beq $12, $0, out
beq $12, $12, Loop

0 个答案:

没有答案