1 // clang -masm=intel -nostdlib -Ltarget/release -lrt -lSystem -Wl,-e,_start -g example.s -o target/example
49 lea rdi, [rip + debug]
53 mov [rip + DEBUG], rax
60 call _ivy_app // succ zero
63 call _ivy_app // succ (succ zero)
64 // RAX contains Church #2
65 mov [rsp], rax // 2 := succ (succ zero)
68 call _ivy_app // add 2
71 call _ivy_app // add 2 2
73 // RAX contains Church #4
76 call _ivy_app // mul (add 2 2)
79 call _ivy_app // 16 := mul (add 2 2) (add 2 2)
82 call _ivy_app // mul (add 2 2)
85 call _ivy_app // 64 := mul (add 2 2) 16
86 // RAX contains Church #16
88 mov rsi, [rip + DEBUG]
89 call _ivy_app // 64 debug
92 call _ivy_app // 64 debug zero
93 // This should print out "DBUG <0-addr>" 16 times. I hope.
100 zero = lam (f x) => x;
101 succ = lam (n f x) => f (n f x);
102 add = lam (m n f x) => m f (n f x);
103 mul = lam (m n f x) => m (n f) x;
104 debug = some magic nonsense
106 two = succ (succ zero);
108 _64 = mul (mul four four) four
115 mov rax, [rdi + (0x18 + 8)]
122 mov rdi, [rbx + 0x18]
123 mov rsi, [rbx + (0x18 + 8)]
126 mov rsi, [rbx + (0x18 + 16)
128 mov rdi, [rbx + (0x18 + 8)]
130 call _ivy_app // f(nfx)
139 mov rdi, [rbx + 0x18]
140 mov rsi, [rbx + (0x18 + 16)]
143 mov rdi, [rbx + (0x18 + 8)]
144 mov rsi, [rbx + (0x18 + 16)]
147 mov rsi, [rbx + (0x18 + 24)]
151 call _ivy_app // mf(nfx)
160 mov rdi, [rbx + (0x18 + 8)]
161 mov rsi, [rbx + (0x18 + 16)]
163 mov rdi, [rbx + 0x18]
165 call _ivy_app // m(nf)
167 mov rsi, [rbx + (0x18 + 24)]
168 call _ivy_app // m(nf)x
175 mov rdi, [rdi + 0x18]