https://github.com/akkartik/mu/blob/master/apps/mulisp.subx
1
2
3
4
5
6
7
8
9
10
11 == code
12
13 Entry:
14
15 89/<- %ebp 4/r32/esp
16
17 (new-segment Heap-size Heap)
18
19 81 7/subop/compare *ebp 1/imm32
20 7e/jump-if-lesser-or-equal $run-main/disp8
21
22 (kernel-string-equal? *(ebp+8) "test")
23 3d/compare-eax-and 0/imm32
24 74/jump-if-equal $run-main/disp8
25
26 (run-tests)
27
28 8b/-> *Num-test-failures 3/r32/ebx
29 eb/jump $main:end/disp8
30 $run-main:
31 (repl Stdin Stdout)
32
33 bb/copy-to-ebx 0/imm32
34 $main:end:
35 b8/copy-to-eax 1/imm32/exit
36 cd/syscall 0x80/imm8
37
38
39
40
41
42
43
44
45
46 repl:
47
48 55/push-ebp
49 89/<- %ebp 4/r32/esp
50
51 50/push-eax
52 $repl:loop:
53 (lisp-read Stdin)
54
55 3d/compare-eax-and 0/imm32
56 74/jump-if-equal $repl:end/disp8
57
58 (lisp-eval %eax)
59 (lisp-print Stdout %eax)
60
61 eb/jump $repl:loop/disp8
62 $repl:end:
63
64 58/pop-to-eax
65
66 89/<- %esp 5/r32/ebp
67 5d/pop-to-ebp
68 c3/return
69
70 lisp-read:
71
72 55/push-ebp
73 89/<- %ebp 4/r32/esp
74
75
76 81 5/subop/subtract %esp 0x200/imm32
77 68/push 0x200/imm32/size
78 68/push 0/imm32/read
79 68/push 0/imm32/write
80 89/<- %ecx 4/r32/esp
81
82 (clear-stream %ecx)
83 (read-line-buffered *(ebp+8) %ecx)
84
85 81 7/subop/compare *ecx 0/imm32
86 75/jump-if-not-equal $lisp-read:loop/disp8
87 b8/copy-to-eax 0/imm32/eof
88 eb/jump $lisp-read:end/disp8
89 $lisp-read:loop:
90
91 89/<- %eax 1/r32/ecx
92 $lisp-read:end:
93
94 81 0/subop/add %esp 0x20c/imm32
95
96
97 89/<- %esp 5/r32/ebp
98 5d/pop-to-ebp
99 c3/return
100
101 lisp-eval:
102
103 55/push-ebp
104 89/<- %ebp 4/r32/esp
105
106 8b/-> *(ebp+8) 0/r32/eax
107 $lisp-eval:end:
108
109
110 89/<- %esp 5/r32/ebp
111 5d/pop-to-ebp
112 c3/return
113
114 lisp-print:
115
116 55/push-ebp
117 89/<- %ebp 4/r32/esp
118
119
120 (write-buffered Stdout "=> ")
121 (write-stream-data Stdout *(ebp+0xc))
122 (flush Stdout)
123 $lisp-print:end:
124
125
126 89/<- %esp 5/r32/ebp
127 5d/pop-to-ebp
128 c3/return
129
130 == data
131
132 Nil:
133 0/imm32/tag
134 0/imm32/data