FBC 1.00.0

For other topics related to the FreeBASIC project or its community.
marcov
Posts: 2806
Joined: Jun 16, 2005 9:45
Location: Eindhoven, NL
Contact:

Re: FBC 1.00.0

Postby marcov » Oct 24, 2014 9:06

MichaelW wrote:
marcov wrote:That reminds me, are globals RIP relative in FB (win64)?
See e.g. Eli Bendersky's

While I am familiar with IP-relative addressing in code, where a jump or call destination can be effectively encoded as a "displacement", and where the functional description of these operations makes perfect sense, IP-relative data addressing seems more than a little bizarre. The instruction pointer, which formerly was not directly accessible in code, now is directly accessible, and usable as part of an indirect-memory operand.


Not general data, but STATIC data. The static memory segments are typically fairly small (and remember, 64-bit STILL allows 2GB offsets, so small is relative), so if the OS allocates the static segments in the vicinity of the code that it belongs to, one can save some speed and make the code denser. (which improves branch performance etc). Moreover, since the property is bound to the symbol, exceptions can be made for very large symbols. (it seems the medium model does that already at 64kb, which was new for me)

It does have a tendency to frustrate assembler use though, which is why I mentioned it here.
MichaelW
Posts: 3500
Joined: May 16, 2006 22:34
Location: USA

Re: FBC 1.00.0

Postby MichaelW » Oct 25, 2014 6:19

marcov wrote:
MichaelW wrote:Not general data, but STATIC data.

Yes, I missed that point because it could be used for (almost) any data.
marcov
Posts: 2806
Joined: Jun 16, 2005 9:45
Location: Eindhoven, NL
Contact:

Re: FBC 1.00.0

Postby marcov » Oct 26, 2014 11:48

Btw, on *nix global data symbols are also PIC in PIC binaries and addressed via the GOT. Same reason as why code is PIC, if you have multiple shared libraries with a (static) data segment on a fixed position, data can conflict too
dodicat
Posts: 6026
Joined: Jan 10, 2006 20:30
Location: Scotland

Re: FBC 1.00.0

Postby dodicat » Oct 27, 2014 1:09

This is for FB 1.01.0

error 88: Recursive DEFINE not allowed, found 'or' in 'if inbox(b1,mx,my) or inbox(b2,mx,my) then'

Here is the code snippet.

OK in FBC 1.00
Win XP.

Code: Select all


#define inbox(c,mx,my) (mx)>(c.x-c.r) and (mx)<(c.x+c.r) and (my)>(c.y-c.r) and (my)<(c.y+c.r)

type box
    as integer x,y,r
end type

dim as integer mx,my

screen 19,,2
screenset 1,0
dim as box b1,b2
b1.x=200
b1.y=200
b1.r=50

b2.x=500
b2.y=200
b2.r=50
do
    getmouse mx,my
    cls
    line(b1.x-b1.r,b1.y-b1.r)-(b1.x+b1.r,b1.y+b1.r),3,bf
    line(b2.x-b2.r,b2.y-b2.r)-(b2.x+b2.r,b2.y+b2.r),3,bf
    'workaround===================
    'var x1=inbox(b1,mx,my),x2=inbox(b2,mx,my)
    'if x1 or x2 then
    '============================
   
    if inbox(b1,mx,my) or inbox(b2,mx,my) then
    beep
    end if
    flip
    sleep 1,1
    loop until len(inkey)
dkl
Site Admin
Posts: 3210
Joined: Jul 28, 2005 14:45
Location: Germany

Re: FBC 1.00.0

Postby dkl » Oct 27, 2014 12:55

Weird, I can't reproduce that with my Git builds, I seems to compile fine.
dodicat
Posts: 6026
Joined: Jan 10, 2006 20:30
Location: Scotland

Re: FBC 1.00.0

Postby dodicat » Oct 27, 2014 13:14

I have downloaded fbc_win32_mingw_0171_2014_10-24.zip.
from http://users.freebasic-portal.de/stw/builds/win32/

The compiler message is still:


Command executed:
"C:\Documents and Settings\USER\Desktop\FreeBASIC\FB1\builds\fbc_win32_mingw\fbc.exe " -lang fb -gen gas -exx -asm intel "C:\Documents and Settings\USER\Desktop\fbc\FBIde\FBIDETEMP.bas"

Compiler output:
C:\Documents and Settings\USER\Desktop\fbc\FBIde\FBIDETEMP.bas(31) error 88: Recursive DEFINE not allowed, found 'or' in 'if inbox(b1,mx,my) or inbox(b2,mx,my) then'

Results:
Compilation failed

System:
FBIde: 0.4.6
fbc: FreeBASIC Compiler - Version 1.01.0 (10-24-2014), built for win32 (32bit)
OS: Windows XP (build 2600, Service Pack 3)
fxm
Posts: 9310
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: FBC 1.00.0

Postby fxm » Oct 27, 2014 13:56

That works fine for me.

Same configuration:
- fbc_win32_mingw_0171_2014-10-24.zip
- FBIde 0.4.6 r4
log wrote:Command executed:
"d:\Documents and Settings\t0003830\Mes documents\fbc1.01.0.St_W\fbc.exe" "d:\Documents and Settings\t0003830\Mes documents\FBIde0.4.6r4_fbc1.01.0\FBIDETEMP.bas" -gen gas -exx -arch 686 -w pedantic "d:\documents and settings\t0003830\mes documents\freebasic-1.00.0-win32+dos\bin\win32\res\fblogo.rc"

Results:
Compilation successful
Generated executable: d:\Documents and Settings\t0003830\Mes documents\FBIde0.4.6r4_fbc1.01.0\FBIDETEMP.exe

System:
FBIde: 0.4.6
fbc: FreeBASIC Compiler - Version 1.01.0 (10-24-2014), built for win32 (32bit)
OS: Windows XP (build 2600, Service Pack 3)
dodicat
Posts: 6026
Joined: Jan 10, 2006 20:30
Location: Scotland

Re: FBC 1.00.0

Postby dodicat » Oct 27, 2014 18:20

I tested the new compiler with other programs -- OK.
If I bracket :
if (inbox(b1,mx,my)) or inbox(b2,mx,my) then blah ... blah
it is OK.
If I bracket each side of the OR, or the other side of the OR, it is OK.

I put a start_shell in with the compiler fbc.exe and tried to compile the code snippet independently of an ide, with no flags.
I get:


Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

C:\Documents and Settings\USER\Desktop\FreeBASIC\FB1\builds\fbc_win32_mingw>fbc
macrotest.bas
macrotest.bas(30) error 88: Recursive DEFINE not allowed, found 'or' in 'if inbo
x(b1,mx,my) or inbox(b2,mx,my) then'

C:\Documents and Settings\USER\Desktop\FreeBASIC\FB1\builds\fbc_win32_mingw>

Strange!
fxm
Posts: 9310
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: FBC 1.00.0

Postby fxm » Oct 27, 2014 18:53

Compile with option '-pp' (emitting the preprocessed input file only, do not compiling) and examine the file 'FBIDETEMP.pp.bas' to try to understand that behavior.
dodicat
Posts: 6026
Joined: Jan 10, 2006 20:30
Location: Scotland

Re: FBC 1.00.0

Postby dodicat » Oct 27, 2014 19:04

OK fxm.
here is the pp file:

Code: Select all

type box
 as integer x,y,r
end type

dim as integer mx,my

screen 19,,2
screenset 1,0
dim as box b1,b2
b1.x=200
b1.y=200
b1.r=50

b2.x=500
b2.y=200
b2.r=50
do
 getmouse mx,my
 cls
 line(b1.x-b1.r,b1.y-b1.r)-(b1.x+b1.r,b1.y+b1.r),3,bf
 line(b2.x-b2.r,b2.y-b2.r)-(b2.x+b2.r,b2.y+b2.r),3,bf

 if (mx)>(b1.x-b1.r) and (mx)<(b1.x+b1.r) and (my)>(b1.y-b1.r) and (my)<(b1.y+b1.r) or inbox(b2,mx,my)  then   beep
 end if
 flip
 sleep 1,1
 loop until len(inkey)
 


inbox to the right of or has not expanded for some reason.
Beep seems to be in the wrong position.

I'll download the GIT file again, maybe I got a corruption.
fxm
Posts: 9310
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: FBC 1.00.0

Postby fxm » Oct 27, 2014 19:10

I get this:

Code: Select all

type box
 as integer x,y,r
end type

dim as integer mx,my

screen 19,,2
screenset 1,0
dim as box b1,b2
b1.x=200
b1.y=200
b1.r=50

b2.x=500
b2.y=200
b2.r=50
do
 getmouse mx,my
 cls
 line(b1.x-b1.r,b1.y-b1.r)-(b1.x+b1.r,b1.y+b1.r),3,bf
 line(b2.x-b2.r,b2.y-b2.r)-(b2.x+b2.r,b2.y+b2.r),3,bf

 if (mx)>(b1.x-b1.r) and (mx)<(b1.x+b1.r) and (my)>(b1.y-b1.r) and (my)<(b1.y+b1.r) or (mx)>(b2.x-b2.r) and (mx)<(b2.x+b2.r) and (my)>(b2.y-b2.r) and (my)<(b2.y+b2.r) then
 beep
 end if
 flip
 sleep 1,1
 loop until len(inkey)
dodicat
Posts: 6026
Joined: Jan 10, 2006 20:30
Location: Scotland

Re: FBC 1.00.0

Postby dodicat » Oct 27, 2014 20:20

I re-downloaded, put the compiler in a folder on C: drive.

Still the compile error.

I transferred everything to my pentium 3 machine.

I didn't copy the snippet to fbide (incase of an editor bug, which I have had with fbide in the past), but transferred via wordpad.

My other machine gives the same error with the October 25 th. build.
counting_pine
Site Admin
Posts: 6174
Joined: Jul 05, 2005 17:32
Location: Manchester, Lancs

Re: FBC 1.00.0

Postby counting_pine » Oct 27, 2014 22:47

Would it be possible to post a hexdump of your code, or link to a zip file?
I'm wondering if there might be a subtle problem, e.g. a nonprintable character, something that's not showing up in the code box.
Either way, if we're all using exactly the same code file, it would eliminate some factors.
dodicat
Posts: 6026
Joined: Jan 10, 2006 20:30
Location: Scotland

Re: FBC 1.00.0

Postby dodicat » Oct 27, 2014 23:59

I've taken the comments out.
The code is:

Code: Select all

#define inbox(c,mx,my) (mx)>(c.x-c.r) and (mx)<(c.x+c.r) and (my)>(c.y-c.r) and (my)<(c.y+c.r)

type box
    as integer x,y,r
end type

dim as integer mx,my

screen 19,,2
screenset 1,0
dim as box b1,b2
b1.x=200
b1.y=200
b1.r=50

b2.x=500
b2.y=200
b2.r=50
do
    getmouse mx,my
    cls
    line(b1.x-b1.r,b1.y-b1.r)-(b1.x+b1.r,b1.y+b1.r),3,bf
    line(b2.x-b2.r,b2.y-b2.r)-(b2.x+b2.r,b2.y+b2.r),3,bf
   
    if inbox(b1,mx,my)  or  inbox(b2,mx,my) then
    beep
    end if
    flip
    sleep 1,1
    loop until len(inkey)


The hexdump is:

Code: Select all

 
E:\hexdunp>sfk172 hexdump -showle testmacro.bas
:file testmacro.bas
 >0D0A2364 6566696E 6520696E 626F7828< ..#define inbox( 00000000
 >632C6D78 2C6D7929 20286D78 293E2863< c,mx,my) (mx)>(c 00000010
 >2E782D63 2E722920 616E6420 286D7829< .x-c.r) and (mx) 00000020
 >3C28632E 782B632E 72292061 6E642028< <(c.x+c.r) and ( 00000030
 >6D79293E 28632E79 2D632E72 2920616E< my)>(c.y-c.r) an 00000040
 >6420286D 79293C28 632E792B 632E7229< d (my)<(c.y+c.r) 00000050
 >200D0A0D 0A747970 6520626F 780D0A20<  ....type box..  00000060
 >20202061 7320696E 74656765 7220782C<    as integer x, 00000070
 >792C720D 0A656E64 20747970 650D0A0D< y,r..end type... 00000080
 >0A64696D 20617320 696E7465 67657220< .dim as integer  00000090
 >6D782C6D 790D0A0D 0A736372 65656E20< mx,my....screen  000000A0
 >31392C2C 320D0A73 63726565 6E736574< 19,,2..screenset 000000B0
 >20312C30 0D0A6469 6D206173 20626F78<  1,0..dim as box 000000C0
 >2062312C 62320D0A 62312E78 3D323030<  b1,b2..b1.x=200 000000D0
 >0D0A6231 2E793D32 30300D0A 62312E72< ..b1.y=200..b1.r 000000E0
 >3D35300D 0A0D0A62 322E783D 3530300D< =50....b2.x=500. 000000F0
 >0A62322E 793D3230 300D0A62 322E723D< .b2.y=200..b2.r= 00000100
 >35300D0A 646F0D0A 20202020 6765746D< 50..do..    getm 00000110
 >6F757365 206D782C 6D790D0A 20202020< ouse mx,my..     00000120
 >636C730D 0A202020 206C696E 65286231< cls..    line(b1 00000130
 >2E782D62 312E722C 62312E79 2D62312E< .x-b1.r,b1.y-b1. 00000140
 >72292D28 62312E78 2B62312E 722C6231< r)-(b1.x+b1.r,b1 00000150
 >2E792B62 312E7229 2C332C62 660D0A20< .y+b1.r),3,bf..  00000160
 >2020206C 696E6528 62322E78 2D62322E<    line(b2.x-b2. 00000170
 >722C6232 2E792D62 322E7229 2D286232< r,b2.y-b2.r)-(b2 00000180
 >2E782B62 322E722C 62322E79 2B62322E< .x+b2.r,b2.y+b2. 00000190
 >72292C33 2C62660D 0A202020 200D0A20< r),3,bf..    ..  000001A0
 >20202069 6620696E 626F7828 62312C6D<    if inbox(b1,m 000001B0
 >782C6D79 2920206F 72202069 6E626F78< x,my)  or  inbox 000001C0
 >2862322C 6D782C6D 79292074 68656E20< (b2,mx,my) then  000001D0
 >0D0A2020 20206265 65700D0A 20202020< ..    beep..     000001E0
 >656E6420 69660D0A 20202020 666C6970< end if..    flip 000001F0
 >0D0A2020 2020736C 65657020 312C310D< ..    sleep 1,1. 00000200
 >0A202020 206C6F6F 7020756E 74696C20< .    loop until  00000210
 >6C656E28 696E6B65 7929<              len(inkey)       00000220


I got the hexdump console from:
http://www.stahlworks.com/dev/index.php?tool=hexdump
I popped it on to a usb pen and ran it from there.
St_W
Posts: 1479
Joined: Feb 11, 2009 14:24
Location: Austria
Contact:

Re: FBC 1.00.0

Postby St_W » Oct 28, 2014 19:46

I can reproduce the issue with the provided file. The important thing is the additional space character at the end of the "#define ..." line.
I've reconstructed the file from the hexdump and uploaded it here: http://users.freebasic-portal.de/stw/fi ... _error.bas

I've also tried to remove all unecessary stuff and reduced the program to a minimalistic version: http://users.freebasic-portal.de/stw/fi ... or_min.bas

Code: Select all

#define inbox(c) 1 'insert trailing space character here and remove this comment
if inbox(1) or inbox(1) then beep


fbc test_define_error_min.bas wrote:test.bas(2) error 88: Recursive DEFINE not allowed, found 'or' in 'if inbox(1) or inbox(1) then beep'
test.bas(2) error 32: Expected 'END IF' in 'if inbox(1) or inbox(1) then beep'

Return to “Community Discussion”

Who is online

Users browsing this forum: badidea and 2 guests