Page 1 of 5 123 ... LastLast
Results 1 to 10 of 46

Thread: The Asmosphere Assembler

  1. #1

    The Asmosphere Assembler

    Updated 22 June 2008
    Performance improvements

    Oxygen / Asmosphere is now available here:

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


  2. #2

    Re: The Asmosphere Assembler

    W.....o......W

    THANK YOU!!!!

  3. #3
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,777
    Rep Power
    10

    Re: The Asmosphere Assembler

    "wow" is the right word.
    It is far from my knowledge. It seems so complex for my poor ASM understanding.
    It is a great module done with big generosity: sources are included so all can take advantages studing it.

    Thanks a lot
    Eros
    www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

  4. #4

    Re: The Asmosphere Assembler

    There's the rest of the instruction set to come but this establishes the basic principle.

    I am also working on procs and string literals so it should be possible to do this directly with system calls:

    Proc MessageBox$ 0,"foo","bar",0

    or

    Proc GetProcAddress$ foo,"bar"

    This will save a lot of assembly code lines

  5. #5
    thinBasic MVPs kryton9's Avatar
    Join Date
    Nov 2006
    Location
    Naples, Florida & Duluth, Georgia
    Age
    67
    Posts
    3,869
    Rep Power
    404

    Re: The Asmosphere Assembler

    Thanks Charles, looking forward to tinkering with this in due time!
    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

  6. #6
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,128
    Rep Power
    732

    Re: The Asmosphere Assembler

    Where am I when things move here ,

    so please accept a bit delayed WOW from my side too!
    I am leaving now till the evening, but looking forward to spent the night with mov, add, inc and other friends from the assembly quarter


    Thanks a lot,
    incredible job,
    Petr
    Learn 3D graphics with ThinBASIC, learn TBGL!
    Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB

  7. #7

    Re: The Asmosphere Assembler

    Hi Petr, you may like to try today's update which supports string literals and system calls. Doesn't look much like assembler but it saves many lines of code.

    One word of caution: There is no protection against recursive macros yet. If a macro invokes itself, directly or indirectly, it will expand until your PC runs out of system memory. ;D

    This is a MessageBox Hello World:
    The latest update is posted at the beginning of this thread

    [code=thinbasic]

    'ASMOSPHERE DEMO
    '---------------

    ' showing use of def (macros) and proc (procedures) to make system calls

    Uses "Oxygen"


    '---------------------------------------------------------------------------
    '---Reference:
    '---http://developer.intel.com/design/pentiumii/manuals/243191.htm
    '---------------------------------------------------------------------------


    DECLARE FUNCTION LoadLibrary LIB "KERNEL32.DLL" _
    ALIAS "LoadLibraryA" _
    (lpLibFileName AS ASCIIZ) AS LONG

    DECLARE FUNCTION FreeLibrary LIB "KERNEL32.DLL" _
    ALIAS "FreeLibrary" _
    (BYVAL hLibModule AS DWORD) AS LONG

    DECLARE FUNCTION GetProcAddress LIB "KERNEL32.DLL" _
    ALIAS "GetProcAddress" _
    (BYVAL hModule AS DWORD, lpProcName AS ASCIIZ) AS LONG



    'SYSTEM INTERFACE
    '----------------

    dim iKernelLib as long = LoadLibrary("Kernel32.dll")
    dim iLoadLibrary as long = GetProcAddress(iKernelLib, "LoadLibraryA")
    dim iFreeLibrary as long = GetProcAddress(iKernelLib, "FreeLibrary")
    dim iGetProcAddress as long = GetProcAddress(iKernelLib, "GetProcAddress")

    'THINBASIC VARIABLES INTERFACE
    '------------------------------

    dim vv(16) as long
    dim ff(16) as single


    if (iLoadLibrary)and(iFreeLibrary)and(iGetProcAddress) then


    'SOURCE CODE
    '-----------

    dim src as string="

    'DEFINE MACROS

    def greet `Hello World!`
    def Meaning_of_Life 42
    def UserLib [ebx]
    def iMessageBox [ebx+04]

    def LoadLibrary proc [#iLoadLibrary]
    def FreeLibrary proc [#iFreeLibrary]
    def GetProcAddress proc [#iGetProcAddress]
    def MessageBox proc iMessagebox$


    'PRESERVE VITAL REGISTERS

    push ebx

    'SETUP POINTER TO THINBASIC VARIABLES

    mov ebx,#vv

    'LOAD LIBRARY

    proc [#iLoadLibrary] `LoadLibraryA`

    LoadLibrary$ `User32.dll`
    mov UserLib$,eax

    ' GET PROC ADDRESS IN VV(2)

    GetProcAddress$ UserLib$ ,`MessageBoxA`
    mov iMessageBox$, eax

    'INVOKE

    MessageBox$ 0,greet$,`Asm Proc Test`,0

    'FREE LIBRARY

    FreeLibrary$ UserLib$


    'RESTORE VITAL REGISTERS

    pop ebx

    'RETURN OK VALUE

    mov eax, Meaning_of_Life$
    ret
    "

    'ASSEMBLE
    '--------

    dim cod as string=O2_asm(src)

    'EXECUTE OR REPORT ERROR
    '-----------------------

    if asc(cod)=&hc3 then
    MsgBox 0,"ERROR:"+$crlf+O2_Error+$crlf+$crlf+_
    "CODE:"+$crlf+O2_View(src)
    else
    dim retval as long
    retval = MC_Exec (cod)
    'MsgBox 0,"RESULT"+$crlf+retval+$crlf+$crlf+_
    '"CODE:"+$crlf+O2_View(src)
    end if


    end if

    'FINISH
    '------

    if iKernelLib then FreeLibrary(iKernelLib)

    [/code]

  8. #8
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,777
    Rep Power
    10

    Re: The Asmosphere Assembler

    That is magic Charles!
    www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

  9. #9
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,128
    Rep Power
    732

    Re: The Asmosphere Assembler

    Thanks Charles,

    this makes coding speed criticall parts a lot easier


    Great,
    Petr

    Learn 3D graphics with ThinBASIC, learn TBGL!
    Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB

  10. #10

    Re: The Asmosphere Assembler


    New update at the beginning of this thread

    This example works with e the latest update which supports hi-level syntax for using system functions. eg:

    MessageBox 0,greet,`Asm Proc Test`,0

    or

    MessageBox (0,greet,`Asm Proc Test`,0)


    Return values are also supported (values returned in EAX only)

    Userlib=LoadLibrary (`User32.dll`)

    The brackets are optional

    [code=thinbasic]


    'ASMOSPHERE DEMO
    '---------------

    ' showing use of def (macros) and proc (procedures) to make system calls
    ' Supports standard syntax used by C,Basic etc

    Uses "Oxygen"


    '---------------------------------------------------------------------------
    '---Reference:
    '---http://developer.intel.com/design/pentiumii/manuals/243191.htm
    '---------------------------------------------------------------------------


    DECLARE FUNCTION LoadLibrary LIB "KERNEL32.DLL" _
    ALIAS "LoadLibraryA" _
    (lpLibFileName AS ASCIIZ) AS LONG

    DECLARE FUNCTION FreeLibrary LIB "KERNEL32.DLL" _
    ALIAS "FreeLibrary" _
    (BYVAL hLibModule AS DWORD) AS LONG

    DECLARE FUNCTION GetProcAddress LIB "KERNEL32.DLL" _
    ALIAS "GetProcAddress" _
    (BYVAL hModule AS DWORD, lpProcName AS ASCIIZ) AS LONG



    'SYSTEM INTERFACE
    '----------------

    dim iKernelLib as long = LoadLibrary("Kernel32.dll")
    dim iLoadLibrary as long = GetProcAddress(iKernelLib, "LoadLibraryA")
    dim iFreeLibrary as long = GetProcAddress(iKernelLib, "FreeLibrary")
    dim iGetProcAddress as long = GetProcAddress(iKernelLib, "GetProcAddress")

    'THINBASIC VARIABLES INTERFACE
    '------------------------------

    dim vv(16) as long
    dim ff(16) as single


    if (iLoadLibrary)and(iFreeLibrary)and(iGetProcAddress) then


    'SOURCE CODE
    '-----------

    dim src as string="

    def greet `Hello World!`
    def Meaning_of_Life 420.4200e-1
    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)
    mov eax, Meaning_of_Life
    add esp,workspace
    pop ebp
    ret
    "

    'ASSEMBLE
    '--------

    dim cod as string=O2_asm(src)

    'EXECUTE OR REPORT ERROR
    '-----------------------

    if asc(cod)=&hc3 then
    MsgBox 0,"ERROR:"+$crlf+O2_Error+$crlf+$crlf+_
    "CODE:"+$crlf+O2_View(src)
    else
    dim retval as long
    retval = MC_Exec (cod)
    'MsgBox 0,"RESULT"+$crlf+retval+$crlf+$crlf+_
    '"CODE:"+$crlf+O2_View(src)
    end if


    end if

    'FINISH
    '------

    if iKernelLib then FreeLibrary(iKernelLib)
    [/code]

Page 1 of 5 123 ... LastLast

Similar Threads

  1. x86 assembler...
    By Johannes in forum BigInt module. Big Integer handling by Johannes
    Replies: 6
    Last Post: 06-03-2011, 23:53
  2. Assembler on GPU, from ATi resources
    By Petr Schreiber in forum TBGL General
    Replies: 1
    Last Post: 16-07-2008, 00:34

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
  •