//---------------------------------------------------------------- // demo2.s // // This is the same program as 'demo1.c' but rewritten using // the GNU assembly language for Intel Pentium processors. // // assemble using: $ as demo2.s -o demo2.o // $ gcc demo2.o -o demo2 // // or in one step: $ gcc demo2.s -o demo2 // // programmer: ALLAN CRUSE // written on: 27 AUG 2003 //---------------------------------------------------------------- .section .data x: .int 4 y: .int 5 .comm z, 4 fmt: .string "%d + %d = %d \n" .section .text main: movl x, %eax addl y, %eax movl %eax, z pushl z pushl y pushl x pushl $fmt call printf addl $16, %esp ret .global main