Gas64 (no more use of gcc, only gas) WDS / LNX
Re: Gas64 (no more use of gcc, only gas) WDS / LNX
Thanks UEZ.
I didn't see your post immediately before my debug code, If I had I wouldn't have needed to post the debug code, but I was so busy trying to debug that I completely missed your post, So I shall delete my code later on.
I have another (completely different) snippet for gas64, but I have yet to isolate it from clutter.
I shall take the dogs for a walk in the rain in the meantime.
I didn't see your post immediately before my debug code, If I had I wouldn't have needed to post the debug code, but I was so busy trying to debug that I completely missed your post, So I shall delete my code later on.
I have another (completely different) snippet for gas64, but I have yet to isolate it from clutter.
I shall take the dogs for a walk in the rain in the meantime.
Re: Gas64 (no more use of gcc, only gas) WDS / LNX
Hi all,
I'm tenacious but this time I doubted to find the bug in fireworks.....
As the values of 4 and 6 for iparticles allow a good execution but not 5 I finished ( after pulling out my hair although there are not many left...) to have a genious idea : compare the asm code for 4 and 5.
And there I saw an horror.
When clearing memory there are different ways according the size of the area. By mistake I mixed partially 2 ways : so in case of size >64 but not if a multiple of 8 a small space was zeroed further from where it should have been. Shame on me.
New version fixing this bug and that reported by dodicat. http://users.freebasic-portal.de/sarg/ir-gas64.zip
@UEZ
- With only one rocket you can see some 'stealthy' artifacts of the previous rocket.
- In the Function _Stack.Get(iPos As Uinteger) Byref As ParticleTail
When the test is negative the returning value is null. Not sure this case could arise but if yes something will go wrong. :-)
Again thanks to the testers ;-) And Dodicat I'm wondering what you found.
I'm tenacious but this time I doubted to find the bug in fireworks.....
As the values of 4 and 6 for iparticles allow a good execution but not 5 I finished ( after pulling out my hair although there are not many left...) to have a genious idea : compare the asm code for 4 and 5.
And there I saw an horror.
When clearing memory there are different ways according the size of the area. By mistake I mixed partially 2 ways : so in case of size >64 but not if a multiple of 8 a small space was zeroed further from where it should have been. Shame on me.
New version fixing this bug and that reported by dodicat. http://users.freebasic-portal.de/sarg/ir-gas64.zip
@UEZ
- With only one rocket you can see some 'stealthy' artifacts of the previous rocket.
- In the Function _Stack.Get(iPos As Uinteger) Byref As ParticleTail
When the test is negative the returning value is null. Not sure this case could arise but if yes something will go wrong. :-)
Again thanks to the testers ;-) And Dodicat I'm wondering what you found.
Re: Gas64 (no more use of gcc, only gas) WDS / LNX
I did realize this unwanted effect, too, but somehow it looked mystical. Anyhow, I think I fixed it -> viewtopic.php?f=8&t=27478&p=273018#p273018SARG wrote:@UEZ
- With only one rocket you can see some 'stealthy' artifacts of the previous rocket.
- In the Function _Stack.Get(iPos As Uinteger) Byref As ParticleTail
When the test is negative the returning value is null. Not sure this case could arise but if yes something will go wrong. :-)
I still don't understand the class stuff how it is managed under the hood. I need to do more exercises in class stuff to understand it better. :-)
Meanwhile I've added some sound fx using BASS... ^^
Btw, GAS64 seems to work properly also with the updated code.
Last edited by UEZ on Jun 13, 2020 22:13, edited 1 time in total.
Re: Gas64 (no more use of gcc, only gas) WDS / LNX
I have the little bug isolated a bit.
using
dim as integer u=ubound(p)
is OK
or compile
-gen gas64 -exx
is OK
Code: Select all
type pt
as long x,y
end type
screen 19
dim as pt p(1 to 3)
p(1)=type(100,100)
p(2)=type(400,400)
p(3)=type(-10,-10)
dim as long u=ubound(p)
var ctr=10
line (p((ctr) mod u).x,p((ctr) mod u).y)- (p(1+(ctr+u\4) mod u).x,p(1+(ctr+u\4) mod u).y)
sleep
sleep
dim as integer u=ubound(p)
is OK
or compile
-gen gas64 -exx
is OK
Re: Gas64 (no more use of gcc, only gas) WDS / LNX
Again a good catch dodicat. Long and complex lines use more registers so you found new bug cases.
Fixed and I found in the same area other problems also fixed.
http://users.freebasic-portal.de/sarg/ir-gas64.zip.
@xusinboy
Try with increasing the stack up to 4096 (-t 4096) when compiling. I can see the splash image then an exit with code 2 = file not found. Maybe it runs not in a good place.
Maybe there is also a memory leak somewhere I have to check.
Fixed and I found in the same area other problems also fixed.
http://users.freebasic-portal.de/sarg/ir-gas64.zip.
@xusinboy
Try with increasing the stack up to 4096 (-t 4096) when compiling. I can see the splash image then an exit with code 2 = file not found. Maybe it runs not in a good place.
Maybe there is also a memory leak somewhere I have to check.
Re: Gas64 (no more use of gcc, only gas) WDS / LNX
Thanks SARG.
I put your new fbc64_gas64.exe into my FreeBASIC-1.07.1-win64 folder.
I put your new fbc64_gas64.exe into my FreeBASIC-1.07.1-win64 folder.
-
- Posts: 789
- Joined: Jul 26, 2018 18:28
Re: Gas64 (no more use of gcc, only gas) WDS / LNX
To find the error line I want to show the lines with "?5", but it doesn’t show.SARG wrote: @xusinboy
Try with increasing the stack up to 4096 (-t 4096) when compiling. I can see the splash image then an exit with code 2 = file not found. Maybe it runs not in a good place.
Maybe there is also a memory leak somewhere I have to check.
Older versions of fbc64_gas64 worked fine without "-t 4096" and never threw errors at runtime. After several versions of fbc64_gas64 it turns out like this.
gdb gives an error inside the procedure Sub EditControl.ShowCaretPos(Scroll As Boolean = False), but without printing, I can’t see the line.
Code: Select all
Program received signal SIGSEGV, Segmentation fault.
0x000000000047d293 in MY::SYS::FORMS::EDITCONTROL::SHOWCARETPOS(bool) ()
(gdb) bt
#0 0x000000000047d293 in MY::SYS::FORMS::EDITCONTROL::SHOWCARETPOS(bool) ()
#1 0x000000000047ef35 in MY::SYS::FORMS::EDITCONTROL::SCROLLTOCARET() ()
#2 0x000000000048865a in MY::SYS::FORMS::EDITCONTROL::PROCESSMESSAGE(MESSAGE&) ()
#3 0x0000000000427a19 in MY::SYS::FORMS::CONTROL::DEFWNDPROC(HWND__*, unsigned int, unsigned long long, long long) ()
#4 0x00007ffcd442681d in USER32!CascadeChildWindows () from C:\Windows\System32\user32.dll
#5 0x0000000000030ebe in ?? ()
#6 0x0000000000000007 in ?? ()
#7 0x00000000004e0c60 in MY::SYS::FORMS::HOTKEY::TEXT__get__() ()
#8 0x000000000048b8fe in MY::SYS::FORMS::EDITCONTROL::PROCESSMESSAGE(MESSAGE&) ()
#9 0x0000000000427a19 in MY::SYS::FORMS::CONTROL::DEFWNDPROC(HWND__*, unsigned int, unsigned long long, long long) ()
#10 0x00007ffcd442681d in USER32!CascadeChildWindows () from C:\Windows\System32\user32.dll
#11 0x0000000000030ebe in ?? ()
#12 0x0000000000000201 in ?? ()
#13 0x0000000000000001 in ?? ()
#14 0x0000000000990073 in UDT ()
#15 0x0000000000000000 in ?? ()
(gdb)
Re: Gas64 (no more use of gcc, only gas) WDS / LNX
@xusinboy
Yesterday I have fixed the bug for the wrong memory stack. The max stack size for each procedure was not reset so a huge size was kept for all the next procedures. http://users.freebasic-portal.de/sarg/ir-gas64.zip.
And I got something strange your source codes are on the linux's format (only CR or LF) and when I change for windows I get the compilation errors reported in a previous post (about compilation of version 1.24). I'll also see what is happening.
Edit : I forgot to say : gas64 and regular fbc.
Edit 2 : using notepad ++ no problem as it saves the file in the same format.
And execution seems now fine after moving the exe at its right place. With -exx I saw where the code 2 came and so what file was missing.....
Yesterday I have fixed the bug for the wrong memory stack. The max stack size for each procedure was not reset so a huge size was kept for all the next procedures. http://users.freebasic-portal.de/sarg/ir-gas64.zip.
Do you compile with -s console ?Xusinboy Bekchanov wrote:To find the error line I want to show the lines with "?5", but it doesn’t show.
And I got something strange your source codes are on the linux's format (only CR or LF) and when I change for windows I get the compilation errors reported in a previous post (about compilation of version 1.24). I'll also see what is happening.
Edit : I forgot to say : gas64 and regular fbc.
Edit 2 : using notepad ++ no problem as it saves the file in the same format.
And execution seems now fine after moving the exe at its right place. With -exx I saw where the code 2 came and so what file was missing.....
-
- Posts: 789
- Joined: Jul 26, 2018 18:28
Re: Gas64 (no more use of gcc, only gas) WDS / LNX
I just tried the new version with the console. The error appears in line 1147:SARG wrote:@xusinboy
Yesterday I have fixed the bug for the wrong memory stack. The max stack size for each procedure was not reset so a huge size was kept for all the next procedures. http://users.freebasic-portal.de/sarg/ir-gas64.zip.
Do you compile with -s console ?Xusinboy Bekchanov wrote:To find the error line I want to show the lines with "?5", but it doesn’t show.
And I got something strange your source codes are on the linux's format (only CR or LF) and when I change for windows I get the compilation errors reported in a previous post (about compilation of version 1.24). I'll also see what is happening.
Edit : I forgot to say : gas64 and regular fbc.
Edit 2 : using notepad ++ no problem as it saves the file in the same format.
And execution seems now fine after moving the exe at its right place. With -exx I saw where the code 2 came and so what file was missing.....
Code: Select all
Sub EditControl.ShowCaretPos(Scroll As Boolean = False)
?1137: nCaretPosY = GetCaretPosY(FSelEndLine)
?1138: FCurLineCharIdx = FSelEndChar
?1139: nCaretPosX = TextWidth(GetTabbedText(Left(Lines(FSelEndLine), FCurLineCharIdx)))
?1140: If CInt(DropDownShowed) AndAlso CInt(CInt(FSelEndChar < DropDownChar) OrElse CInt(FSelEndChar > GetNextCharIndex(*Cast(EditControlLine Ptr, FLines.Items[FSelEndLine])->Text, DropDownChar))) Then
?1141: CloseDropDown()
?1142: End If
?1143: If CInt(ToolTipShowed) AndAlso CInt(CInt(FSelEndChar < ToolTipChar) OrElse CInt(Mid(*Cast(EditControlLine Ptr, FLines.Items[FSelEndLine])->Text, FSelEndChar + 1, 1) = ":") OrElse CInt(GetWordAt(FSelEndLine, ToolTipChar) <> HintWord)) Then
?1144: CloseToolTip()
?1145: End If
?1146: If OldLine <> FSelEndLine OrElse OldChar <> FSelEndChar Then
?1147: If OnSelChange Then OnSelChange(This, FSelEndLine, FSelEndChar)
?1148: End If
Code: Select all
OnValidate As Sub(ByRef Sender As EditControl)
OnSelChange As Sub(ByRef Sender As EditControl, ByVal CurrentLine As Integer, ByVal CurrentCharIndex As Integer)
OnLineChange As Sub(ByRef Sender As EditControl, ByVal CurrentLine As Integer, ByVal OldLine As Integer)
OnLinkClicked As Sub(ByRef Sender As EditControl, ByRef Link As WString)
OnToolTipLinkClicked As Sub(ByRef Sender As EditControl, ByRef Link As WString)
End Type
Re: Gas64 (no more use of gcc, only gas) WDS / LNX
@Xusinboy
Sorry I don't know how to get the current problems. Could you explain exactly what I should do.
Sorry I don't know how to get the current problems. Could you explain exactly what I should do.
Re: Gas64 (no more use of gcc, only gas) WDS / LNX
Hi SARG
I got you a new challenge, viewtopic.php?f=3&t=28636
I got you a new challenge, viewtopic.php?f=3&t=28636
Re: Gas64 (no more use of gcc, only gas) WDS / LNX
another one, in the following program if INTEGER is used then you get errors like
untitled12.a64:2518: Error: operand type mismatch for `add'
if you change INTEGER to __longint then it compiles OK but as soon as you press the return key at the program's input it crashes
to be fair it also crashes if compiled using -gen gcc
untitled12.a64:2518: Error: operand type mismatch for `add'
if you change INTEGER to __longint then it compiles OK but as soon as you press the return key at the program's input it crashes
to be fair it also crashes if compiled using -gen gcc
Code: Select all
#lang "qb"
declare FUNCTION eval(byref ee AS STRING) as double
a$ = " "
WHILE a$ <> ""
LINE INPUT ""; a$
result# = eval(a$)
PRINT result#
WEND
END
FUNCTION eval(ee AS STRING) as double
DIM i AS __longint
DIM id AS __longint
DIM l AS __longint
DIM fn AS __longint
DIM k AS __longint
/'
DIM i AS INTEGER
DIM id AS INTEGER
DIM l AS INTEGER
DIM fn AS INTEGER
DIM k AS INTEGER
'/
DIM aa AS STRING
DIM d2 AS STRING
DIM e2 AS STRING
DIM s2 AS STRING
DIM ch2 AS STRING
DIM g AS DOUBLE
DIM x AS DOUBLE
DIM fc AS DOUBLE
DIM 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
eval# = v#(0)
EXIT FUNCTION
'================================
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
v#(id - 1) = v#(id - 1) ^ v#(id)
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 = "E" THEN
If mid$(e2, i - 1, 2) <> "ER" _
andalso mid$(e2, i - 1, 2) <> "EX" Then
v#(id) = 2.71828182845904523536
id = id + 1
GOSUB scan
RETURN
end if
END IF
IF ch2 = "P" AND MID$(e2, i - 1, 2) = "PI" THEN
v#(id) = 3.14159265358979323846
id = id + 1
i = i + 1
GOSUB scan
RETURN
END IF
IF INSTR(".0123456789", ch2) THEN
d2 = ""
WHILE INSTR("DE.0123456789", ch2)
d2 = d2 + ch2
GOSUB scan
WEND
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, 4) = "ATN(" THEN
i = i + 2
GOSUB scan
GOSUB factor
v#(id - 1) = ATN(v#(id - 1))
ELSEIF MID$(e2, i - 1, 6) = "ATAN2(" THEN
i = i + 4
GOSUB scan
GOSUB factor
id = id - 1
v#(id - 1) = __ATAN2(v#(id - 1), v#(id))
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
v#(id - 1) = EXP(v#(id - 1) * 2.3025850929940456840#)
ELSE
k = INSTR(i, e2, "(")
PRINT "unknown function E" + MID$(e2, i, k - i)
END IF
ELSEIF ch2 = "I" THEN
IF MID$(e2, i - 1, 4) = "INT(" THEN
i = i + 2 'advance pointer to just before "("
GOSUB scan
GOSUB factor
v#(id - 1) = INT(v#(id - 1))
ELSE
k = INSTR(i, e2, "(")
PRINT "unknown function I" + 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
v#(id - 1) = LOG(v#(id - 1)) * 0.43429448190325182765#
ELSE
k = INSTR(i, e2, "(")
PRINT "unknown function L" + 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 fc = 1 TO x
g = g * fc
NEXT fc
RETURN
END FUNCTION
Re: Gas64 (no more use of gcc, only gas) WDS / LNX
Hi srvaldez
Thanks for those new hardships ;-)
I'll fix them later.
For now I'm more focused on the test suite for Linux. Happily almost all are successfully passed.
Thanks for those new hardships ;-)
I'll fix them later.
For now I'm more focused on the test suite for Linux. Happily almost all are successfully passed.
Re: Gas64 (no more use of gcc, only gas) WDS / LNX
Hi all,
Issue 1 (reported Mon Jun 22, 2020 11:28)
Variable or procedure names can not be asm names. That's the case with 'ch'. Changing by 'char' no problem.
In fact I previously used adding an underscore to avoid that but coderjeff made some changes in my code and now those names are no more allowed.
It's a point to be discussed with him.
Issue 2 (reported Mon Jun 22, 2020 11:50)
There were 2 problems:
- with lang qb integer is 16-bit and all calculations are done with shorts instead of integer 64-bit. I fixed that but maybe there are other places with wrong behaviours.
- nested gosubs don't work (gas64 and gcc). I followed execution with a debugger and also looked at the c code (rt lib) without understanding what was going wrong.
Under the hood : setjmp and longjmp are used. They save/restore a lot of registers so an obvious overhead. In our case when longjmp is called a test is done on a saved register and that induces that the restore of all the data is not done. ?????
Maybe it's possible to do like gas32 (call/ret a faster way) but IMO the interest of using gosub is low.
Issue 1 (reported Mon Jun 22, 2020 11:28)
Variable or procedure names can not be asm names. That's the case with 'ch'. Changing by 'char' no problem.
In fact I previously used adding an underscore to avoid that but coderjeff made some changes in my code and now those names are no more allowed.
It's a point to be discussed with him.
Issue 2 (reported Mon Jun 22, 2020 11:50)
There were 2 problems:
- with lang qb integer is 16-bit and all calculations are done with shorts instead of integer 64-bit. I fixed that but maybe there are other places with wrong behaviours.
- nested gosubs don't work (gas64 and gcc). I followed execution with a debugger and also looked at the c code (rt lib) without understanding what was going wrong.
Under the hood : setjmp and longjmp are used. They save/restore a lot of registers so an obvious overhead. In our case when longjmp is called a test is done on a saved register and that induces that the restore of all the data is not done. ?????
Maybe it's possible to do like gas32 (call/ret a faster way) but IMO the interest of using gosub is low.
Re: Gas64 (no more use of gcc, only gas) WDS / LNX
thank you SARG :-)
I agree that fixing the compiler so that the QB code would work is probably not worth the trouble, but from my hackish mindset I think that it would be cool to support gosubs in a function, the reason is that you can encapsulate my eval for example, in a function, rather than have the different procedures spread outside the function.
I agree that fixing the compiler so that the QB code would work is probably not worth the trouble, but from my hackish mindset I think that it would be cool to support gosubs in a function, the reason is that you can encapsulate my eval for example, in a function, rather than have the different procedures spread outside the function.