Charles Pegge
23-08-2008, 10:43
Hi Eros
re: thinCore module sdk / Freebasic
This problem turned up when I started combining Asmosphere test programs, which involve 1 assembly pass for each test using o2_Asmo(src)
I trace the problem down to thinBasic_ParseString causing VariableGetInfoEx to yield a null pointer to a variable which definitely exists in the script. This happens after 6 thinBasic_ParseSring calls corresponfing to 6 Asmo calls in the TB script.
This is the first time I have used multiple Asmo calls which explains why the problem has gone undetected until now.
The problem does not occur with thinBasic_ParseLong
Using a FreeBasic module complicates matters but if the bug remains hidden I can try to simulate using PB.
Any way here is the TB script:
Uses "Oxygen"
Uses "File"
dim dd as double
dim vv as long
dim ss as string
ss=string$(256," ")
dim zz as asciiz*256
dim src as string
' INSERT THESE LINES TO REGRESS THE FAILURE POINT
o2_asmo "ret"
'o2_asmo "ret"
'o2_asmo "ret"
'o2_asmo "ret"
src = "
symbols {}``^;>
>this is comment
^this is a quoted string^
mov eax,3
mov ecx,3
> using curly braces instead of round brackets
> for block scoping etc
{
inc eax
dec ecx
jge repeat
}
ret
"
o2_asmo src
if len(o2_error) then
'msgbox 0,o2_exec
msgbox 0,"ZM1: "+o2_error()+o2_view (src)
stop
end if
'------------------------------------------------------
src= "
nop
; divert symbols then create macro definitions of
; brackets and comments
; (quote marks cannot be defined in this way)
symbols ///////
def begin (
def end )
def cmt ;
symbols ()```;;
; symbols now restored
; begin end cmt are now available for use
cmt this is a comment
mov eax,3
mov ecx,3
begin
inc eax
dec ecx
jge repeat
end
ret
"
o2_asmo src
if len(o2_error) then
'msgbox 0,o2_exec
msgbox 0,"ZM2: "+o2_error()+o2_view (src)
stop
end if
'------------------------------------------------------
src="
def show
(
copy0 #zz, `%1 %2 %3 %4`
)
; invoke macro but prevent %params
; from being interpreted by using incl.
incl show
ret
"
o2_asmo src
if len(o2_error) then
'msgbox 0,o2_exec
msgbox 0,"ZM3: "+o2_error()+o2_view (src)
stop
end if
'------------------------------------------------------
src="
; using %% to hide parms
def show copy0 #zz, `%e %%ok%%`
show % params
ret
"
o2_asmo src
if len(o2_error) then
'msgbox 0,o2_exec
msgbox 0,"ZM4: "+o2_error()+o2_view (src)
stop
end if
'------------------------------------------------------
src="
; the strd and vald functions
edx=data nd 42.25
strd #zz,edx
vald #dd,#zz
ret
"
o2_asmo src
if len(o2_error) then
'msgbox 0,o2_exec
msgbox 0,"ZM5: "+o2_error()+o2_view (src)
stop
end if
'------------------------------------------------------
src="
mov eax,[#vv]
; note * pointer for reading dynamic string
vald #dd,*#ss
fld qword [#dd]
fsqrt
fstp qword [#dd]
ret
"
o2_asmo src
if len(o2_error) then
'msgbox 0,o2_exec
msgbox 0,"ZM6: "+o2_error()+o2_view (src)
stop
end if
'------------------------------------------------------
re: thinCore module sdk / Freebasic
This problem turned up when I started combining Asmosphere test programs, which involve 1 assembly pass for each test using o2_Asmo(src)
I trace the problem down to thinBasic_ParseString causing VariableGetInfoEx to yield a null pointer to a variable which definitely exists in the script. This happens after 6 thinBasic_ParseSring calls corresponfing to 6 Asmo calls in the TB script.
This is the first time I have used multiple Asmo calls which explains why the problem has gone undetected until now.
The problem does not occur with thinBasic_ParseLong
Using a FreeBasic module complicates matters but if the bug remains hidden I can try to simulate using PB.
Any way here is the TB script:
Uses "Oxygen"
Uses "File"
dim dd as double
dim vv as long
dim ss as string
ss=string$(256," ")
dim zz as asciiz*256
dim src as string
' INSERT THESE LINES TO REGRESS THE FAILURE POINT
o2_asmo "ret"
'o2_asmo "ret"
'o2_asmo "ret"
'o2_asmo "ret"
src = "
symbols {}``^;>
>this is comment
^this is a quoted string^
mov eax,3
mov ecx,3
> using curly braces instead of round brackets
> for block scoping etc
{
inc eax
dec ecx
jge repeat
}
ret
"
o2_asmo src
if len(o2_error) then
'msgbox 0,o2_exec
msgbox 0,"ZM1: "+o2_error()+o2_view (src)
stop
end if
'------------------------------------------------------
src= "
nop
; divert symbols then create macro definitions of
; brackets and comments
; (quote marks cannot be defined in this way)
symbols ///////
def begin (
def end )
def cmt ;
symbols ()```;;
; symbols now restored
; begin end cmt are now available for use
cmt this is a comment
mov eax,3
mov ecx,3
begin
inc eax
dec ecx
jge repeat
end
ret
"
o2_asmo src
if len(o2_error) then
'msgbox 0,o2_exec
msgbox 0,"ZM2: "+o2_error()+o2_view (src)
stop
end if
'------------------------------------------------------
src="
def show
(
copy0 #zz, `%1 %2 %3 %4`
)
; invoke macro but prevent %params
; from being interpreted by using incl.
incl show
ret
"
o2_asmo src
if len(o2_error) then
'msgbox 0,o2_exec
msgbox 0,"ZM3: "+o2_error()+o2_view (src)
stop
end if
'------------------------------------------------------
src="
; using %% to hide parms
def show copy0 #zz, `%e %%ok%%`
show % params
ret
"
o2_asmo src
if len(o2_error) then
'msgbox 0,o2_exec
msgbox 0,"ZM4: "+o2_error()+o2_view (src)
stop
end if
'------------------------------------------------------
src="
; the strd and vald functions
edx=data nd 42.25
strd #zz,edx
vald #dd,#zz
ret
"
o2_asmo src
if len(o2_error) then
'msgbox 0,o2_exec
msgbox 0,"ZM5: "+o2_error()+o2_view (src)
stop
end if
'------------------------------------------------------
src="
mov eax,[#vv]
; note * pointer for reading dynamic string
vald #dd,*#ss
fld qword [#dd]
fsqrt
fstp qword [#dd]
ret
"
o2_asmo src
if len(o2_error) then
'msgbox 0,o2_exec
msgbox 0,"ZM6: "+o2_error()+o2_view (src)
stop
end if
'------------------------------------------------------