bltn_closure.asm 457 B

123456789101112131415161718192021222324252627282930
  1. %ifndef BLTN_CLOSURE_ASM
  2. %define BLTN_CLOSURE_ASM
  3. %include "syscalls.asm"
  4. %include "print_type.asm"
  5. %include "heap.asm"
  6. %include "type_check.asm"
  7. section .text
  8. bltn_alloc_closure:
  9. ;; INPUT: rax closure length, r8 the label
  10. ;; OUTPUT: rax the heap address of the uninitialized closure
  11. ;; uses rcx as a temporary
  12. mov rcx, rax
  13. add rax, 1
  14. call heap_alloc
  15. mov [rax], r8
  16. mov [rax + 8], rcx
  17. or rax, 0b011 ; tag it as a closure
  18. ret
  19. %endif