/* Copyright 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 .text double_fmt: .string "%G\n" eflags_fmt: .string "0x%x\n" reg_fmt: .string "0x%x\n" .macro print_reg reg pusha pushl \reg pushl $reg_fmt call printf addl $8,%esp popa .endm proc print_eflags movl $0,%eax lahf pushl %eax pushl $eflags_fmt call printf addl $8,%esp ret /* This expects an address for a double to be in %eax */ proc print_double pushl 4(%eax) #double part 2 pushl (%eax) #double part 1 pushl $double_fmt call printf addl $12,%esp ret proc main movl $EXIT_SUCCESS,%eax ret