Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- b top
- calc: stp x29, x30, [sp, -16]! // Allocate
- mov x29, sp
- fmov counter, 1.0 // It's a counter
- fmov power, 1.0
- fmov accum, 1.0 // Accumulator is 1
- fmov numerator, d0 // Num = x
- fmov factorial, power
- fdiv quotient, numerator, factorial // x / factorial
- fadd accum, accum, quotient // accum + quotient
- loop: adrp x27, value
- add x27, x27, :lo12:value
- ldr d3, [x27] // d3 = 0r1.0e-10
- fmul numerator, numerator, d0 // d0 * num
- fadd power, power, counter // power++
- fmul factorial, factorial, power // factor * power
- fdiv quotient, numerator, factorial // quotient = num / fact
- fadd accum, accum, quotient // accum += quotient
- fabs quotient, quotient
- fcmp quotient, d3 // Compare
- b.ge loop // If quotient >= d3
- fmov d0, accum
- ldp x29, x30, [sp], 16
- ret
- end: mov w0, fd_r // 1st arg (fd)
- mov x8, 57 // closing I/O
- svc 0 // call sys func
- mov w0, 0 // ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement