jeandrek / do-it

Toy compiled language
GNU General Public License v3.0
2 stars 1 forks source link

Blocks cause to much popping #7

Closed jeandrek closed 8 years ago

jeandrek commented 8 years ago
(block
  (var x 1)
  (block
    (var y 2)))

compiles to

    .text
    .globl entry
entry:
    pushl %ebp
    movl %esp, %ebp

    # push x
    movl $1, %eax
    pushl %eax
    # push y
    movl $2, %eax
    pushl %eax
    # pop y
    addl $4, %esp
    # pop x!! (Should not be here)
    addl $4, %esp
    # pop x
    addl $4, %esp

    popl %ebp
    ret
    .data
jeandrek commented 8 years ago

Ok, I've got to seperate the stack index and how many items need to be popped.