.file "tri1.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 mov eax, DWORD PTR _height inc eax mov edx, eax imul edx, DWORD PTR _height mov eax, edx sar eax, 31 shr eax, 31 lea eax, [edx+eax] sar eax mov DWORD PTR _numBricks, eax 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, 2 mov eax, _height add eax, 1 mul DWORD PTR _height div DWORD PTR ebx mov _numBricks, eax 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 L4: 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 L6 jmp L5 L6: call _asm_tri mov eax, DWORD PTR _numBricks mov DWORD PTR [esp+4], eax mov DWORD PTR [esp], OFFSET FLAT:LC2 call _printf jmp L4 L5: 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