Hi John, Mike
There are a number of DLLCO2 examples in ProjectsB/ScriptBasic/DLLC/
They require Oxygen for JIT compiling, as well as DLLC.
I'll zip the whole folder below, since I've been editing a few of the examples.
Here is a piece of Assembly code working in SB. It is treated just like any other o2 function source code.
dllco2_EAsm
include "dllcinc.sb"
oxy=dllfile("/scriptbasic/modules/oxygen.dll")
o2_basic = dllproc( oxy, "o2_basic i =(c*source) " )
o2_exec = dllproc( oxy, "o2_exec i =(i call) " )
o2_error = dllproc( oxy, "o2_error c*=() " )
o2_errno = dllproc( oxy, "o2_errno i =() " )
o2_len = dllproc( oxy, "o2_len i =() " )
o2_mode = dllproc( oxy, "o2_mode (i mode) " )
dllcall o2_mode,1
' ==============================
src="""
extern
function reverse(char*s)
========================
addr ecx,s
mov edx,0
.rlen
mov al,[ecx]
cmp al,0
jz xlen
inc edx
inc ecx
jmp rlen
.xlen
;
addr ecx,s
add edx,ecx
dec ecx
;
.rswap
inc ecx
dec edx
cmp edx,ecx
jle xswap
mov al,[ecx]
mov ah,[edx]
mov [ecx],ah
mov [edx],al
jmp rswap
.xswap
end function
sub finish()
terminate
end sub
function link(sys n) as sys
select n
case 0 : return @finish
case 1 : return @reverse
end select
end function
end extern
addr link
"""
' ==============================
function oxygen(src)
dllcall o2_basic,src
if (dllcall(o2_errno)<>0) then
dllprnt dllcall(o2_error)
a=0
else
a=dllcall(o2_exec,0)
end if
oxygen=a
end function
'
a=oxygen(src)
'
if (a<>0) then
'
' ==============================
'
Finish = dllproc(a,"Finish () ", dllcald(a,0) )
Reverse = dllproc(a,"Reverse (c*value) ", dllcald(a,1) )
'
' ==============================
'
s="abcdef1234567"
print "Reversed " & s & " = "
dllcall(Reverse,s)
print s & "\n"
dllcall(Finish)
'
end if
dllfile
line input q
.