# copyright -- Ivan Novick -- Jan-2008 -- ivan at 0x4849 dot net # x86 assembly -- use printf to print a floating point number # # as -o hello_float.o hello_float.s # ld -dynamic-linker /lib/ld-linux.so.2 -o hello_float -lc hello_float.o ############################################# .section .data y: .double 8.213 message: .asciz "Hello float: %.2lf\n" ############################################# .section .text .globl _start _start: # load the double into the floating registers fldl y # make room for an 8 byte double on the stack subl $8, %esp # load the double from the floating register to the top of the stack fstpl 0(%esp) # push the message text address onto the stack pushl $message # call lib c call printf # pop the data off the stack that was used addl $12, %esp # exit system call movl $1, %eax movl $0, %ebx int $0x80