MatthewKosloski / torrey

The Torrey Programming Language

Home Page:https://torrey.xyz

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Booleans are not converted to immediate addresses

MatthewKosloski opened this issue · comments

Example program:

(println (let [a true]
  (- 1 )))

Actual assembly:

.text
  .globl main
main:
  pushq %rbp
  movq %rsp, %rbp
  subq $32, %rsp
  jmp start
start:
  movq $true, -8(%rbp)
  movq -8(%rbp), %r10
  movq %r10, -16(%rbp)
  movq $-1, -24(%rbp)
  movq -24(%rbp), %rdi
  callq print_int
  callq print_nl
  jmp conclusion
conclusion:
  addq $32, %rsp
  popq %rbp
  movq $0, %rax
  retq

Expected assembly:

.text
  .globl main
main:
  pushq %rbp
  movq %rsp, %rbp
  subq $32, %rsp
  jmp start
start:
  movq $1, -8(%rbp)
  movq -8(%rbp), %r10
  movq %r10, -16(%rbp)
  movq $-1, -24(%rbp)
  movq -24(%rbp), %rdi
  callq print_int
  callq print_nl
  jmp conclusion
conclusion:
  addq $32, %rsp
  popq %rbp
  movq $0, %rax
  retq