.file "tri3.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 cmp DWORD PTR _height, 0 jle L1 mov eax, DWORD PTR _height add DWORD PTR _numBricks, eax dec DWORD PTR _height call _c_tri L1: pop ebp ret .section .rdata,"dr" LC0: .ascii "height = %d, numBricks = %d\12\0" .text .globl _asm_tri .def _asm_tri; .scl 2; .type 32; .endef _asm_tri: push ebp mov ebp, esp sub esp, 24 /APP push eax mov eax, _height cmp eax, 0 jna QUIT add _numBricks, eax sub eax, 1 mov _height, eax /NO_APP mov eax, DWORD PTR _numBricks mov DWORD PTR [esp+8], eax mov eax, DWORD PTR _height mov DWORD PTR [esp+4], eax mov DWORD PTR [esp], OFFSET FLAT:LC0 call _printf /APP pop eax call _asm_tri QUIT: pop eax /NO_APP leave ret .def ___main; .scl 2; .type 32; .endef .section .rdata,"dr" LC1: .ascii "-> \0" LC2: .ascii "%d\0" LC3: .ascii "%d\12\0" LC4: .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 L5: mov DWORD PTR [esp], OFFSET FLAT:LC1 call _printf mov DWORD PTR [esp+4], OFFSET FLAT:_height mov DWORD PTR [esp], OFFSET FLAT:LC2 call _scanf cmp DWORD PTR _height, 0 jns L7 jmp L6 L7: call _asm_tri mov eax, DWORD PTR _numBricks mov DWORD PTR [esp+4], eax mov DWORD PTR [esp], OFFSET FLAT:LC3 call _printf jmp L5 L6: mov DWORD PTR [esp], OFFSET FLAT:LC4 call _printf mov eax, 0 leave ret .def _scanf; .scl 3; .type 32; .endef .def _printf; .scl 3; .type 32; .endef