.title "objects.ic" # global declarations .global _ic_main # data section .data .align 4 _A_DV: .long _A_m _B_DV: .long _B_m _C_DV: .long _C_main .int 10 str1: .string "A fields: " .int 10 str2: .string "B fields: " .int 2 str3: .string ", " .int 23 strNPC: .string "Null pointer violation." .int 23 strABC: .string "Array bounds violation." # text (code) section .text #---------------------------------------------------- .align 4 _A_m: push %ebp # prologue mov %esp,%ebp mov 8(%ebp), %eax # itos(a) push 4(%eax) call __itos add $4, %esp push %eax # stringCat push $str1 call __stringCat add $8, %esp push %eax # println call __println add $4, %esp _epilogue_A_m: mov %ebp,%esp # epilogue pop %ebp ret .align 4 _B_m: push %ebp # prologue mov %esp,%ebp push %ebx mov 8(%ebp), %eax # itos(a) push 4(%eax) call __itos add $4, %esp push %eax # stringCat push $str2 call __stringCat add $8, %esp push $str3 # stringCat push %eax call __stringCat add $8, %esp mov %eax, %ebx mov 8(%ebp), %eax # btos(b) push 8(%eax) call __btos add $4, %esp push %eax # stringCat push %ebx call __stringCat add $8, %esp push %eax # println call __println add $4, %esp _epilogue_B_m: pop %ebx # epilogue mov %ebp,%esp pop %ebp ret #---------------------------------------------------- .align 4 _C_main: push %ebp # prologue mov %esp, %ebp sub $8, %esp push %ebx movl $0, -4(%ebp) # initialize locals movl $0, -8(%ebp) push $8 # oa = new A call __allocateObject add $4, %esp movl $_A_DV, (%eax) mov %eax, -4(%ebp) push $12 # ob = new B call __allocateObject add $4, %esp movl $_B_DV, (%eax) mov %eax, -8(%ebp) mov 12(%ebp), %eax # eax = args cmp $0, %eax # null pointer check je labelNPC mov -4(%eax), %eax # if (args.length != 0) cmp $0, %eax je L1 mov -8(%ebp), %eax # oa = ob mov %eax, -4(%ebp) L1: mov -4(%ebp), %eax # oa.a = 412 cmp $0, %eax je labelNPC movl $412, 4(%eax) mov -8(%ebp), %eax # ob.a = 413 cmp $0, %eax je labelNPC movl $413, 4(%eax) mov -8(%ebp), %eax # ob.b = true cmp $0, %eax je labelNPC movl $1, 8(%eax) mov -4(%ebp), %eax # oa.m() cmp $0, %eax je labelNPC push %eax mov (%eax), %eax call *(%eax) add $4, %esp _epilogue_C_main: pop %ebx # epilogue mov %ebp,%esp pop %ebp ret #---------------------------------------------------- .align 4 _ic_main: push %ebp # prologue mov %esp,%ebp push $4 # o = new C call __allocateObject add $4, %esp movl $_C_DV, (%eax) push 8(%ebp) # o.main(args) push %eax mov (%eax), %eax call *(%eax) add $8, %esp mov $0, %eax # return 0 _epilogue_ic_main: mov %ebp,%esp # epilogue pop %ebp ret #---------------------------------------------------- .align 4 labelNPC: push $strNPC call __println push $1 call __exit .align 4 labelABC: push $strABC call __println push $1 call __exit