• Welcome to Theos PowerBasic Museum 2017.

O2 as a ThinBasic module

Started by Charles Pegge, March 15, 2008, 12:43:26 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Charles Pegge


We are experimenting with machine code in ThinBasic!

In the latest preview version, Eros has added functions to enable machine code to be executed within TB. To add block structured programming capability, I have generated a thinBasic module version of O2.

This has many potential uses such as speeding up programs in critical areas - processing large arrays of data etc. TB variables of all types can be linked directly to the machine code with or without O2.

Also thinking about creating an Assembler along the same lines, using the standard Intel notation. In a scripting environment, Assembler can be generated on the fly, customised for a specific task, then disposed of when finished. - like a local variable.

http://community.thinbasic.com/index.php?board=149.0

Petr Schreiber

I like a lot this project,
I really recommend to check it out!


Petr

AMD Sempron 3400+ | 1GB RAM @ 533MHz | GeForce 6200 / GeForce 9500GT | 32bit Windows XP SP3

psch.thinbasic.com

Kent Sarikaya

This is all very exciting and to even consider intel based Assembler will be a great way to play with and hopefully learn a way to tap into this power!!

Charles Pegge


A complete dynamic assembler for ThinBasic including the Streaming SIMD extensions:

This has a preprocessor layer to facilitate system calls using Basic/C compatible syntax, and Uses the O2 function to produce the executable.

http://community.thinbasic.com/index.php?topic=1637.0

This includes the FreeBasic source code for the module. It is written in an elementary form of Basic so it would be very easy to translate to PB.

This example illustrates the preprocessor syntax - linking and executing DLL calls, and also demonstrates how to get local workspace on the stack. (Round brackets may be used to enclose the call parameters but they are not necessary.)

    def greet           `Hello World!`
    def UserLib         [ebp-04]
    def iMessageBox     [ebp-08]
    def workspace       16     
    def LoadLibrary     proc [#iLoadLibrary]
    def FreeLibrary     proc [#iFreeLibrary]
    def GetProcAddress  proc [#iGetProcAddress]
    def MessageBox      proc iMessagebox$   
    '------------------------------------
    push ebp
    mov ebp,esp
    sub esp,workspace
    Userlib=LoadLibrary `User32.dll`
    iMessageBox=GetProcAddress  UserLib ,`MessageBoxA`
    MessageBox 0,greet,`Asm Proc Test`,0
    FreeLibrary UserLib
    add esp,workspace
    pop ebp
    ret