# Objects.ic # global declarations .globl __ic_main # data section .data .align 8 _A_VT: .quad _A_m _B_VT: .quad _B_m _C_VT: .quad _C_main .quad 10 str1Chars: .ascii "A fields: " str1: .quad str1Chars .quad 10 str2Chars: .ascii "B fields: " str2: .quad str2Chars .quad 2 str3Chars: .ascii ", " str3: .quad str3Chars .quad 0 str4Chars: .ascii "" str4: .quad str4Chars .quad 23 strNullPtrErrorChars: .ascii "Null pointer violation." strNullPtrError: .quad strNullPtrErrorChars .quad 23 strArrayBoundsErrorChars: .ascii "Array bounds violation." strArrayBoundsError: .quad strArrayBoundsErrorChars .quad 21 strArraySizeErrorChars: .ascii "Array size violation." strArraySizeError: .quad strArraySizeErrorChars # text (code) section .text #---------------------------------------------------- .align 8 _A_m: pushq %rbp # prologue movq %rsp,%rbp movq 16(%rbp), %rax # itos(a) movq 8(%rax), %rdi call __LIB_itos movq %rax, %rsi # stringCat movq str1(%rip), %rdi call __LIB_stringCat movq %rax, %rdi # println call __LIB_println _epilogue_A_m: movq %rbp,%rsp # epilogue popq %rbp ret .align 8 _B_m: pushq %rbp # prologue movq %rsp,%rbp pushq %rbx movq str2(%rip), %rdi # print("B fields: ") call __LIB_print movq 16(%rbp), %rax # printi(a) movq 8(%rax), %rdi call __LIB_printi movq str3(%rip), %rdi # print(", ") call __LIB_print movq 16(%rbp), %rax # printb(b) movq 16(%rax), %rdi call __LIB_printb movq str4(%rip), %rdi # println("") call __LIB_println _epilogue_B_m: popq %rbx # epilogue movq %rbp,%rsp popq %rbp ret #---------------------------------------------------- .align 8 _C_main: pushq %rbp # prologue movq %rsp, %rbp subq $16, %rsp pushq %rbx movq $16, %rdi # oa = new A call __LIB_allocateObject leaq _A_VT(%rip), %rdi movq %rdi, (%rax) mov %rax, -8(%rbp) movq $24, %rdi # ob = new B call __LIB_allocateObject leaq _B_VT(%rip), %rdi movq %rdi, (%rax) movq %rax, -16(%rbp) mov 24(%rbp), %rax # eax = args cmp $0, %rax # null pointer check je labelNullPtrError mov -8(%rax), %rax # if (args.length != 0) cmp $0, %rax je L1 mov -16(%rbp), %rax # oa = ob mov %rax, -8(%rbp) L1: mov -8(%rbp), %rax # oa.a = 412 cmp $0, %rax je labelNullPtrError movq $412, 8(%rax) mov -16(%rbp), %rax # ob.a = 413 cmp $0, %rax je labelNullPtrError movq $413, 8(%rax) mov -16(%rbp), %rax # ob.b = true cmp $0, %rax je labelNullPtrError movq $1, 16(%rax) mov -8(%rbp), %rax # oa.m() cmp $0, %rax je labelNullPtrError push %rax mov (%rax), %rax call *(%rax) add $8, %rsp mov -16(%rbp), %rax # ob.m() cmp $0, %rax je labelNullPtrError push %rax mov (%rax), %rax call *(%rax) add $8, %rsp _epilogue_C_main: pop %rbx # epilogue mov %rbp,%rsp pop %rbp ret #---------------------------------------------------- .align 8 __ic_main: push %rbp # prologue mov %rsp,%rbp push %rdi # o.main(args) -> push args movq $8, %rdi # o = new C call __LIB_allocateObject leaq _C_VT(%rip), %rdi movq %rdi, (%rax) push %rax # o.main(args) -> push o mov (%rax), %rax call *(%rax) add $16, %rsp mov $0, %rax # return 0 _epilogue_ic_main: mov %rbp,%rsp # epilogue pop %rbp ret #---------------------------------------------------- .align 8 labelNullPtrError: movq strNullPtrError(%rip), %rdi call __LIB_println movq $1, %rdi call __LIB_exit .align 8 labelArrayBoundsError: movq strArrayBoundsError(%rip), %rdi call __LIB_println movq $1, %rdi call __LIB_exit .align 8 labelArraySizeError: movq strArraySizeError(%rip), %rdi call __LIB_println movq $1, %rdi call __LIB_exit