W.....o......W
THANK YOU!!!!
Updated 22 June 2008
Performance improvements
Oxygen / Asmosphere is now available here:
http://community.thinbasic.com/index.php?topic=1845
W.....o......W
THANK YOU!!!!
"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
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
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
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
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]
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
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
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]
Bookmarks