• Primitive External Library Interface for kForth-64

    From Krishna Myneni@21:1/5 to All on Mon Dec 25 22:17:31 2023
    Although I wanted to finish the 64-bit assembler for kForth-64 (a 64-bit version of asm-x86.4th) prior to implementing the ability to set up a
    library interface for mapping and calling C functions in external shared
    object libraries to Forth words, my priority now is to go ahead and get
    a library interface working for kForth-64 (the 64-bit assembler is still
    in progress, though).

    A primitive external library interface is now available for kForth-64
    (using machine code). It is not yet full-featured enough to accomodate a
    wide range of function argument cases, but the interface illustrates the mechanics of calling external C library functions. Two complications
    make the 64-bit interface a bit more complicated to implement, over the simpler, but more advanced library interface found in kForth-32:

    1. Function arguments are located in registers, rather than on the CPU
    stack for the amd-64 calling convention.

    2. The 64-bit version of kForth provides a separate fp stack, in line
    with the Forth 200x standard.

    An example of the use of the library interface for calling a portion of
    the GNU GMP multiprecision library may be found at the link below.

    https://github.com/mynenik/kForth-64/tree/master/forth-src/libs/gmp

    Fair Warning: the library interface is in a state of development and may
    change so that call methods in future versions may not be backwards
    compatible with the (incomplete) existing call methods.

    --
    Krishna Myneni

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Krishna Myneni@21:1/5 to Krishna Myneni on Wed Jan 17 09:01:06 2024
    On 12/25/23 22:17, Krishna Myneni wrote:
    Although I wanted to finish the 64-bit assembler for kForth-64 (a 64-bit version of asm-x86.4th) prior to implementing the ability to set up a
    library interface for mapping and calling C functions in external shared object libraries to Forth words, my priority now is to go ahead and get
    a library interface working for kForth-64 (the 64-bit assembler is still
    in progress, though).

    A primitive external library interface is now available for kForth-64
    (using machine code). It is not yet full-featured enough to accomodate a
    wide range of function argument cases, but the interface illustrates the mechanics of calling external C library functions. Two complications
    make the 64-bit interface a bit more complicated to implement, over the simpler, but more advanced library interface found in kForth-32:

    1. Function arguments are located in registers, rather than on the CPU
    stack for the amd-64 calling convention.

    2. The 64-bit version of kForth provides a separate fp stack, in line
    with the Forth 200x standard.

    An example of the use of the library interface for calling a portion of
    the GNU GMP multiprecision library may be found at the link below.

    https://github.com/mynenik/kForth-64/tree/master/forth-src/libs/gmp

    Fair Warning: the library interface is in a state of development and may change so that call methods in future versions may not be backwards compatible with the (incomplete) existing call methods.

    ...

    The MPFR multiprecision library is now usable in kForth-64.

    https://github.com/mynenik/kForth-64/tree/master/forth-src/libs/gmp

    Again, the current library interface in kForth-64 is not set in stone
    and may change.

    --
    KM

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)