MODULE O2
include "dllcinc.sb"
oxy=dllfile("/scriptbasic/Debugger/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
function getword(char*ss,sys*b) as char*
'=======================================
if b=0 then b=1
byte s at @ss
byte c,d
sys bb,bc
static char z[128]
a=0
bb=b
'SKIP LEADING SPACES
do
c=s[b]
select c
case 33 to 255,0 : exit do 'SKIP SPACE
end select
b++
end do
bc=b
'
'QUOTES
select c
case 34,39
do
b+=1
d=s[b]
if d=0 or d=c then b+=1 : jmp fwd done
end do
end select
'WORDS AND SYMBOLS
do
c=s[b]
select c
case 0 to 32 : exit do
case 35 : jmp fwd more
case 33 to 47 : 'symbols
case 48 to 57 : jmp fwd more 'numbers
case 58 to 64 : 'symbols
case 65 to 90 : jmp fwd more 'capitals
case 95 : jmp fwd more 'underscore
case 91 to 96 : 'symbols
case 97 to 122 : jmp fwd more 'lower case
case 123 to 127 : 'symbols
case 128 to 255 : jmp fwd more 'higher ascii
end select
if b=bc then b++
exit do
more:
b++
end do
done:
if b > bb then
z=mid ss,bc,b-bc
else
z = ""
end if
return z
end function
sub finish()
'===========
terminate
end sub
function link(sys n) as sys
'==========================
select n
case 0 : return @finish
case 1 : return @reverse
case 2 : return @getword
end select
end function
end extern
addr link
"""
a = oxygen(src)
Finish = dllproc(a,"Finish ()", dllcald(a,0))
Reverse = dllproc(a,"Reverse (c*value)", dllcald(a,1))
Words = dllproc(a,"getword c* = (c* strraw, i* start)", dllcald(a,2))
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
FUNCTION RevStr(strarg)
dllcall(Reverse, strarg)
RevStr = strarg
END FUNCTION
FUNCTION GetWords(strarg, longarg)
GetWords = dllcall(Words, strarg, longarg)
END FUNCTION
FUNCTION Done
rtnval = dllcall(Finish)
dllfile
Done = rtnval
END FUNCTION
END MODULE