Results 1 to 4 of 4

Thread: High speed links between Asmosphere and thinBasic Modules

  1. #1

    High speed links between Asmosphere and thinBasic Modules


    This is an idea for establishing direct 3 way linkage between Asmosphere, thinBasic and thinBasic Modules. By using pointers both functions and data can be shared between the three parties without any mediating code, achieving very high performance wherever it is needed. The virtual table function, mtable is easy to add to any module (both PB and FB examples included in the zip below.)

    First a thinBasic script:
    [code=thinbasic]
    '

    Uses "Oxygen"
    Uses "MyPBModule"
    dim tbl as long = mm_table
    dim result as long

    dim src as string = "

    ;build interface
    ;---------------

    def mymodule (mov edx,[#tbl]
    )
    def func1 proc [edx+04]
    def func2 proc [edx+08]
    def func3 proc [edx+12]
    def result [#result]

    ;try func1
    ;---------

    result=mymodule func1 6
    ret
    "

    'run the code
    '------------
    o2_asmo src
    o2_exec
    msgbox 0,result

    'msgbox 0,o2_error()+o2_view (src)
    [/code]

    This is a PowerBasic skeleton module showing the virtual table interface with function pointers. Other variables can also be placed in the same table.

    [code=thinbasic]
    'Skeleton Module "thinBasic_MyPBModule.bas"

    #compile dll

    '#include once "win32api.inc"
    '#include "thinCore.inc"

    function func1(byval a as long) as long
    function=a*7
    end function

    function func2() as long
    function=0
    end function

    function func3() as long
    function=0
    end function


    function mtable() as long
    dim tbl(10) as static long
    tbl(1)=codeptr(func1)
    tbl(2)=codeptr(func2)
    tbl(3)=codeptr(func3)
    function=varptr(tbl(0))
    end function

    DECLARE FUNCTION thinBasic_LoadSymbol _
    LIB "thinCore.DLL" _
    ALIAS "thinBasic_LoadSymbol" _
    ( _
    BYVAL SymbolName AS STRING, _
    BYVAL ReturnCode AS LONG, _
    BYVAL FunctionOrSubPointer AS DWORD, _
    OPTIONAL BYVAL ForceOverWrite AS LONG _
    ) AS LONG
    '----------------------------------------------------------------------------

    %thinBasic_ReturnCodeLong= 5
    %thinBasic_ForceOverWrite= 1
    '
    function LoadLocalSymbols Cdecl ALIAS "LoadLocalSymbols" (BYVAL sPath AS STRING) export AS Long
    thinBasic_LoadSymbol "mm_table", %thinBasic_ReturnCodeLong, codeptr(mtable), %thinBasic_ForceOverWrite
    function=0
    end function


    Function UnLoadLocalSymbols Cdecl ALIAS "UnLoadLocalSymbols" (BYVAL sPath AS STRING) export AS Long
    function=0
    end function
    [/code]
    Attached Files Attached Files

  2. #2
    thinBasic MVPs kryton9's Avatar
    Join Date
    Nov 2006
    Location
    Naples, Florida & Duluth, Georgia
    Age
    68
    Posts
    3,865
    Rep Power
    405

    Re: High speed links between Asmosphere and thinBasic Modules

    This is a good idea Charles. Probably how these tools will be used together most often I would think.

    Acer Notebook: Win 10 Home 64 Bit, Core i7-4702MQ @ 2.2Ghz, 12 GB RAM, nVidia GTX 760M and Intel HD 4600
    Raspberry Pi 3: Raspbian OS use for Home Samba Server and Test HTTP Server

  3. #3
    thinBasic MVPs Michael Hartlef's Avatar
    Join Date
    Sep 2006
    Location
    Germany
    Age
    58
    Posts
    3,299
    Rep Power
    348

    Re: High speed links between Asmosphere and thinBasic Modules

    Maybe this is also a way for modules to communicate with each other.

  4. #4

    Re: High speed links between Asmosphere and thinBasic Modules


    Providing high level and low level interfaces by adding pointers and virtual tables is like COM - though I'm not suggesting we take on the full COM baggage.

Similar Threads

  1. For those developing thinBasic modules
    By ErosOlmi in forum Suggestions/Ideas discussions
    Replies: 4
    Last Post: 23-03-2008, 08:18

Members who have read this thread: 0

There are no members to list at the moment.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •