print floating pt using xmm0
Peter Johnson
peter at tortall.net
Thu Oct 26 21:41:24 PDT 2006
It appears the AMD64 ABI for varargs functions requires all 8-byte double
values. The printf function is varargs, so all floats are passed as
doubles. A "normal" function call that has float in the arguments list
takes it as a 4-byte value.
(above per disassembly of GCC output on Linux/amd64)
Peter
On Thu, 26 Oct 2006, Vikas N Kumar wrote:
> But what is wrong with using cvtsi2ss ?
> I want to print a 4byte floating point as opposed to a 8byte double .
>
> Thanks
> Vikas
>
> On 10/26/06, Peter Johnson <peter at tortall.net> wrote:
>> You need to use cvtsi2sd, not cvtsi2ss.
>>
>> Peter
>>
>> On Thu, 26 Oct 2006, Vikas N Kumar wrote:
>>
>>> Hi All
>>> Below is my code to print a floating point number which has been
>>> loaded into XMM0 register.
>>> For some reason it always prints 0.0000. I am not able to figure it
>>> out. Could anyone let me know what I am doing wrong here ? It seems
>>> right based on the manual.
>>>
>>> section .data
>>> fltprmpt db "%f",10,0
>>>
>>> section .text
>>>
>>> global main
>>> extern printf
>>>
>>> main:
>>> enter 0,0
>>> mov rdi, dword fltprmpt
>>> mov rdx, 10
>>> cvtsi2ss xmm0, edx
>>> mov rax, 1
>>> call printf
>>> leave
>>> ret
>>>
>>> Regards,
>>> Vikas
>>> --
>>> http://www.vikaskumar.org/
>>> _______________________________________________
>>> yasm-devel mailing list
>>> yasm-devel at tortall.net
>>> http://cvs.tortall.net/mailman/listinfo/yasm-devel
>>>
>>
>
>
> --
> http://www.vikaskumar.org/
> _______________________________________________
> yasm-devel mailing list
> yasm-devel at tortall.net
> http://cvs.tortall.net/mailman/listinfo/yasm-devel
>
More information about the yasm-devel
mailing list