<html><body style="font-family: Helvetica,Arial,sans-serif; font-size: 12px;">Greetings,<div><br></div><div>Made the mistake of running the FFI unit tests in Cuis, which directly led me down the rabbit hole.</div><div><br></div><div>Think I have made some progress in understanding, but don't yet see how to teach VMMaker to get code from register.</div><div><br></div><div>Here is crux of one of my investigations:</div><div>==============================</div><div><br></div><div>===== C source ======sqFFITestFuncs.c<br>
<br>
/* test passing and returning doubles */<br>
EXPORT(double) ffiTestDoubles(double d1, double d2) {<br>
        printf("The two floats are %f and %f\n", (float)d1, (float)d2);<br>
        return d1+d2;<br>
}<br>
<br>
===== ASM === from objectdump -d<br>
0000000000000ac0 <ffiTestDoubles>:<br>
     ac0:       a9be7bfd        stp     x29, x30, [sp, #-32]!<br>
     ac4:       90000000        adrp    x0, 0 <ffiTestChars><br>
     ac8:       91000000        add     x0, x0, #0x0<br>
     acc:       910003fd        mov     x29, sp<br>
     ad0:       6d0127e8        stp     d8, d9, [sp, #16]<br>
     ad4:       1e604009        fmov    d9, d0<br>
     ad8:       1e604028        fmov    d8, d1<br>
     adc:       1e624000        fcvt    s0, d0<br>
     ae0:       1e624021        fcvt    s1, d1<br>
     ae4:       1e22c000        fcvt    d0, s0<br>
     ae8:       1e22c021        fcvt    d1, s1<br>
     aec:       94000000        bl      0 <printf><br>
     af0:       1e682920        fadd    d0, d9, d8<br>
     af4:       6d4127e8        ldp     d8, d9, [sp, #16]<br>
     af8:       a8c27bfd        ldp     x29, x30, [sp], #32<br>
     afc:       d65f03c0        ret<br>
// result returned in d0 (NB: _not_ x0)<br>
=================Cuis Workspace (after FFI unit test)===========<br>
FFITestLibrary ffiTestDoubles: 30.0 with: 65.0. <br>
"--> 00.00558872584952 -- should be 95.0"<br>
=================Terminal Output===================================<br>
The two floats are 30.000000 and 65.000000<br>
===================================================================<br>
FFIPlugin>>ffiCreateReturnOop: retVal<br>
...<br>
  <br>
        ^interpreterProxy floatObjectOf: (self ffiReturnFloatValue).<br>
====================================================================<br>
My theory: return value taken from x0, not d0.==============================================Is this a sensible interpretation?Any hints from Heloise?<br>Thanks much,-KenDPS: Merry Christmas!  (I would use Xmas, but who knows what is lurking under the X?  8^)<br></div><div><br></div><div><br></div></body></html>