HW16
COP-3402
If main.ir is
function main phonyvar := call func return 10
then the code should be emitted by the codegen1 project would be main.s:
.file "main.ir"
.section .note.GNU-stack,"",@progbits
.text
.globl main
.type main, @function
main:
# prologue, update stack pointer
pushq %rbp # save old base ponter
movq %rsp, %rbp # set new base pointer
push %rbx # %rbx is callee-saved
call func
# set return value
mov $10, %rax
# epilogue
mov %rbp, %rsp # restore old stack pointer
pop %rbp # restore old base pointer
ret
- Which assembly instructions are the function prologue?
- Which are the epilogue?
- Which are the function call?
- Which correspond to
enterReturn?