Skip to content

Instantly share code, notes, and snippets.

@seisvelas
Last active September 12, 2019 16:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save seisvelas/f4d9fe1ce72109b36f0fd3a26684f44a to your computer and use it in GitHub Desktop.
Save seisvelas/f4d9fe1ce72109b36f0fd3a26684f44a to your computer and use it in GitHub Desktop.
My first recursion in x86
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
@seisvelas
Copy link
Author

I only tested it in Postgres. I could modify if to be a bit more universal but I generally stick with PostgreSQL!

@seisvelas
Copy link
Author

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/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment