diff options
author | Bad Diode <bd@badd10de.dev> | 2021-11-01 16:59:01 +0100 |
---|---|---|
committer | Bad Diode <bd@badd10de.dev> | 2021-11-01 16:59:01 +0100 |
commit | 64f4b9192c231236ddeb10548e577ca1e3f40e9b (patch) | |
tree | a02912deccb28307b000e9a6e2a98413395979ef /src/x86_64/postlude.asm | |
parent | 7418a5042471a3a7f05283d36e45b6b422d9785b (diff) | |
download | bdl-64f4b9192c231236ddeb10548e577ca1e3f40e9b.tar.gz bdl-64f4b9192c231236ddeb10548e577ca1e3f40e9b.zip |
Add support for immediate constants
- Fixnums are tagged with a zero on the LSB.
- The nil value is equal to exactly 1.
- Boolean values have a 11 tag. A value of 111 is true and 011 false.
Diffstat (limited to 'src/x86_64/postlude.asm')
-rw-r--r-- | src/x86_64/postlude.asm | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/x86_64/postlude.asm b/src/x86_64/postlude.asm index 139c4e1..5c8e56f 100644 --- a/src/x86_64/postlude.asm +++ b/src/x86_64/postlude.asm | |||
@@ -1,7 +1,32 @@ | |||
1 | |||
2 | _start_return: | ||
1 | ;; return the last value in the stack | 3 | ;; return the last value in the stack |
2 | pop rdi | 4 | pop rdi |
5 | |||
6 | ;; is nil? | ||
7 | mov rax, rdi | ||
8 | cmp rax, NIL_VAL | ||
9 | je exit | ||
10 | |||
11 | ;; is boolean? | ||
12 | mov rax, rdi | ||
13 | and rax, BOOL_MASK | ||
14 | cmp rax, BOOL_TAG | ||
15 | jne not_bool | ||
16 | call printbool | ||
17 | jmp exit | ||
18 | not_bool: | ||
19 | |||
20 | ;; is fixnum? | ||
21 | mov rax, rdi | ||
22 | and rax, FIXNUM_MASK | ||
23 | cmp rax, FIXNUM_TAG | ||
24 | jne not_fixnum | ||
3 | call printdln | 25 | call printdln |
26 | jmp exit | ||
27 | not_fixnum: | ||
4 | 28 | ||
29 | exit: | ||
5 | ; exit syscall | 30 | ; exit syscall |
6 | mov rax, 60 | 31 | mov rax, 60 |
7 | xor rdi, rdi | 32 | xor rdi, rdi |