SHARE
TWEET

Untitled

a guest Jul 1st, 2019 84 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. .global fun
  2. .proc 4
  3.  
  4.     fun:
  5.         save %sp,-96,%sp
  6.         
  7.         mov %i0, %l0         ; l0 - n
  8.         mov %i1, %l1        ; l1 - k
  9.         mov 0, %l2            ; power
  10.         mov 1, %l3            ; a(n) = 1
  11.         
  12.         subcc %i0, 1, %i0
  13.         bl theEnd            ; if n = 0 then jump to theEnd 
  14.         nop
  15.         
  16.         mov %l0, %l2        ; power = n
  17.         smul %l2, %l1, %l2    ; power = power * k
  18.         add %l2, %l1, %l2    ; power = power + k
  19.         
  20.         call fun            ; call recursion
  21.         mov %i0, %l3        ; get score of recursion
  22.         
  23.     expo:
  24.         smul %l3, %l3, %l3
  25.         subcc %l2, 1, %l2
  26.         bl theEnd
  27.         nop
  28.         ba expo
  29.         
  30.     theEnd:
  31.         mov %l3, %i0        ; return score
  32.         ret
  33.         restore
  34.         
  35. .end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top