Gas64 (no more use of gcc, only gas) WDS / LNX

User projects written in or related to FreeBASIC.
Post Reply
wallyg
Posts: 267
Joined: May 08, 2009 7:08
Location: Tucson Arizona

Re: Gas64 (no more use of gcc, only gas) WDS / LNX

Post by wallyg »

I just ran the latest FB compiler for 64-bit using GAS64 and am getting a lot of weird messages.

About No such instruction Found an Error: virtual register 390 no real register corresponding KREG_XXX

....

junk X_D after expression

....

Bad expression

and it terminates with an error code 1

I have a screen print of the errors but do not know how to get a JPG image to you?

WinFBE will abort if I try to cut/copy the messages from the loader screen.

It uses an up-to-date Windows 10 system and the latest version of FB from Paul. I just made a very large update to the internal structures in the program that has been compiling and running fine for the last 2 months.

Is there any way I can send you more information? or get you more debug information? Do not ask for a smaller version, large GTK programs cannot be reduced easily and who knows what caused this to start happening?

Wally
wallyg
Posts: 267
Joined: May 08, 2009 7:08
Location: Tucson Arizona

Re: Gas64 (no more use of gcc, only gas) WDS / LNX

Post by wallyg »

Found the problem.

The error messages were from an error message placed in the *.asm file after the following code

Code: Select all

                        If S->Connections(i).OutputOK Then
                            Dx = S->Connections(i).X-ButtonX
                            Dy = S->connections(i).Y-ButtonY
                            D = sqr(Dx*Dx+Dy*Dy)
                            if D < Distance then 
                                Ind = i
                                Distance = D
                            end if
                        Endif
The error code was placed one instruction after the call to sqrtss

The key I think was that Dx, Dy, and D were declared as Single (only needed 3 digits of accuracy). I retyped them as Double and the errors disappeared and an executable was produced.

Code: Select all

#O3movd r10d, xmm0
   #O3mov -1316[rbp], r10d
   movss -1316[rbp], xmm0 #Optim 3
   .L_1BDB:
   movss xmm0, -1312[rbp]
   movss xmm1, -1312[rbp]
   mulss xmm0, xmm1
   movq r11, xmm0
   movss xmm0, -1316[rbp]
   movss xmm1, -1316[rbp]
   mulss xmm0, xmm1
   movq r10, xmm0
   movd xmm0, r11d
   movd xmm1, r10d
   addss xmm0, xmm1
   movq r8, xmm0
   #O1 movd xmm0, r8
   sqrtss	xmm0, xmm0
   movd r8d, xmm0
   
   FOUND AN ERROR : virtual register=390 no real register corresponding, using KREG_XXX
Wally
SARG
Posts: 1756
Joined: May 27, 2005 7:15
Location: FRANCE

Re: Gas64 (no more use of gcc, only gas) WDS / LNX

Post by SARG »

@wally
Yes only SINGLES were concerned by this problem.
It has been fixed at the beginning of January so the fix is only in next 1.10.

You could use the daily build by St_W for a more uptodate version.

Btw did you try fbdebugger V3 ?
srvaldez
Posts: 3373
Joined: Sep 25, 2005 21:54

Re: Gas64 (no more use of gcc, only gas) WDS / LNX

Post by srvaldez »

hello SARG :)
I revisited some code and it compiles and runs OK with gcc but segfaults with gas64.
I tried to cleanup the code to present it to you but the cleaned-up code compiles and runs OK with gas64, so I present to you the dirty code

Code: Select all

 
#lang "fblite"
option gosub

dim shared as double log10_dec=log(10)
dim shared as double log10inv_dec=1/log(10)
dim shared as double pi_dec=3.1415926535897932

sub fpneg(result as double, x as double)
	result=-x
end sub

sub fpfrac(result as double, x as double)
	result=frac(x)
end sub

sub fpfix(result as double, x as double)
	result=fix(x)
end sub

sub fpadd(result as double, x as double, y as double)
	result=x+y
end sub

sub fpsub(result as double, x as double, y as double)
	result=x-y
end sub

sub fpmul(result as double, x as double, y as double)
	result=x*y
end sub

sub fpmul_si(result as double, x as double, y as long)
	result=x*y
end sub

sub fpdiv(result as double, x as double, y as double)
	result=x/y
end sub

sub Si2fp(result as double, x as longint)
	result=cdbl(x)
end sub

sub fplog(result as double, x as double)
	result=log(x)
end sub

sub fpexp(result as double, x as double)
	result=exp(x)
end sub

Sub fppow (result As double, lhs As double, rhs As double)
    Dim As double lhs2
    fplog lhs2, lhs
    fpmul lhs2, lhs2, rhs
    fpexp lhs2, lhs2
    result = lhs2
End Sub

function fp2long(x as double) as long
	function=CLng(x)
end function

sub str2fp(result as double, x as string)
	result=cdbl(x)
end sub

sub fpabs(result as double, x as double)
	result=abs(x)
end sub

sub fpasin(result as double, x as double)
	result=asin(x)
end sub

sub fpacos(result as double, x as double)
	result=acos(x)
end sub

sub fpatn(result as double, x as double)
	result=atn(x)
end sub

sub mp_sin(result as double, x as double)
	result=sin(x)
end sub

sub mp_cos(result as double, x as double)
	result=cos(x)
end sub

sub mp_tan(result as double, x as double)
	result=tan(x)
end sub

sub fpsqr(result as double, x as double)
	result=sqr(x)
end sub

Sub fpipow (result As double, x As double, e As LongInt)
    'take x to an Long power
    Dim As double y
    Dim As double z
    Dim As LongInt n, c

    c = 0
    y = x
    n = Abs(e)
    z.sign = 0
    z.exponent = (BIAS + 1)
    z.M0 = 100000000

    While n > 0
        While (n And 1) = 0
            n = n \ 2
            fpmul y, y, y
            c = c + 1
        Wend
        n = n - 1
        fpmul z, y, z
        c = c + 1
    Wend
    If e < 0 Then
        Si2fp y, 1
        fpdiv z, y, z
    End If
    result = z
End Sub

sub fpnroot(result As double, x As double, e As LongInt)
	result=x^(1/cdbl(e))
end sub

Sub fpeval (result as double, ee As String)
    Dim As Long i, j, id, l, fn, k
    Dim As String aa, d2, e2, s2, ch2
    Dim As double g, x, tmp, v(20)
    e2 = UCase(ee)

    If Len(e2) = 0 Then e2 = "0"

    i = 1: id = 0: l = Len(e2): s2 = "": fn = 0
    GoSub scan
    GoSub expr

    If ch2 <> " " Then
        Print
        Print "Syntax Error"
        Print
    End If
    result = v(0)
    Exit Sub
    '================================
    scan:
    If i > l Then
        ch2 = " "
        Return
    End If
    ch2 = Mid(e2, i, 1)
    i = i + 1
    If ch2 = " " Then GoSub scan
    Return

    unary:
    If ch2 = "-" Or ch2 = "+" Then
        s2 = s2 + ch2
        GoSub scan
        GoSub term
        aa = Right(s2, 1)
        s2 = Left(s2, Len(s2) - 1)
        If aa <> "-" Then Return
        fpneg v(id - 1), v(id - 1)
        Return
    End If
    GoSub factor
    Return

    gamma:
    GoSub unary
    While ch2 = "!"
        x = v(id - 1)
        GoSub factorial
        v(id - 1) = g
        GoSub scan
    Wend
    Return

    expon:
    GoSub gamma
    While ch2 = "^"
        GoSub scan
        GoSub gamma
        id = id - 1
        fpfrac tmp, v(id)
        If tmp.exponent = 0 Then
            fpfix tmp, v(id)
            fpipow v(id - 1), v(id - 1), fp2long(tmp)
        Else
            fppow v(id - 1), v(id - 1), v(id)
        End If
    Wend
    Return

    term:
    GoSub expon
    While (ch2 = "*" Or ch2 = "/")
        s2 = s2 + ch2
        GoSub scan
        GoSub expon
        aa = Right(s2, 1)
        s2 = Left(s2, Len(s2) - 1)
        If aa = "*" Then
            id = id - 1
            fpmul v(id - 1), v(id - 1), v(id)
        End If
        If aa = "/" Then
            id = id - 1
            fpdiv v(id - 1), v(id - 1), v(id)
        End If
    Wend
    Return

    expr:
    GoSub term
    While (ch2 = "-" Or ch2 = "+")
        s2 = s2 + ch2
        GoSub scan
        GoSub term
        aa = Right(s2, 1)
        s2 = Left(s2, Len(s2) - 1)
        If aa = "-" Then
            id = id - 1
            fpsub v(id - 1), v(id - 1), v(id)
        End If
        If aa = "+" Then
            id = id - 1
            fpadd v(id - 1), v(id - 1), v(id)
        End If
    Wend
    Return


    factor:
    If ch2 = "P" And Mid(e2, i - 1, 2) = "PI" Then
        v(id) = pi_dec
        id = id + 1
        i = i + 1
        GoSub scan
        Return
    End If
    If InStr(".0123456789", ch2) Then
        d2 = ""
        While ch2 <> "." And InStr("0123456789", ch2)
            d2 = d2 + ch2
            gosub scan
        Wend
        If ch2 = "." Then
            d2 = d2 + ch2
            gosub scan
        End If
        While InStr("0123456789", ch2)
            d2 = d2 + ch2
            gosub scan
        Wend
        If ch2 = "E" Then
            d2 = d2 + ch2
            gosub scan
            If ch2 = "-" Or ch2 = "+" Then
                d2 = d2 + ch2
                gosub scan
            End If
            If InStr("0123456789", ch2) Then
                While InStr("0123456789", ch2)
                    d2 = d2 + ch2
                    gosub scan
                Wend
            Else
                d2 = d2 + "0"
            End If
        End If
        str2fp v(id), d2
        id = id + 1
        Return
    End If
    
    If ch2 = "(" Then
        GoSub scan
        GoSub expr
        If ch2 = "," Then
            GoSub scan
            GoSub expr
        End If
        If ch2 <> ")" Then
            Print
            Print "Missing ')'"
        End If
        'IF fn = 0 THEN
        GoSub scan
        'END IF
        Return
    End If
    If ch2 = "A" Then
        If Mid(e2, i - 1, 4) = "ABS(" Then
            i = i + 2 'advance pointer to just before "("
            GoSub scan
            GoSub factor
            fpabs v(id - 1), v(id - 1)
        ElseIf Mid(e2, i - 1, 5) = "ACOS(" Then
            i = i + 3 'advance pointer to just before "("
            GoSub scan
            GoSub factor
            fpacos v(id - 1), v(id - 1)
        ElseIf Mid(e2, i - 1, 5) = "ASIN(" Then
            i = i + 3
            GoSub scan
            GoSub factor
            fpasin v(id - 1), v(id - 1)
        ElseIf Mid(e2, i - 1, 4) = "ATN(" Then
            i = i + 2
            GoSub scan
            GoSub factor
            fpatn v(id - 1), v(id - 1)
        Else
            k% = InStr(i, e2, "(")
            Print "unknown function A" + Mid(e2, i, k% - i)
        End If
    ElseIf ch2 = "C" Then
        If Mid(e2, i - 1, 4) = "COS(" Then
            i = i + 2 'advance pointer to just before "("
            GoSub scan
            GoSub factor
            mp_cos v(id - 1), v(id - 1)
        Else
            k% = InStr(i, e2, "(")
            Print "unknown function C" + Mid(e2, i, k% - i)
        End If
    ElseIf ch2 = "E" Then
        If Mid(e2, i - 1, 4) = "EXP(" Then
            i = i + 2 'advance pointer to just before "("
            GoSub scan
            GoSub factor
            fpexp v(id - 1), v(id - 1)
        ElseIf Mid(e2, i - 1, 6) = "EXP10(" Then
            i = i + 4 'advance pointer to just before "("
            GoSub scan
            GoSub factor
            fpmul tmp, v(id - 1), log10_dec
            fpexp v(id - 1), tmp
        Else
            k% = InStr(i, e2, "(")
            Print "unknown function E" + Mid(e2, i, k% - i)
        End If
    ElseIf ch2 = "L" Then
        If Mid(e2, i - 1, 4) = "LOG(" Then
            i = i + 2 'advance pointer to just before "("
            GoSub scan
            GoSub factor
            fplog v(id - 1), v(id - 1)
        ElseIf Mid(e2, i - 1, 6) = "LOG10(" Then
            i = i + 4 'advance pointer to just before "("
            GoSub scan
            GoSub factor
            fplog tmp, v(id - 1)
            fpmul v(id - 1), tmp, log10inv_dec
        Else
            k% = InStr(i, e2, "(")
            Print "unknown function L" + Mid(e2, i, k% - i)
        End If
    ElseIf ch2 = "R" Then
        If Mid(e2, i - 1, 5) = "ROOT(" Then
            i = i + 3 'advance pointer to just before "("
            GoSub scan
            GoSub factor
            id = id - 1
            fpnroot v(id - 1), v(id - 1), fp2long(v(id))
        Else
            k% = InStr(i, e2, "(")
            Print "unknown function R" + Mid(e2, i, k% - i)
        End If
    ElseIf ch2 = "S" Then
        If Mid(e2, i - 1, 4) = "SIN(" Then
            i = i + 2 'advance pointer to just before "("
            GoSub scan
            GoSub factor
            mp_sin v(id - 1), v(id - 1)
        ElseIf Mid(e2, i - 1, 4) = "SQR(" Then
            i = i + 2 'advance pointer to just before "("
            GoSub scan
            GoSub factor
            fpsqr v(id - 1), v(id - 1)
        Else
            k% = InStr(i, e2, "(")
            Print "unknown function S" + Mid(e2, i, k% - i)
        End If
    ElseIf ch2 = "T" Then
        If Mid(e2, i - 1, 4) = "TAN(" Then
            i = i + 2 'advance pointer to just before "("
            GoSub scan
            GoSub factor
            mp_tan v(id - 1), v(id - 1)
        Else
            k% = InStr(i, e2, "(")
            Print "unknown function T" + Mid(e2, i, k% - i)
        End If
    End If
    Return

    factorial:
    Si2fp g, 1
    For j = 1 To fp2long(x)
        fpmul_si g, g, j
    Next j
    Return

End Sub

dim as double z

fpeval z, "sin(1)"
? z
SARG
Posts: 1756
Joined: May 27, 2005 7:15
Location: FRANCE

Re: Gas64 (no more use of gcc, only gas) WDS / LNX

Post by SARG »

Code reduced and i hope fix the issue tomorrow. Right now I don't exactly remember how gosubs are handled in gas64 but that was not in a very clean way. :oops:
The original code is awful :lol:

Code: Select all

#lang "fblite"
option gosub

Sub fpeval ()
    print "here 000 fpeval"
    GoSub scan
    print "here 001 fpeval":sleep 1000
    Exit Sub
    '================================
    scan:
     print "here 00 scan":sleep 5000
    Return
End Sub

fpeval()
print "end"
sleep
srvaldez
Posts: 3373
Joined: Sep 25, 2005 21:54

Re: Gas64 (no more use of gcc, only gas) WDS / LNX

Post by srvaldez »

hi SARG
your minimalist example exhibits the problem, but then I wonder why my clean version works without a problem

Code: Select all

#lang "fblite"
option gosub

dim shared as double log10_dec=log(10)
dim shared as double log10inv_dec=1/log(10)
dim shared as double pi_dec=3.1415926535897932

Sub fpipow (result As double, x As double, e As LongInt)
    'take x to an Long power
    Dim As double y
    Dim As double z
    Dim As LongInt n, c

    c = 0
    y = x
    n = Abs(e)
    z=1

    While n > 0
        While (n And 1) = 0
            n = n \ 2
            y=y*y
            c = c + 1
        Wend
        n = n - 1
        z=y*z
        c = c + 1
    Wend
    If e < 0 Then
        z=1/z
    End If
    result = z
End Sub

sub fpnroot(result As double, x As double, e As LongInt)
	result=x^(1/cdbl(e))
end sub

Sub fpeval (result as double, ee As String)
    Dim As Long i, j, id, l, fn, k
    Dim As String aa, d2, e2, s2, ch2
    Dim As double g, x, tmp, v(20)
    e2 = UCase(ee)

    If Len(e2) = 0 Then e2 = "0"

    i = 1: id = 0: l = Len(e2): s2 = "": fn = 0
    GoSub scan
    GoSub expr

    If ch2 <> " " Then
        Print
        Print "Syntax Error"
        Print
    End If
    result = v(0)
    Exit Sub
    '================================
    scan:
    If i > l Then
        ch2 = " "
        Return
    End If
    ch2 = Mid(e2, i, 1)
    i = i + 1
    If ch2 = " " Then GoSub scan
    Return

    unary:
    If ch2 = "-" Or ch2 = "+" Then
        s2 = s2 + ch2
        GoSub scan
        GoSub term
        aa = Right(s2, 1)
        s2 = Left(s2, Len(s2) - 1)
        If aa <> "-" Then Return
        v(id - 1)=-v(id - 1)
        Return
    End If
    GoSub factor
    Return

    gamma:
    GoSub unary
    While ch2 = "!"
        x = v(id - 1)
        GoSub factorial
        v(id - 1) = g
        GoSub scan
    Wend
    Return

    expon:
    GoSub gamma
    While ch2 = "^"
        GoSub scan
        GoSub gamma
        id = id - 1
        tmp=frac(v(id))
        If tmp.exponent = 0 Then
            tmp=fix(v(id))
            fpipow v(id - 1), v(id - 1), clng(tmp)
        Else
            v(id - 1)=v(id - 1)^v(id)
        End If
    Wend
    Return

    term:
    GoSub expon
    While (ch2 = "*" Or ch2 = "/")
        s2 = s2 + ch2
        GoSub scan
        GoSub expon
        aa = Right(s2, 1)
        s2 = Left(s2, Len(s2) - 1)
        If aa = "*" Then
            id = id - 1
            v(id - 1)=v(id - 1)*v(id)
        End If
        If aa = "/" Then
            id = id - 1
            v(id - 1)=v(id - 1)/v(id)
        End If
    Wend
    Return

    expr:
    GoSub term
    While (ch2 = "-" Or ch2 = "+")
        s2 = s2 + ch2
        GoSub scan
        GoSub term
        aa = Right(s2, 1)
        s2 = Left(s2, Len(s2) - 1)
        If aa = "-" Then
            id = id - 1
            v(id - 1)=v(id - 1)-v(id)
        End If
        If aa = "+" Then
            id = id - 1
            v(id - 1)=v(id - 1)+v(id)
        End If
    Wend
    Return


    factor:
    If ch2 = "P" And Mid(e2, i - 1, 2) = "PI" Then
        v(id) = pi_dec
        id = id + 1
        i = i + 1
        GoSub scan
        Return
    End If
    If InStr(".0123456789", ch2) Then
        d2 = ""
        While ch2 <> "." And InStr("0123456789", ch2)
            d2 = d2 + ch2
            gosub scan
        Wend
        If ch2 = "." Then
            d2 = d2 + ch2
            gosub scan
        End If
        While InStr("0123456789", ch2)
            d2 = d2 + ch2
            gosub scan
        Wend
        If ch2 = "E" Then
            d2 = d2 + ch2
            gosub scan
            If ch2 = "-" Or ch2 = "+" Then
                d2 = d2 + ch2
                gosub scan
            End If
            If InStr("0123456789", ch2) Then
                While InStr("0123456789", ch2)
                    d2 = d2 + ch2
                    gosub scan
                Wend
            Else
                d2 = d2 + "0"
            End If
        End If
        v(id)=val(d2)
        id = id + 1
        Return
    End If
    
    If ch2 = "(" Then
        GoSub scan
        GoSub expr
        If ch2 = "," Then
            GoSub scan
            GoSub expr
        End If
        If ch2 <> ")" Then
            Print
            Print "Missing ')'"
        End If
        'IF fn = 0 THEN
        GoSub scan
        'END IF
        Return
    End If
    If ch2 = "A" Then
        If Mid(e2, i - 1, 4) = "ABS(" Then
            i = i + 2 'advance pointer to just before "("
            GoSub scan
            GoSub factor
            v(id - 1)=abs(v(id - 1))
        ElseIf Mid(e2, i - 1, 5) = "ACOS(" Then
            i = i + 3 'advance pointer to just before "("
            GoSub scan
            GoSub factor
            v(id - 1)=acos(v(id - 1))
        ElseIf Mid(e2, i - 1, 5) = "ASIN(" Then
            i = i + 3
            GoSub scan
            GoSub factor
            v(id - 1)=asin(v(id - 1))
        ElseIf Mid(e2, i - 1, 4) = "ATN(" Then
            i = i + 2
            GoSub scan
            GoSub factor
            v(id - 1)=atn(v(id - 1))
        Else
            k = InStr(i, e2, "(")
            Print "unknown function A" + Mid(e2, i, k - i)
        End If
    ElseIf ch2 = "C" Then
        If Mid(e2, i - 1, 4) = "COS(" Then
            i = i + 2 'advance pointer to just before "("
            GoSub scan
            GoSub factor
            v(id - 1)=cos(v(id - 1))
        Else
            k = InStr(i, e2, "(")
            Print "unknown function C" + Mid(e2, i, k - i)
        End If
    ElseIf ch2 = "E" Then
        If Mid(e2, i - 1, 4) = "EXP(" Then
            i = i + 2 'advance pointer to just before "("
            GoSub scan
            GoSub factor
            v(id - 1)=exp(v(id - 1))
        ElseIf Mid(e2, i - 1, 6) = "EXP10(" Then
            i = i + 4 'advance pointer to just before "("
            GoSub scan
            GoSub factor
            tmp=v(id - 1)*log10_dec
            v(id - 1)=exp(tmp)
        Else
            k = InStr(i, e2, "(")
            Print "unknown function E" + Mid(e2, i, k - i)
        End If
    ElseIf ch2 = "L" Then
        If Mid(e2, i - 1, 4) = "LOG(" Then
            i = i + 2 'advance pointer to just before "("
            GoSub scan
            GoSub factor
            v(id - 1)=log(v(id - 1))
        ElseIf Mid(e2, i - 1, 6) = "LOG10(" Then
            i = i + 4 'advance pointer to just before "("
            GoSub scan
            GoSub factor
            tmp=log(v(id - 1))
            v(id - 1)=tmp*log10inv_dec
        Else
            k = InStr(i, e2, "(")
            Print "unknown function L" + Mid(e2, i, k - i)
        End If
    ElseIf ch2 = "R" Then
        If Mid(e2, i - 1, 5) = "ROOT(" Then
            i = i + 3 'advance pointer to just before "("
            GoSub scan
            GoSub factor
            id = id - 1
            fpnroot v(id - 1), v(id - 1), clng(v(id))
        Else
            k = InStr(i, e2, "(")
            Print "unknown function R" + Mid(e2, i, k - i)
        End If
    ElseIf ch2 = "S" Then
        If Mid(e2, i - 1, 4) = "SIN(" Then
            i = i + 2 'advance pointer to just before "("
            GoSub scan
            GoSub factor
            v(id - 1)=sin(v(id - 1))
        ElseIf Mid(e2, i - 1, 4) = "SQR(" Then
            i = i + 2 'advance pointer to just before "("
            GoSub scan
            GoSub factor
            v(id - 1)=sqr(v(id - 1))
        Else
            k = InStr(i, e2, "(")
            Print "unknown function S" + Mid(e2, i, k - i)
        End If
    ElseIf ch2 = "T" Then
        If Mid(e2, i - 1, 4) = "TAN(" Then
            i = i + 2 'advance pointer to just before "("
            GoSub scan
            GoSub factor
            v(id - 1)=tan(v(id - 1))
        Else
            k = InStr(i, e2, "(")
            Print "unknown function T" + Mid(e2, i, k - i)
        End If
    End If
    Return

    factorial:
    g=1
    For j = 1 To clng(x)
        g=g*j
    Next j
    Return

End Sub

dim as double z

fpeval z, "sin(1)*2/7!"
? z
fxm
Moderator
Posts: 12082
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: Gas64 (no more use of gcc, only gas) WDS / LNX

Post by fxm »

Shortest code with only GOSUB (without SUB) that induces a 'runtime error 12 ("segmentation violation" signal)' with 'gas64':

Code: Select all

#lang "fblite"
option gosub

gosub scan
end

scan:
    sleep 0
return
Aborting due to runtime error 12 ("segmentation violation" signal) in C:\...\FBIDETEMP.bas::()
SARG
Posts: 1756
Joined: May 27, 2005 7:15
Location: FRANCE

Re: Gas64 (no more use of gcc, only gas) WDS / LNX

Post by SARG »

Hi srvaldez,fxm,
Thanks for report and help

Worst, if you let sleep running -->crash if you press any key --> no crash.
I'm still investigating.

Code: Select all

#lang "fblite"
option gosub

Sub fpeval ()
    GoSub scan
    Exit Sub
    '================================
    scan:
    sleep 5000
    Return

End Sub

fpeval()

print "end"
sleep
srvaldez
Posts: 3373
Joined: Sep 25, 2005 21:54

Re: Gas64 (no more use of gcc, only gas) WDS / LNX

Post by srvaldez »

fxm and SARG
in both your minimalist examples the trigger is sleep, in SARG's example if I press the return key before the sleep expires then there's no crash
fxm's code without the sleep has no problem

Code: Select all

#lang "fblite"
option gosub

gosub scan
end

scan:
    ? "hello"
return
edit: SARG posted just a little before me and I wasn't warned
SARG
Posts: 1756
Joined: May 27, 2005 7:15
Location: FRANCE

Re: Gas64 (no more use of gcc, only gas) WDS / LNX

Post by SARG »

The return address of the gosub stored on the stack is squashed when sleep runs to the end, not the case if a key is pressed.
That's strange because a register is also pushed but not changed.
Maybe more space should be reserved on the stack but how much if nested gosubs.......

To be continued :wink:
D.J.Peters
Posts: 8586
Joined: May 28, 2005 3:28
Contact:

Re: Gas64 (no more use of gcc, only gas) WDS / LNX

Post by D.J.Peters »

if you use nested gosubs in 2022 a crash should be a normal reaction on this :lol:
dodicat
Posts: 7976
Joined: Jan 10, 2006 20:30
Location: Scotland

Re: Gas64 (no more use of gcc, only gas) WDS / LNX

Post by dodicat »

A couple of questions.
Where can I get the latest gas64 and fb build these days?
Is it safe to define and undefine a label thousands (millions) of times?

Code: Select all

'#cmdline "-gen gas64"
#macro MyMacro(commence,limit,result)
#define finish finishlabel
#define start startlabel
 scope
      dim as long x=commence
      result=""
	start:
      do
      result+=str(x)+" "
      x+=1
     if abs(x) <=limit then goto start else goto finish
 loop
 end scope
finish:
#undef startlabel
#undef finishlabel
#endmacro

dim as string z,g

for n as long=1 to 100000
MyMacro(n,0,g)
z+= g
next
print z
print
MyMacro(8,30,g)
print g


Sleep
 
SARG
Posts: 1756
Joined: May 27, 2005 7:15
Location: FRANCE

Re: Gas64 (no more use of gcc, only gas) WDS / LNX

Post by SARG »

@ D.J.Peters
Sure. :lol:

@dodicat
First question : viewtopic.php?p=295411#p295411 (https://users.freebasic-portal.de/sarg/ ... astest.zip)
However only exe for windows 64bit.
Second one : I don't know, have to test.
dodicat
Posts: 7976
Joined: Jan 10, 2006 20:30
Location: Scotland

Re: Gas64 (no more use of gcc, only gas) WDS / LNX

Post by dodicat »

Thanks SARG.
I'm sure you have tested, but using
sleep 5000,1
is OK
in the example.
SARG
Posts: 1756
Joined: May 27, 2005 7:15
Location: FRANCE

Re: Gas64 (no more use of gcc, only gas) WDS / LNX

Post by SARG »

Bug fixed. No stack was reserved after GOSUB for called procedures.....
https://users.freebasic-portal.de/sarg/ ... astest.zip

@dodicat
No I didn't think to test 'sleep 5000,1' and I don't know why it's OK but now it doesn't matter. :)

About your second question : the macro is integrated only 2 times even in the loop. Or maybe I don't quite understand the question.
Post Reply