Forum
Dim At Issue? (1.15.0-beta4) - Printable Version

+- Forum (https://www.boriel.com/forum)
+-- Forum: Compilers and Computer Languages (https://www.boriel.com/forum/forumdisplay.php?fid=12)
+--- Forum: ZX Basic Compiler (https://www.boriel.com/forum/forumdisplay.php?fid=11)
+---- Forum: Help & Support (https://www.boriel.com/forum/forumdisplay.php?fid=16)
+---- Thread: Dim At Issue? (1.15.0-beta4) (/showthread.php?tid=1037)



Dim At Issue? (1.15.0-beta4) - Ljg701 - 03-09-2021

Hello Boriel,

The following array initiation code I don't think is initiating the array data at the correct address. In the example below, the peek returns a value of 255 rather than 1, also @test doesn't return a value of $c000  (Version  1.15.0-beta4 + NextBuild)

Code:
'!ORG=24576
'!OPT=4

dim test(0 to 3) as ubyte => {1,2,3,4} at $C000

'this should return 1
print at 0,0;peek($c000)

do
loop until inkey$<>""



RE: Dim At Issue? (1.15.0-beta4) - boriel - 03-14-2021

(03-09-2021, 08:07 PM)Ljg701 Wrote: Hello Boriel,

The following array initiation code I don't think is initiating the array data at the correct address. In the example below, the peek returns a value of 255 rather than 1, also @test doesn't return a value of $c000  (Version  1.15.0-beta4 + NextBuild)

Code:
'!ORG=24576
'!OPT=4

dim test(0 to 3) as ubyte => {1,2,3,4} at $C000

'this should return 1
print at 0,0;peek($c000)

do
loop until inkey$<>""

This is a bug in the sense that the compiler should report a syntax error.

It's not allowed to initialize an array with DIM AT (i.e. what if you initialize it into a ROM address?).
Allocation at a given memory address is not allowed (unless you declare asm code with ORG, which is NOT recommended).
Declaring things at given locations will be done outside the compiler (with a linker, and config files, and compiling to .obj, etc).

It's an effort that will take time, be patient, since this is required also for pagination, and interruptions.
Implementing things like this would make the compiler very architecture-dependent, and I want to move to a multi-architecture scheme.


RE: Dim At Issue? (1.15.0-beta4) - Ljg701 - 03-14-2021

(03-14-2021, 06:38 PM)boriel Wrote:
(03-09-2021, 08:07 PM)Ljg701 Wrote: Hello Boriel,

The following array initiation code I don't think is initiating the array data at the correct address. In the example below, the peek returns a value of 255 rather than 1, also @test doesn't return a value of $c000  (Version  1.15.0-beta4 + NextBuild)

Code:
'!ORG=24576
'!OPT=4

dim test(0 to 3) as ubyte => {1,2,3,4} at $C000

'this should return 1
print at 0,0;peek($c000)

do
loop until inkey$<>""

This is a bug in the sense that the compiler should report a syntax error.

It's not allowed to initialize an array with DIM AT (i.e. what if you initialize it into a ROM address?).
Allocation at a given memory address is not allowed (unless you declare asm code with ORG, which is NOT recommended).
Declaring things at given locations will be done outside the compiler (with a linker, and config files, and compiling to .obj, etc).

It's an effort that will take time, be patient, since this is required also for pagination, and interruptions.
Implementing things like this would make the compiler very architecture-dependent, and I want to move to a multi-architecture scheme.
Thank you for the response, that makes perfect sense.


RE: Dim At Issue? (1.15.0-beta4) - boriel - 03-18-2021

Try this beta. It will prevent you to do this with a Syntax Error.
http://www.boriel.com/files/zxb/zxbasic-1.15.0-beta11.tar.gz
http://www.boriel.com/files/zxb/zxbasic-1.15.0-beta11.zip
http://www.boriel.com/files/zxb/zxbasic-1.15.0-beta11-win32.zip
http://www.boriel.com/files/zxb/zxbasic-1.15.0-beta11-linux64.tar.gz
http://www.boriel.com/files/zxb/zxbasic-1.15.0-beta11-macos.tar.gz


RE: Dim At Issue? (1.15.0-beta4) - Ljg701 - 04-06-2021

(03-18-2021, 07:26 PM)boriel Wrote: Try this beta. It will prevent you to do this with a Syntax Error.
http://www.boriel.com/files/zxb/zxbasic-1.15.0-beta11.tar.gz
http://www.boriel.com/files/zxb/zxbasic-1.15.0-beta11.zip
http://www.boriel.com/files/zxb/zxbasic-1.15.0-beta11-win32.zip
http://www.boriel.com/files/zxb/zxbasic-1.15.0-beta11-linux64.tar.gz
http://www.boriel.com/files/zxb/zxbasic-1.15.0-beta11-macos.tar.gz
That indeed seems to prevent the scenario.