#include int height = 0; // = height of stair case int numBricks = 0; // = num bricks needed to build staircase void c_tri() { numBricks = height * (height + 1) / 2; } void asm_tri() { asm("push eax \n\t" "push ebx \n\t" "push edx \n\t" "mov ebx, 2 \n\t" "mov eax, _height \n\t" "add eax, 1 \n\t" "mul DWORD PTR _height \n\t" "div DWORD PTR ebx \n\t" "mov _numBricks, eax \n\t" "pop edx \n\t" "pop ebx \n\t" "pop eax"); } int main(void) { while(1) { printf("-> "); scanf("%d", &height); if (height < 0) break; asm_tri(); printf("%d\n", numBricks); } printf("bye\n"); return 0; }