# hello.ic # data segment .data .align 8 # vtable for Hello Hello_VT: .quad _Hello_main #---------------------------------------------------- # string constants in IC format .quad 12 str0data: .ascii "Hello world\n" str0: .quad str0data # text segment .text #----------------------------------------------------- # code for Hello.main .align 8 _Hello_main: pushq %rbp # prologue movq %rsp, %rbp movq str0(%rip), %rdi # println(...) call __LIB_print movq %rbp, %rsp # epilogue popq %rbp ret #----------------------------------------------------- # The main entry point. Allocate object and invoke main on it. .align 8 .globl __ic_main __ic_main: push %rbp # prologue mov %rsp,%rbp pushq %rdi # o.main(args) -> push args movq $8,%rdi # o = new Hello call __LIB_allocateObject leaq Hello_VT(%rip), %rdi # compute table base movq %rdi, (%rax) # set vptr pushq %rax # o.main(args) -> push o call _Hello_main addq $16, %rsp movq $0, %rax # always return 0 _epilogue_ic_main: movq %rbp,%rsp # epilogue popq %rbp ret