aboutsummaryrefslogtreecommitdiffstats
path: root/src/x86_64/postlude.asm
blob: 5c8e56ff3ed9facc10b8744264191135cc558a2f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33

_start_return:
    ;; return the last value in the stack
    pop     rdi

    ;; is nil?
    mov     rax, rdi
    cmp     rax, NIL_VAL
    je      exit

    ;; is boolean?
    mov     rax, rdi
    and     rax, BOOL_MASK
    cmp     rax, BOOL_TAG
    jne     not_bool
    call    printbool
    jmp     exit
not_bool:

    ;; is fixnum?
    mov     rax, rdi
    and     rax, FIXNUM_MASK
    cmp     rax, FIXNUM_TAG
    jne     not_fixnum
    call    printdln
    jmp     exit
not_fixnum:

exit:
    ; exit syscall
    mov     rax, 60
    xor     rdi, rdi
    syscall