Author Topic: O2 as a ThinBasic module  (Read 4263 times)

0 Members and 1 Guest are viewing this topic.

Offline Charles Pegge

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 734
    • Charles Pegge
O2 as a ThinBasic module
« 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

Offline Petr Schreiber

  • Sr. Member
  • ****
  • Posts: 411
Re: O2 as a ThinBasic module
« Reply #1 on: March 15, 2008, 08:17:27 PM »
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

Offline Kent Sarikaya

  • Sr. Member
  • ****
  • Posts: 368
Re: O2 as a ThinBasic module
« Reply #2 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!!

Offline Charles Pegge

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 734
    • Charles Pegge
Re: O2 as a ThinBasic module - Full Dynamic Assembler with SSE2
« Reply #3 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.)
Code: [Select]
    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