Author Topic: Question about quads  (Read 3088 times)

0 Members and 1 Guest are viewing this topic.

jack

  • Guest
Re: Question about quads
« Reply #15 on: August 13, 2018, 05:26:05 PM »
I am confused about this statement: "Floating-point and double-precision arguments are passed in XMM0 - XMM3 (up to 4) with the integer slot (RCX, RDX, R8, and R9) that would normally be used for that cardinal slot being ignored (see example) and vice versa."
it's the second part that confuses me, can someone explain?

Charles Pegge

  • Guest
Re: Question about quads
« Reply #16 on: August 13, 2018, 07:10:41 PM »
In the early days, I had to do a lot of testing to disambiguate such statements.

The first 4 parameters are passed in xmm registers for floats, and cpu registers for non-floats.

Floats: xmm0 xmm1 xmm2 xmm3
non floats: rcx rdx r8 r9


Supposing you had a mix of floats and non-floats:

foo(int a,float b, int c, float d)

They would be passed to foo something like this:
Code: [Select]
sub rsp,32 'create spill zone for 4 registers on the stack
mov eax,a
movss xmm1,b
mov r8d,c
movss xmm3,d
call foo
add rsp,32 'restore stack pointer position

Another example:

bah(double a,quad b, double c, quad d)

Code: [Select]
sub rsp,32 'create spill zone for 4 registers on the stack
movsd xmm0,a
mov rdi,b
movsd xmm2,c
mov r9,d
call bah
add rsp,32 'restore stack pointer position

« Last Edit: August 13, 2018, 07:21:31 PM by Charles Pegge »

Arnold

  • Guest
Re: Question about quads
« Reply #17 on: August 14, 2018, 02:22:56 AM »
Hi Charles,

your cformat function is brilliant. I experimented a little bit with the format specifiers and the results are promising.
I also found a specifier for quads, which only works with Win64:

Code: [Select]
$ filename "Ranges4.exe"
'use rtl32
use rtl64

uses corewin
uses console

function cformat(char*f, ...) as string
=======================================
...
   double d, quad q
   d=(2^64)-1 : printl "2^64-1 = " cformat( "%f" , d )  '18446744073709552000

   q=-0x2 : printl "2^64-2 = " cformat( "%I64u" , q )   '18446744073709551614
   q=-0x1 : printl "2^64-1 = " cformat( "%I64u" , q )   '18446744073709551615   
   
printl "Enter: ... " : waitkey

In Win64 I get the precise results. But I do not understand the effects of hex -0x2, -0x1 and if it would be possible to achieve these results in Win32 too. I wished I could master some of these tricks as well.

Roland

jack

  • Guest
Re: Question about quads
« Reply #18 on: August 14, 2018, 03:01:09 AM »
thank you Charles Pegge :)