Theos PowerBasic Museum 2017

IT-Consultant: Charles Pegge => OxygenBasic => Topic started by: Charles Pegge on March 15, 2008, 12:43:26 PM

Title: O2 as a ThinBasic module
Post by: Charles Pegge on March 15, 2008, 12:43:26 PM

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
Title: Re: O2 as a ThinBasic module
Post by: Petr Schreiber on March 15, 2008, 08:17:27 PM
I like a lot this project,
I really recommend to check it out!


Petr

Title: Re: O2 as a ThinBasic module
Post by: Kent Sarikaya on March 16, 2008, 10:54:44 PM
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!!
Title: Re: O2 as a ThinBasic module - Full Dynamic Assembler with SSE2
Post by: Charles Pegge on April 14, 2008, 04:23:14 AM

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