.file "tri2.c" .intel_syntax .globl _height .bss .align 4 _height: .space 4 .globl _numBricks .align 4 _numBricks: .space 4 .text .globl _c_tri .def _c_tri; .scl 2; .type 32; .endef _c_tri: push ebp mov ebp, esp L2: cmp DWORD PTR _height, 0 jle L1 mov eax, DWORD PTR _height add DWORD PTR _numBricks, eax dec DWORD PTR _height jmp L2 L1: pop ebp ret .globl _asm_tri .def _asm_tri; .scl 2; .type 32; .endef _asm_tri: push ebp mov ebp, esp /APP push eax push ebx mov ebx, 0 mov eax, _height WHILE: cmp eax, 0 jna DONE add ebx, eax sub eax, 1 jmp WHILE DONE: mov _numBricks, ebx pop ebx pop eax /NO_APP pop ebp ret .def ___main; .scl 2; .type 32; .endef .section .rdata,"dr" LC0: .ascii "-> \0" LC1: .ascii "%d\0" LC2: .ascii "%d\12\0" LC3: .ascii "bye\12\0" .text .globl _main .def _main; .scl 2; .type 32; .endef _main: push ebp mov ebp, esp sub esp, 24 and esp, -16 mov eax, 0 add eax, 15 add eax, 15 shr eax, 4 sal eax, 4 mov DWORD PTR [ebp-4], eax mov eax, DWORD PTR [ebp-4] call __alloca call ___main L6: mov DWORD PTR [esp], OFFSET FLAT:LC0 call _printf mov DWORD PTR [esp+4], OFFSET FLAT:_height mov DWORD PTR [esp], OFFSET FLAT:LC1 call _scanf cmp DWORD PTR _height, 0 jns L8 jmp L7 L8: call _asm_tri mov eax, DWORD PTR _numBricks mov DWORD PTR [esp+4], eax mov DWORD PTR [esp], OFFSET FLAT:LC2 call _printf jmp L6 L7: mov DWORD PTR [esp], OFFSET FLAT:LC3 call _printf mov eax, 0 leave ret .def _scanf; .scl 3; .type 32; .endef .def _printf; .scl 3; .type 32; .endef