Assembly Language Programming (intel 32 bit) under Unix. A. Slightly easier way 1. Make a library of functions so that you don't have to deal with stdio $ cat ass.c #include void printi(int n) { printf("%d", n); } void prints(char * s) { printf("%s", s); } void printc(char c) { printf("%c", c); } int readi(void) { int n; scanf("%d", & n); return n; } $ cc -c ass.c 2. Here is a complete assembly language file, with its own main, that uses that library $ cat assex.s .file "assex.s" .text .p2align 2,,3 .globl semblyfn .type semblyfn, @function semblyfn: pushl %ebp movl %esp, %ebp subl $4, %esp movl 8(%ebp), %eax addl 12(%ebp), %eax movl %eax, -4(%ebp) pushl %eax call printi addl $4, %esp pushl $10 call printc addl $4, %esp movl -4(%ebp), %eax incl %eax addl $8, %esp leave ret .size semblyfn, .-semblyfn .p2align 2,,3 .globl main .type main, @function main: pushl %ebp movl %esp, %ebp pushl $123 pushl $101 call semblyfn addl $8, %esp movl $0, %eax leave ret .size main, .-main $ cc assex.s ass.o $ a.out 224 B. Just stand-alone assembly $ cat examp.s .file "examp.s" .section .rodata .format1: .string "%d + %d is %d\n" .text .p2align 2,,3 .globl main .type main, @function main: pushl %ebp movl %esp, %ebp subl $8, %esp movl $123, %eax movl %eax, -4(%ebp) movl $202, %eax movl %eax, -8(%ebp) movl -4(%ebp), %eax addl -8(%ebp), %eax pushl %eax pushl -8(%ebp) pushl -4(%ebp) pushl $.format1 call printf addl $12, %esp movl $0, %eax addl $8, %esp leave ret .size main, .-main $ cc examp.s $ a.out 123 + 202 is 325