Last active
September 12, 2019 16:09
-
-
Save seisvelas/f4d9fe1ce72109b36f0fd3a26684f44a to your computer and use it in GitHub Desktop.
My first recursion in x86
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
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
I only tested it in Postgres. I could modify if to be a bit more universal but I generally stick with PostgreSQL!