-
-
Save seisvelas/f4d9fe1ce72109b36f0fd3a26684f44a to your computer and use it in GitHub Desktop.
section .data | |
section .text | |
global _start | |
global power | |
power: | |
; ro ro fite | |
push rbp | |
mov rbp, rsp | |
mov r12, [rbp+16] | |
mov r13, [rbp+24] | |
imul rax, r12 | |
cmp r13, 1 ; if r13==1 return | |
je return | |
dec r13 | |
push r13 | |
push r12 | |
call power ; woah recuuuuurrrssiOnN | |
return: | |
mov rsp, rbp ; realign the stuck after we f-d it up by pushing | |
pop rbp | |
ret | |
_start: | |
push 4; exponent | |
push 3; base (thought was called mantissa but google says base | |
mov rax, 1 | |
call power | |
mov ebx, eax | |
mov rax, 1 ; exit() | |
int 0x80 |
I didn't expect to ever receive a comment on this Gist! How did you even find this, haha
To be honest, I was looking for esoteric Fibonacci algo's and I found your recursive SQL query. Looked around at your gists and saw ; ro ro fite
and I immediately thought of Tenga Toppen and I wanted to post the song 😄.
That's awesome! If you ever want to work on a challenging toy problem together let me know
That's a fun idea! I have some fibonacci challenges I would like to tackle in SQL, PL/SQL or PL/pgSQL. I'm not sure which version you used for your gist? I'm having trouble running it because it runs forever in mysql (MariaDB).
On a site note, I also discovered racket
by reading your gists. I'm going to try it out once I can fully think in FP programming.
I only tested it in Postgres. I could modify if to be a bit more universal but I generally stick with PostgreSQL!
Also, Racket is extremely fun. The main idea is Language Oriented Programming, where you use extensive macros (including reader macros) to change the language itself to fit the problem. A great introduction to LOP: https://beautifulracket.com/
Still feel like my intuition for what's going on in the stack is weak. Should I be subtracting from the stack pointer after my function calls to make up for all those pushes? Idfk. Gotta work on open source stuff like rn, shift mind gears from x86/cpu to Python/Cuenca