2009-08-15 11 views

답변

8

여기에 한 가지 방법 (86 libc는 NASM)

이되는이 질문은 당신이 (아키텍처, 시스템 콜 또는 libc의, 가스 또는 NASM, 출력 형식 등)보다 구체적인없이 대답 할 수있는 방법을 많이하지만
bits 32 

section .text 

extern printf 
global main 

main: 
    fldpi ; load pi onto FPU stack 
    sub esp, 8 ; make space on CPU stack 
    fstp qword [esp] ; pop from FPU stack and store on CPU stack (parameter 2 of printf) 
    push format ; stack the format string (parameter 1 of printf) 
    call printf 
    add esp,12 ; restore stack (4 btyes address + 8 bytes float) 
    xor eax,eax ; set eax (return value) to 0 
    ret ; return to libc 

section .data 

format: db "%.20g",10,0 

출력 : 3.141592653589793116

+0

답변을 입력하기 시작했을 때, 당신이 펑펑 들었을 때 ;-) – hirschhornsalz