UP | HOME

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
  1. Which assembly instructions are the function prologue?
  2. Which are the epilogue?
  3. Which are the function call?
  4. Which correspond to enterReturn?

Author: Paul Gazzillo

Created: 2024-10-28 Mon 23:17

Validate