Gas64 (no more use of gcc, only gas) WDS / LNX
Re: Gas64 (no more use of gcc, only gas) :-)
Here is my copy re zipped.
http://www.mediafire.com/file/c8kdh9phb ... 4.zip/file
You are correct, there is now an error on sarg's file.
http://www.mediafire.com/file/c8kdh9phb ... 4.zip/file
You are correct, there is now an error on sarg's file.
Re: Gas64 (no more use of gcc, only gas) :-)
I don't have any problems unzipping the archive, try windows explorer instead of 7z
Re: Gas64 (no more use of gcc, only gas) :-)
Weird errors - is this a wrapper around GCC??
Code: Select all
error 91: Executable not found: "C:\FreeBasic\bin\win64\gcc.exe"
Re: Gas64 (no more use of gcc, only gas) :-)
In bin/win64 I made my gcc.exe into gcc.exe_ just to make sure there was no gcc.
My set up is
1) Get a new 64 bit fb dowlnoad .zip and expand it into a working folder.
2) In the place where fbc.exe resides, pop in a copy of fbc64_gas64.exe (from your gas64 download)
3) Take a fresh copy of your ide, dedicate it to running fbc64_gas64.exe
That's all I did.
I have not tried fbc32_gas64.exe.
Remember the compiler switches given by SARG
-arch 64 -RR -R -gen gas64 -v -g
My set up is
1) Get a new 64 bit fb dowlnoad .zip and expand it into a working folder.
2) In the place where fbc.exe resides, pop in a copy of fbc64_gas64.exe (from your gas64 download)
3) Take a fresh copy of your ide, dedicate it to running fbc64_gas64.exe
That's all I did.
I have not tried fbc32_gas64.exe.
Remember the compiler switches given by SARG
-arch 64 -RR -R -gen gas64 -v -g
Re: Gas64 (no more use of gcc, only gas) :-)
SARG, Wow, that's neat. And ambitious, writing an IR/REG/EMIT almost from scratch. I also was working on an x86_64 but using a modification of the x86 IR/REG/EMIT as the template. It sort of works, but mostly not, so I must envy your progress. :)
Your zip file I downloaded Mar 4, seems to work OK, as well the one uploaded by dodicat. The current download seems broken. Anyway, I copied the code on to 1.06.0 release source and it compiled OK for me. I didn't try the packaged exe's.
Some comments; and I do understand that this is a WIP.
Options:
- '-gen gas -arch x86_64' should be enough to select gas+64bit IR, though I can see for development, '-gen gas64' with a separate backend constant in source makes it easy to search for in the source code and keeps it separate from the 32-bit x86-isms.
Style (see existing code for comparison):
- 3 space indents ==> tab indent (equal to four spaces)
- mixed cases of keywords "Dim" ==> "dim"
- numeric literals ==> named literals, like 0 ==> NULL, or -2, -3 ==> some symbol name
- comments on same line of code ==> comments on line before code line
- warning 15(0): No explicit BYREF or BYVAL, at parameter N
- warning 16(0): Possible escape sequence found in: "\0\0\0\0", ==> use '$' or '!' prefix on literals
Test Suite (with -g):
- Many errors on many files, not sure where to start. I have given just one example below.
- To compile run-time tests, without using make/makefile, first compile the fbc unit testing library:
cd tests/fbcunit
fbc-win64.exe -gen gas64 -mt -g -exx -i ./inc -lib src/fbcunit.bas src/fbcunit_qb.bas src/fbcunit_console.bas src/fbcunit_report.bas -x lib/libcunit.a
- Next from ./tests try a single run-time test file.
fbc-win64.exe -g -gen gas64 fbc-tests.bas numbers/casting.bas -i fbcunit/inc -p fbcunit/lib
Output:
numbers/casting.a64: Assembler messages:
numbers/casting.a64:139: Error: operand size mismatch for `movsx'
numbers/casting.a64:351: Error: operand size mismatch for `movsx'
numbers/casting.a64:1285: Error: unsupported instruction `mov'
- however, looks like support for global .ctors/.dtors is still missing, so none of the run-time tests actually get executed. The fbc test suite is heavily dependant on global ctors/dtors to function.
- optimizations/math-torture-?.bas never finishes (or it takes a really long time, I didn't wait), probably due all the debug info.
Testing (without -g):
- many of test programs will cause this kind of error without -g
fbc-win64.exe -gen gas64 -c -w 3 -i fbcunit/inc -m fbc-tests -mt boolean/boolean-conversions.bas
Aborting due to runtime error 6 (out of bounds array access) at line 2656 of src\compiler\ir-gas64.bas::HLOADOPERANDSANDWRITEBOP()
- Even if the compilation fails due no free reg, probably don't want the compiler itself to crash.
After modifying the size of the array reghandle(15) to 17, and using KREG_XXX as a possible register it looks like CMP instruction doesn't free regs (I think). After several calls, the number of real registers in use exceed the registers available, and causes error.
Simple example code:
Output:
Error: no such instruction: `found AN ERROR:no free reg use RAX'
It looks like a vreg that has been assigned to a real reg, but is never used again, also does not get free'd, but I could be missing something. Regardless, if you do run out of free reg's, then will have to spill regs and restore later.
Keep up the good work.
Your zip file I downloaded Mar 4, seems to work OK, as well the one uploaded by dodicat. The current download seems broken. Anyway, I copied the code on to 1.06.0 release source and it compiled OK for me. I didn't try the packaged exe's.
Some comments; and I do understand that this is a WIP.
Options:
- '-gen gas -arch x86_64' should be enough to select gas+64bit IR, though I can see for development, '-gen gas64' with a separate backend constant in source makes it easy to search for in the source code and keeps it separate from the 32-bit x86-isms.
Style (see existing code for comparison):
- 3 space indents ==> tab indent (equal to four spaces)
- mixed cases of keywords "Dim" ==> "dim"
- numeric literals ==> named literals, like 0 ==> NULL, or -2, -3 ==> some symbol name
- comments on same line of code ==> comments on line before code line
- warning 15(0): No explicit BYREF or BYVAL, at parameter N
- warning 16(0): Possible escape sequence found in: "\0\0\0\0", ==> use '$' or '!' prefix on literals
Test Suite (with -g):
- Many errors on many files, not sure where to start. I have given just one example below.
- To compile run-time tests, without using make/makefile, first compile the fbc unit testing library:
cd tests/fbcunit
fbc-win64.exe -gen gas64 -mt -g -exx -i ./inc -lib src/fbcunit.bas src/fbcunit_qb.bas src/fbcunit_console.bas src/fbcunit_report.bas -x lib/libcunit.a
- Next from ./tests try a single run-time test file.
fbc-win64.exe -g -gen gas64 fbc-tests.bas numbers/casting.bas -i fbcunit/inc -p fbcunit/lib
Output:
numbers/casting.a64: Assembler messages:
numbers/casting.a64:139: Error: operand size mismatch for `movsx'
numbers/casting.a64:351: Error: operand size mismatch for `movsx'
numbers/casting.a64:1285: Error: unsupported instruction `mov'
- however, looks like support for global .ctors/.dtors is still missing, so none of the run-time tests actually get executed. The fbc test suite is heavily dependant on global ctors/dtors to function.
- optimizations/math-torture-?.bas never finishes (or it takes a really long time, I didn't wait), probably due all the debug info.
Testing (without -g):
- many of test programs will cause this kind of error without -g
fbc-win64.exe -gen gas64 -c -w 3 -i fbcunit/inc -m fbc-tests -mt boolean/boolean-conversions.bas
Aborting due to runtime error 6 (out of bounds array access) at line 2656 of src\compiler\ir-gas64.bas::HLOADOPERANDSANDWRITEBOP()
- Even if the compilation fails due no free reg, probably don't want the compiler itself to crash.
After modifying the size of the array reghandle(15) to 17, and using KREG_XXX as a possible register it looks like CMP instruction doesn't free regs (I think). After several calls, the number of real registers in use exceed the registers available, and causes error.
Simple example code:
Code: Select all
sub proc( byval x as integer )
end sub
dim as integer a
proc a=0
proc a=0
proc a=0
proc a=0
proc a=0
proc a=0
proc a=0
proc a=0
proc a=0
proc a=0
proc a=0
proc a=0
proc a=0
proc a=0
Error: no such instruction: `found AN ERROR:no free reg use RAX'
It looks like a vreg that has been assigned to a real reg, but is never used again, also does not get free'd, but I could be missing something. Regardless, if you do run out of free reg's, then will have to spill regs and restore later.
Keep up the good work.
Re: Gas64 (no more use of gcc, only gas) :-)
@SARG
Only array of 8bit integer works correct, 16bit, 32bit of 64bit give wrong numbers.
The next pieces of code work
When some FP calculation needs to be stored in a integer things go wrong.
The next 3 snippets don't work, they all give an error Aborting due to runtime error 10 ("illegal instruction" signal) in test.bas::()
When its pure integer math then there's no problem.
var = -var does return the wrong value for integers and real, (0) instead of then negative number.
Only array of 8bit integer works correct, 16bit, 32bit of 64bit give wrong numbers.
Code: Select all
dim as integer<8> a(3), b = 1, c = 2
for i as integer = 1 to 3 : print a(i), : next : print
a(b) = b : a(c) = c
for i as integer = 1 to 3 : print a(i), : next : print
swap a(b), a(c)
print
Code: Select all
dim as double real = 123.456
print real
print int(real)
print fix(real)
print
dim as integer<32> x = 111
print x, x / 7 , x \ 7
print int(x / 7)
print fix(x / 7)
print
dim as integer<8> y = 111
print y, y / 7.7
print int(y / 7.7)
print fix(y / 7.7)
print
print rnd
print rnd * 10
print int(rnd * 10)
print int(rnd * 10.123)
The next 3 snippets don't work, they all give an error Aborting due to runtime error 10 ("illegal instruction" signal) in test.bas::()
Code: Select all
dim as integer<32> test = 10,answer
answer = int( test / 2.2)
Code: Select all
dim as integer<32> test = 10,answer
answer = test / 2.2
Code: Select all
dim as integer<32> test = 10,answer
answer = rnd * 10
Code: Select all
dim as integer<32> test = 10, answer
answer = test * 10 \ 22
print answer
Code: Select all
dim as integer<32> test = 10,answer
answer = -test
print answer
Code: Select all
dim as double test = rnd, answer
answer = test
print answer
answer = int(test * 100 / 3)
print answer
answer = -test
print answer
Re: Gas64 (no more use of gcc, only gas) :-)
Hi all,
Thanks again for the time you spend and are going to spend ;-)
New version : http://users.freebasic-portal.de/sarg/fbcgas64.zip
About the zip file
Maybe the reason of the issue is that I updated directly new versions in it so the result is ok for windows but not for 7zip or other tools.
Sorry for the inconvenience I'll create a new one each time.
Gcc.exe is not used. When using fbc32_gas64 the win64 directory must be put like the win32 one to avoid errors "missing etc".
@frisian
The "multiple comparisons with if" issue is fixed. Hard to understand but easy to fix (15 chars added)....
The issue with literal numeric used as index is fixed.
It should be the same mistake with variables used as indexes (reported also by dodicat), fixed later like for the other bugs you reported.
@srvaldez
I forgot you in my previous post for the LT_xxx missing bug fixed.
@jj007
I'll play also.
@coderjeff
Thanks. Obviously it's an hard road and the arrival is still far :-)
Not really from scratch as I used the ir-llvm module as a good basis. The x86 part was too difficult to understand.
However there should be some similitudes as no many ways to do same actions.
Some comments show that you went deep in my code, congratulations :-)
* -g option
For now it is necessary because each new line resets the list of used registers. In the future, I guess, it'll be possible to avoid it however the functionnality must be kept.
* style
Everyone uses the style that suits him ;-) I have started to do the changes.
* test suite
I wrote a "smart" bat file which loops inside all the directories to compile and execute each file. But the main purpose is to check compilation. I have run it on 5 files just for testing. Now I have to adapt it with what you provided and check the 2550 others...
* registers
I want to use the less memory moves and no pushes/pops except at the beginning of procs (ABI recommendations).
Also, I don't remember well, push/pop inside proc break the way the stack is managed, way that I defined at the beginning of project (see the stack organization at the top of code). This could be changed to accept register spilling as I am a bit more skilled now.
* To reduce the compilation time comment the "#define infodata" line. And as the "#define debugdata" is commented there is no debugging data added, the -g option is only used for triggering a register release (new line).
* global .ctors/.dtors
I know that I removed some code about them. I don't understand the purpose as I have not be able to get something using them. Examples welcome.
* duplicated procs
To avoid modifications in some other modules I have duplicated procs.
It's possible to remove them by modifying these modules, just by suppressing "private" instruction.
* gen gas64 ?
It seems to me more carefull to keep gas64 but I'm open to other options.
@all
The computations (+, -, *, etc) with integer numbers (8/16/32Bit) are executed after convertion in 64bit integer. So for speed reason use preferably integer 64bit varaiables. However the overhead isn't big although done twice (xxbit --> 64bit, computation and 64bit --> xxbit).
Thanks again for the time you spend and are going to spend ;-)
New version : http://users.freebasic-portal.de/sarg/fbcgas64.zip
About the zip file
Maybe the reason of the issue is that I updated directly new versions in it so the result is ok for windows but not for 7zip or other tools.
Sorry for the inconvenience I'll create a new one each time.
Gcc.exe is not used. When using fbc32_gas64 the win64 directory must be put like the win32 one to avoid errors "missing etc".
@frisian
The "multiple comparisons with if" issue is fixed. Hard to understand but easy to fix (15 chars added)....
The issue with literal numeric used as index is fixed.
It should be the same mistake with variables used as indexes (reported also by dodicat), fixed later like for the other bugs you reported.
@srvaldez
I forgot you in my previous post for the LT_xxx missing bug fixed.
@jj007
I'll play also.
@coderjeff
Thanks. Obviously it's an hard road and the arrival is still far :-)
Not really from scratch as I used the ir-llvm module as a good basis. The x86 part was too difficult to understand.
However there should be some similitudes as no many ways to do same actions.
Some comments show that you went deep in my code, congratulations :-)
* -g option
For now it is necessary because each new line resets the list of used registers. In the future, I guess, it'll be possible to avoid it however the functionnality must be kept.
* style
Everyone uses the style that suits him ;-) I have started to do the changes.
* test suite
I wrote a "smart" bat file which loops inside all the directories to compile and execute each file. But the main purpose is to check compilation. I have run it on 5 files just for testing. Now I have to adapt it with what you provided and check the 2550 others...
* registers
I want to use the less memory moves and no pushes/pops except at the beginning of procs (ABI recommendations).
Also, I don't remember well, push/pop inside proc break the way the stack is managed, way that I defined at the beginning of project (see the stack organization at the top of code). This could be changed to accept register spilling as I am a bit more skilled now.
* To reduce the compilation time comment the "#define infodata" line. And as the "#define debugdata" is commented there is no debugging data added, the -g option is only used for triggering a register release (new line).
* global .ctors/.dtors
I know that I removed some code about them. I don't understand the purpose as I have not be able to get something using them. Examples welcome.
* duplicated procs
To avoid modifications in some other modules I have duplicated procs.
It's possible to remove them by modifying these modules, just by suppressing "private" instruction.
* gen gas64 ?
It seems to me more carefull to keep gas64 but I'm open to other options.
@all
The computations (+, -, *, etc) with integer numbers (8/16/32Bit) are executed after convertion in 64bit integer. So for speed reason use preferably integer 64bit varaiables. However the overhead isn't big although done twice (xxbit --> 64bit, computation and 64bit --> xxbit).
Re: Gas64 (no more use of gcc, only gas) :-)
Hi all,
I'll try to update one time by week according found bugs and fixed.... New version : http://users.freebasic-portal.de/sarg/fbcgas64.zip
@frisian, @dodicat
It seems that all bugs you reported are fixed.
There was a big mistake sometimes with arrays and more a tricky optimization used in x86 that I didn't see, not easy to find.
By the way I didn't get the "Aborting due to runtime error 10 " error, so ????
@srvaldez,jepalza
I don't forget you :-)
Thank you again for testing and sending bug reports (small piece of code pls).
The 2 examples below work fine.
I'll try to update one time by week according found bugs and fixed.... New version : http://users.freebasic-portal.de/sarg/fbcgas64.zip
@frisian, @dodicat
It seems that all bugs you reported are fixed.
There was a big mistake sometimes with arrays and more a tricky optimization used in x86 that I didn't see, not easy to find.
By the way I didn't get the "Aborting due to runtime error 10 " error, so ????
@srvaldez,jepalza
I don't forget you :-)
Thank you again for testing and sending bug reports (small piece of code pls).
The 2 examples below work fine.
Code: Select all
' frisian » Mar 10, 2019 10:59
'
'Only array of 8bit integer works correct, 16bit, 32bit of 64bit give wrong numbers.
'Code: Select all
dim as integer<16> a(3), b = 1, c = 2
print "should be 0 0 0"
for i as integer = 1 to 3 : print a(i), : next : print
a(b) = b : a(c) = c
print "should be 1 2 0"
for i as integer = 1 to 3 : print a(i), : next : print
swap a(b), a(c)
print "should be 2 1 0"
for i as integer = 1 to 3 : print a(i), : next : print
print
'The next pieces of code work
dim as double real = 123.456
print real
print int(real)
print fix(real)
print
dim as integer<32> x = 111
print x, x / 7 , x \ 7
print int(x / 7)
print fix(x / 7)
print
dim as integer<8> y = 111
print y, y / 7.7
print int(y / 7.7)
print fix(y / 7.7)
print
print rnd
print rnd * 10
print int(rnd * 10)
print int(rnd * 10.123)
'When some FP calculation needs to be stored in a integer things go wrong.
'The next 3 snippets don't work, they all give an error
'Aborting due to runtime error 10 ("illegal instruction" signal) in test.bas::()
dim as integer<32> test1 = 10,answer1
answer1 = int( test1 / 2.2)
print "answer1=";answer1
dim as integer<32> test2 = 10,answer2
answer2 = test2 / 2.2
print "answer2=";answer2
dim as integer<32> test3 = 10,answer3
answer3 = rnd * 10
print "answer3=";answer3
'When its pure integer math then there's no problem.
dim as integer<32> test4 = 10, answer4
answer4 = test4 * 10 \ 22
print "answer4=";answer4
'var = -var does return the wrong value for integers and real, (0) instead of then negative number.
dim as integer<32> test5 = 10,answer5
answer5 = -test5
print "answer5=";answer5
dim as double test6 = rnd, answer6
answer6 = test6
print "answer61=";answer6
answer6 = int(test6 * 100 / 3)
print "answer62=";answer6
answer6 = -test6
print "answer63=";answer6
print "END"
sleep
Code: Select all
enum enm
enm1
enm2
end enum
type arraydim
lower as longint
upper as longint
end type
sub testarray(dtb() as arraydim)
static as integer statc
if 1 then
dim as enm venm=any
venm=enm1
end if
if 1 then
dim as enm venm=any
venm=enm1
end if
statc=4510
dtb(0).lower=1
dtb(0).upper=2
dtb(1).lower=3
dtb(1).upper=4
end sub
dim as integer a(1 to 5)
for n as long=1 to 5
a(n)=21*n
next
print "load done 01"
''===========
a(3)=7852
''===========
dim as integer n=4
dim shared as integer shrd(1 to 5)
shrd(2)=678
shrd(n)=789
print "must be 678,789",shrd(2),shrd(n)
''===========
dim as integer rdm()
redim as integer rdm(9)
rdm(7)=147
rdm(n)=963
print "must be 147 963",rdm(7),rdm(n)
''===========
dim shared as integer rdms()
redim shared as integer rdms(8)
rdms(7)=1456
rdms(n)=1326
print "must be 1456 1326",rdms(7),rdms(n)
''===========
for n as long=1 to 5
print a(n)
next
print "must be 21 42 7852 84 105"
dim as arraydim dtb(5)
testarray(dtb())
print dtb(0).lower
print dtb(0).upper
print dtb(1).lower
print dtb(1).upper
print "must be 1 2 3 4"
print "END"
sleep
Re: Gas64 (no more use of gcc, only gas) :-)
@SARG
You have solved some problems, some of my programs are running correct, but the problem with FP calculation stored in a integer still goes wrong.
The test crashes the program also command line switch -exx added wil result in no exe file.
z.bas (Zhang-Suen thinning algorithm [Rosetta Code])
command line fbc64_gas64 -RR -R -gen gas64 -v -g
Produces a exe file that works correct.
Command line fbc64_gas64 -gen gas64 will produce an runtime error in ir-gas64.bas
[C:\FBC105win64]fbc64_gas64 -gen gas64 z.bas
Aborting due to runtime error 6 (out of bounds array access) at line 2685 of ir-gas64.bas::HLOADOPERANDSANDWRITEBOP()
Both produce no exe file.
Command line fbc64_gas64 -RR -R -gen gas64 -v -g -exx
Produces an exe file that's about 8k bigger but when trying to run, it crashes without an error message, windows report "z.exe has stop working"
You have solved some problems, some of my programs are running correct, but the problem with FP calculation stored in a integer still goes wrong.
The test crashes the program also command line switch -exx added wil result in no exe file.
Code: Select all
dim as integer<32> test = 10,answer
answer = rnd * 10
print answer
Code: Select all
Data "00000000000000000000000000000000"
Data "01111111110000000111111110000000"
Data "01110001111000001111001111000000"
Data "01110000111000001110000111000000"
Data "01110001111000001110000000000000"
Data "01111111110000001110000000000000"
Data "01110111100000001110000111000000"
Data "01110011110011101111001111011100"
Data "01110001111011100111111110011100"
Data "00000000000000000000000000000000"
Data "END"
' ------=< MAIN >=------
Dim As UInteger x, y, m, n
Dim As String input_str
Do ' find out how big it is
Read input_str
If input_str = "END" Then Exit Do
If x < Len(input_str) Then x = Len(input_str)
y = y + 1
Loop
m = x -1 : n = y -1
ReDim As UByte old(m, n), new_(m, n)
y = 0
Restore ' restore data pointer
Do ' put data in array
Read input_str
If input_str="END" Then Exit Do
For x = 0 To Len(input_str) -1
old(x,y) = input_str[x] - Asc("0")
' print image
If old(x, y) = 0 Then Print "."; Else Print "#";
Next
Print
y = y + 1
Loop
'corners and sides do not change
For x = 0 To m
new_(x, 0) = old(x, 0)
new_(x, n) = old(x, n)
Next
For y = 0 To n
new_(0, y) = old(0, y)
new_(m, y) = old(m, y)
Next
Dim As UInteger tmp, change, stage = 1
Do
change = 0
For y = 1 To n -1
For x = 1 To m -1
' -1-
If old(x,y) = 0 Then ' first condition, p1 must be black
new_(x,y) = 0
Continue For
End If
' -2-
tmp = old(x, y -1) + old(x +1, y -1)
tmp = tmp + old(x +1, y) + old(x +1, y +1) + old(x, y +1)
tmp = tmp + old(x -1, y +1) + old(x -1, y) + old(x -1, y -1)
If tmp < 2 OrElse tmp > 6 Then ' 2 <= B(p1) <= 6
new_(x, y) = 1
Continue For
End If
' -3-
tmp = 0
If old(x , y ) = 0 And old(x , y -1) = 1 Then tmp += 1 ' p1 > p2
If old(x , y -1) = 0 And old(x +1, y -1) = 1 Then tmp += 1 ' p2 > p3
If old(x +1, y -1) = 0 And old(x +1, y ) = 1 Then tmp += 1 ' p3 > p4
If old(x +1, y ) = 0 And old(x +1, y +1) = 1 Then tmp += 1 ' p4 > p5
If old(x +1, y +1) = 0 And old(x , y +1) = 1 Then tmp += 1 ' p5 > p6
If old(x , y +1) = 0 And old(x -1, y +1) = 1 Then tmp += 1 ' p6 > p7
If old(x -1, y +1) = 0 And old(x -1, y ) = 1 Then tmp += 1 ' p7 > p8
If old(x -1, y ) = 0 And old(x -1, y -1) = 1 Then tmp += 1 ' p8 > p9
If old(x -1, y -1) = 0 And old(x , y -1) = 1 Then tmp += 1 ' p9 > p2
' tmp = 1 ==> A(P1) = 1
If tmp <> 1 Then
new_(x, y) = 1
Continue For
End If
If (stage And 1) = 1 Then
' step 1 -4- -5-
If (old(x, y -1) + old(x +1, y) + old(x, y +1)) = 3 OrElse _
(old(x +1, y) + old(x, y +1) + old(x -1, y)) = 3 Then
new_(x, y) = 1
Continue For
End If
Else
' step 2 -4- -5-
If (old(x, y -1) + old(x +1, y) + old(x -1, y)) = 3 OrElse _
(old(x, y -1) + old(x, y +1) + old(x -1, y)) = 3 Then
new_(x, y) = 1
Continue For
End If
End If
' all condition are met, make p1 white (0)
new_(x, y) = 0
change = 1 ' flag change
Next
Next
' copy new_() into old()
For y = 0 To n
For x = 0 To m
old(x, y) = new_(x, y)
Next
Next
stage += 1
Loop Until change = 0 ' stop when there are no changes made
Print ' print result
Print "End result"
For y = 0 To n
For x = 0 To m
If old(x, y) = 0 Then Print "."; Else Print "#";
Next
Print
Next
' empty keyboard buffer
While Inkey <> "" : Wend
Print : Print "hit any key to end program"
Sleep
End
Code: Select all
[C:\FBC105win64]fbc64_gas64 -RR -R -gen gas64 -v -g z.bas
FreeBASIC Compiler - Version 1.06.0 (03-18-2019), built for win64 (64bit)
Copyright (C) 2004-2019 The FreeBASIC development team.
standalone
target: win64, x86-64, 64bit
compiling: z.bas -o z.a64 (main module)
assembling: C:\FBC105win64\bin\win64\as.exe --64 "z.a64" -o "z.o"
linking: C:\FBC105win64\bin\win64\ld.exe -m i386pep -o "z.exe" -subsystem console "C:\FBC105win64\lib\win64\fbextra.x" --stack 1048576,
1048576 -L "C:\FBC105win64\lib\win64" -L "." "C:\FBC105win64\lib\win64\crt2.o" "C:\FBC105win64\lib\win64\crtbegin.o" "C:\FBC105win64\lib\win
64\fbrt0.o" "z.o" "-(" -lfb -lgcc -lmsvcrt -lkernel32 -luser32 -lmingw32 -lmingwex -lmoldname -lgcc_eh "-)" "C:\FBC105win64\lib\win64\crtend
.o"
Command line fbc64_gas64 -gen gas64 will produce an runtime error in ir-gas64.bas
[C:\FBC105win64]fbc64_gas64 -gen gas64 z.bas
Aborting due to runtime error 6 (out of bounds array access) at line 2685 of ir-gas64.bas::HLOADOPERANDSANDWRITEBOP()
Both produce no exe file.
Command line fbc64_gas64 -RR -R -gen gas64 -v -g -exx
Code: Select all
[C:\FBC105win64]fbc64_gas64 -RR -R -gen gas64 -v -g -exx z.bas
FreeBASIC Compiler - Version 1.06.0 (03-18-2019), built for win64 (64bit)
Copyright (C) 2004-2019 The FreeBASIC development team.
standalone
target: win64, x86-64, 64bit
compiling: z.bas -o z.a64 (main module)
assembling: C:\FBC105win64\bin\win64\as.exe --64 "z.a64" -o "z.o"
linking: C:\FBC105win64\bin\win64\ld.exe -m i386pep -o "z.exe" -subsystem console "C:\FBC105win64\lib\win64\fbextra.x" --stack 1048576,
1048576 -L "C:\FBC105win64\lib\win64" -L "." "C:\FBC105win64\lib\win64\crt2.o" "C:\FBC105win64\lib\win64\crtbegin.o" "C:\FBC105win64\lib\win
64\fbrt0.o" "z.o" "-(" -lfb -lgcc -lmsvcrt -lkernel32 -luser32 -lmingw32 -lmingwex -lmoldname -lgcc_eh "-)" "C:\FBC105win64\lib\win64\crtend
.o"
Re: Gas64 (no more use of gcc, only gas) :-)
Hi SARG
> * style
> Everyone uses the style that suits him ;-) I have started to do the changes.
The reason I mention this, is that the code is worked on by multiple people, and visually, it is less distracting when the overall code has similar style. When I go back and review code years later, I can't tell if I wrote it or some other developer, it's just part of freebasic source code. Just curious, I notice lots of code posted (not just here) that use spaces instead of tabs. Your personal preference? or your IDE's?
> * registers
> I want to use the less memory moves and no pushes/pops except at the beginning of procs (ABI recommendations).
> Also, I don't remember well, push/pop inside proc break the way the stack is managed, way that I defined at the beginning of project (see the stack organization at the top of code). This could be changed to accept register spilling as I am a bit more skilled now.
Plan to run out of registers. But doesn't mean must use push/pop. When you create the frame, need to reserve enough stack space for all local/temporary variables, plus space to spill registers when you run out. You track the stack pointer position yourself at compile time in IR and just use MOV instructions to save/restore registers. Also, if you know that a vreg won't be used ever again in the remainder of the procedure, can free the actual register attached to it so it can be re-used.
> * global .ctors/.dtors
> I know that I removed some code about them. I don't understand the purpose as I have not be able to get something using them. Examples welcome.
global .ctors (module constructor) and .dtors (module destructor) are procedures that are executed before "main()" as part of the EXE's initialization code. In gcc .ctors/.dtors are specially named linker sections. Should be similar to gas32. The test suite uses module ctors/dtors to register test functions with the testing framework. fbc will also generate .ctors/.dtors to initialize/destrory some kinds of variable types.
> * gen gas64 ?
> It seems to me more carefull to keep gas64 but I'm open to other options.
sounds good
> * style
> Everyone uses the style that suits him ;-) I have started to do the changes.
The reason I mention this, is that the code is worked on by multiple people, and visually, it is less distracting when the overall code has similar style. When I go back and review code years later, I can't tell if I wrote it or some other developer, it's just part of freebasic source code. Just curious, I notice lots of code posted (not just here) that use spaces instead of tabs. Your personal preference? or your IDE's?
> * registers
> I want to use the less memory moves and no pushes/pops except at the beginning of procs (ABI recommendations).
> Also, I don't remember well, push/pop inside proc break the way the stack is managed, way that I defined at the beginning of project (see the stack organization at the top of code). This could be changed to accept register spilling as I am a bit more skilled now.
Plan to run out of registers. But doesn't mean must use push/pop. When you create the frame, need to reserve enough stack space for all local/temporary variables, plus space to spill registers when you run out. You track the stack pointer position yourself at compile time in IR and just use MOV instructions to save/restore registers. Also, if you know that a vreg won't be used ever again in the remainder of the procedure, can free the actual register attached to it so it can be re-used.
> * global .ctors/.dtors
> I know that I removed some code about them. I don't understand the purpose as I have not be able to get something using them. Examples welcome.
global .ctors (module constructor) and .dtors (module destructor) are procedures that are executed before "main()" as part of the EXE's initialization code. In gcc .ctors/.dtors are specially named linker sections. Should be similar to gas32. The test suite uses module ctors/dtors to register test functions with the testing framework. fbc will also generate .ctors/.dtors to initialize/destrory some kinds of variable types.
> * gen gas64 ?
> It seems to me more carefull to keep gas64 but I'm open to other options.
sounds good
Re: Gas64 (no more use of gcc, only gas) :-)
Hi all,
New version : http://users.freebasic-portal.de/sarg/fbcgas64.zip
Symb-define.bas modified to get "gas64" when __FB_BACKEND__ is used. For now just to easily see under what version the exe has been compiled.
Could be changed in the future to keep only gas and 32/64bit as gcc and 32/64bit.
@srvaldez
Nbody example
bug fixed . Explanation : dt was transmited but wrongly retrieved so equal zero ...... No other changes
gas64 : 15.166
gcc64 : 13.913
gas32 : 14.725
@ jj2007
Your benchmark 100000 loops with LoadSaveFile.bi. I added total at end of print --> Print " for";loops*2;"*find a string",total
finding "maxCell" = 200 000
gas32 : 6.872 / 1.513
gcc32 : 7.049 / 1.529
gas64 : 6.420 / 1.385
@dodicat
bug fixed for qmult. Explanation : for shared array the space reserved was only for one element (mod and div)..... Not easy to find as strange results. No other changes.
gas32 : 0.642
gcc64 : 0.658
gas64 : 0.721
@frisian
With the example of code given in a previous post I got the same display using gas64 or gcc64 and no crash :
And compiling/executing this without any problem.
So I don't understand your issue with FP calculation. Send me by PM the a64 and exe files you get.
However the compiler should not stop (out of bounds...) any more on lack of registers, the size of the array reghandle() is increased as coderjeff suggested.
@coderjeff
New version : http://users.freebasic-portal.de/sarg/fbcgas64.zip
Symb-define.bas modified to get "gas64" when __FB_BACKEND__ is used. For now just to easily see under what version the exe has been compiled.
Could be changed in the future to keep only gas and 32/64bit as gcc and 32/64bit.
@srvaldez
Nbody example
bug fixed . Explanation : dt was transmited but wrongly retrieved so equal zero ...... No other changes
gas64 : 15.166
gcc64 : 13.913
gas32 : 14.725
@ jj2007
Your benchmark 100000 loops with LoadSaveFile.bi. I added total at end of print --> Print " for";loops*2;"*find a string",total
finding "maxCell" = 200 000
gas32 : 6.872 / 1.513
gcc32 : 7.049 / 1.529
gas64 : 6.420 / 1.385
@dodicat
bug fixed for qmult. Explanation : for shared array the space reserved was only for one element (mod and div)..... Not easy to find as strange results. No other changes.
gas32 : 0.642
gcc64 : 0.658
gas64 : 0.721
@frisian
With the example of code given in a previous post I got the same display using gas64 or gcc64 and no crash :
Code: Select all
should be 0 0 0
0 0 0
should be 1 2 0
1 2 0
should be 2 1 0
2 1 0
123.456
123
123
111 15.85714285714286 15
15
15
111 14.41558441558442
14
14
0.3300995409954339
3.290384791325778
5
7
answer1= 4
answer2= 5
answer3= 6
answer4= 4
answer5=-10
answer61= 0.6527107947040349
answer62= 21
answer63=-0.6527107947040349
end
Code: Select all
dim as integer<32> test = 10,answer
answer = rnd * 10
print answer
what are the both ? Anyway the "-g " MUST be used.frisian wrote:Command line fbc64_gas64 -gen gas64 will produce an runtime error in ir-gas64.bas
[C:\FBC105win64]fbc64_gas64 -gen gas64 z.bas
Aborting due to runtime error 6 (out of bounds array access) at line 2685 of ir-gas64.bas::HLOADOPERANDSANDWRITEBOP()
Both produce no exe file.
However the compiler should not stop (out of bounds...) any more on lack of registers, the size of the array reghandle() is increased as coderjeff suggested.
It "seems" something wrong with -exx. I have to investigate.frisian wrote:Produces an exe file that's about 8k bigger but when trying to run, it crashes without an error message, windows report "z.exe has stop working"
@coderjeff
Understood, changes done (most key words in lower case, 4 space tabs) but still a bit of work (byval/byref).coderJeff wrote:The reason I mention this, is that the code is worked on by multiple people, and visually, it is less distracting when the overall code has similar style. When I go back and review code years later, I can't tell if I wrote it or some other developer, it's just part of freebasic source code.
I guess the IDE was configured like this and personaly I don't like tabs. When you put the text in another editor you don't get the same display, with spaces no problem...coderJeff wrote:Just curious, I notice lots of code posted (not just here) that use spaces instead of tabs. Your personal preference? or your IDE's?
I have already reserved space to spill the registers however it's a fixed size (for each register except rbp/rip) to save them, if necessary, just at the beginning of procs. I have to think carefully about that but my view of this problem is now better than I began the project :-)coderJeff wrote:Plan to run out of registers. But doesn't mean must use push/pop. When you create the frame, need to reserve enough stack space for all local/temporary variables, plus space to spill registers when you run out. You track the stack pointer position yourself at compile time in IR and just use MOV instructions to save/restore registers. Also, if you know that a vreg won't be used ever again in the remainder of the procedure, can free the actual register attached to it so it can be re-used.
Ok understood. Shared object should be in this case. I'll try that.coderJeff wrote:global .ctors (module constructor) and .dtors (module destructor) are procedures that are executed before "main()" as part of the EXE's initialization code. In gcc .ctors/.dtors are specially named linker sections. Should be similar to gas32. The test suite uses module ctors/dtors to register test functions with the testing framework. fbc will also generate .ctors/.dtors to initialize/destrory some kinds of variable types.
Re: Gas64 (no more use of gcc, only gas) :-)
Do I miss something?
Code: Select all
fb.bi(22) error 23: File not found, "list.bi" in '#include once "list.bi"'
Code: Select all
FreeBasic\fbc64_gas64.exe -t 2000 -Wc -Ofast -s console FreeBasic\tmp\TmpFb.bas
FreeBasic\tmp\TmpFb.bas() error 91: Executable not found: "FreeBasic\bin\win64\gcc.exe"
Re: Gas64 (no more use of gcc, only gas) :-)
@jj2007
I suggest
I suggest
Code: Select all
FreeBasic\fbc64_gas64.exe -t 2000 -g -s console FreeBasic\tmp\TmpFb.bas
Re: Gas64 (no more use of gcc, only gas) :-)
jj2007 wrote:Do I miss something?Code: Select all
fb.bi(22) error 23: File not found, "list.bi" in '#include once "list.bi"'
Code: Select all
FreeBasic\fbc64_gas64.exe -t 2000 -Wc -Ofast -s console FreeBasic\tmp\TmpFb.bas FreeBasic\tmp\TmpFb.bas() error 91: Executable not found: "FreeBasic\bin\win64\gcc.exe"
I guess I'm not clear enough or maybe you should read more carefully.... :-)srvaldez wrote:@jj2007
I suggestCode: Select all
FreeBasic\fbc64_gas64.exe -t 2000 -g -s console FreeBasic\tmp\TmpFb.bas
-gen gas64 and also -g are mandatory.
Without -gen gas64 the default compiler backend is selected (on 64bit --> gcc). I could force the gas64 option when using fbc64/32_gas64.exe ????
Without -g it could work with very small codes as the registers are not anymore freed each line.
@jj2007
What are you trying to compile ?
There is (should be) no change when using other backends.
Re: Gas64 (no more use of gcc, only gas) :-)
[rant]Maybe it's not your fault, no idea. Every single FB "package" has its own quirks, needs specific settings, environment variables (set PATH? set INCLUDE?). Most of my FB stuff works now, but every time I see some interesting non-standard stuff, it needs a trial and error session to find out where exactly gccwhatever.exe has to sit, and where it might find its includes. I have never ever experienced a programming language that had so messy setup requirements. Even the Masm32 setup (note: utterly complicated ASSEMBLER, not Beginner's All-purpose Symbolic Instruction Code) is orders of magnitude simpler.[/rant]SARG wrote:I guess I'm not clear enough or maybe you should read more carefully.... :-)