17 lines
326 B
ArmAsm
17 lines
326 B
ArmAsm
|
;; MIPS program pow(x,n)
|
||
|
.data
|
||
|
N: .word 5
|
||
|
X: .double 2
|
||
|
W: .double 1
|
||
|
|
||
|
.text
|
||
|
dadd r1,r0,r0 ; r1=i=0
|
||
|
lw r2, N(r0) ; r2=n
|
||
|
l.d f1, W(r0) ; f1=w
|
||
|
l.d f2, X(r0) ; f2=x
|
||
|
loop:
|
||
|
mul.d f1, f1, f2 ; w*=x
|
||
|
addi r1, r1, 1 ; i++
|
||
|
bne r1, r2, loop
|
||
|
s.d f1, W(r0)
|
||
|
halt
|