/* 2005 George Peter Staplin */ .global main .macro proc name .align 4 \name: .endm .macro save reg pushl \reg .endm .macro restore reg popl \reg .endm .equ EXIT_SUCCESS,0 .data .align 4 /* * This needs to be in the .data segment, so that it's writable. */ stream: .long 0 .text str: .string "hello" f: .string "myfile" mode: .string "w" proc main pushl $mode pushl $f call fopen addl $8,%esp #stack cleanup /* * Check for NULL from fopen. */ cmpl $0,%eax jne 1f call abort #horrible/quick error handling ;) 1: movl %eax,stream /* * Begin calling fputs. * int fputs(const char * restrict str, FILE * restrict stream); */ pushl stream pushl $str call fputs addl $8,%esp #cleanup the stack movl $EXIT_SUCCESS,%eax ret