Forum
B Integer out of range - 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: B Integer out of range (/showthread.php?tid=357)



B Integer out of range - oblo - 07-12-2011

Hi all

First of all, I'd like to introduce myself. I'm new at this forum but I visit it always I have a doubt about the ZX Basic Compiler.

Now, I'm compiling a large basic program (about 37k) and while the execution in Basic is OK, when I compiled it in a .tzx and try to load it in an emulator, at the end of the load the error B Integer out of range, 30:1 is showed.
The info of the CODE block is 32768,37229 and here is the basic code of the loader:
10 CLEAR 32767
20 LOAD""CODE
30 RANDOMIZE USR 32768

Should I suppose that the program is too big?

Thanks and regards


Re: B Integer out of range - boriel - 07-12-2011

Hmmm, could be.
Can you post more information?
Compiler version, compiler flags...
you can also send me by private msg/mail the source code to check it (I won't disclose it, promise) :roll:

You can lower the ramtop, giving more memory to your program, by changing the ORG address:
zxb --org=27000 (I think this should work). You can also reduce the HEAP memory (used for strings)
zxb --heap-size=1024 (leave some heap space for strings). Default heap space is 4Kb, so try:
Code:
zxb --org=27000 --heap-size=1024 ....
This will give you 8Kb of extra space...


Re: B Integer out of range - oblo - 07-12-2011

Thanks but still the same Sad I'm using the last version (1.2.8 ) Now, I'm trying to reduce the code defining uByte variables and arrays but it seems I don't know the syntax because I'm getting the error Syntax Error. Unexpected token 'AS' <AS>. I'm trying to it in several ways do:
Code:
10 LET a=1 AS INTEGER
20 LET b=1 AS INTEGER UBYTE
30 LET c=1 AS UBYTE

Please tell me the correct way to do it. If after it the program still fails, it won't be a problem for me to sent it to you. I'm sure I can learn a thing or two about this Smile

Cheers


Re: B Integer out of range - boriel - 07-12-2011

oblo Wrote:Thanks but still the same Sad I'm using the last version (1.2.8 ) Now, I'm trying to reduce the code defining uByte variables and arrays but it seems I don't know the syntax because I'm getting the error Syntax Error. Unexpected token 'AS' <AS>. I'm trying to it in several ways do:
Code:
10 LET a=1 AS INTEGER
20 LET b=1 AS INTEGER UBYTE
30 LET c=1 AS UBYTE

Please tell me the correct way to do it. If after it the program still fails, it won't be a problem for me to sent it to you. I'm sure I can learn a thing or two about this Smile

Cheers

You have to declare the variables *before* they are used. If you don't the compiler will try to "guess" the most suitable type. To declare a variable use DIM:
Code:
REM Line numbers are not needed

DIM a As Integer
DIM b as Ubyte
DIM c as Ubyte

10 LET a=1
20 LET b=1
30 LET c=1

Read here for more info: <!-- m --><a class="postlink" href="http://www.boriel.com/wiki/en/index.php/ZX_BASIC:Syntax">http://www.boriel.com/wiki/en/index.php/ZX_BASIC:Syntax</a><!-- m -->


Re: B Integer out of range - oblo - 07-12-2011

Thanks, at last it works! Big Grin Declaring vars and arrays as uByte and compiling with the --org and --heap-size did the trick. Now I'm polishing a bit the BASIC code and I hope to release it in a day or two.

Many thanks!Smile


Re: B Integer out of range - LCD - 07-13-2011

I always set the Start address to 24576 or 24200. This still leaves enough room for adding a loading screen. After the game is finished, and I know how much space it needs, I can play around with start point or add more code. I also lower the heap size up to 100 bytes (because I do not use many strings but mostly direct memory access). The final phase is optimisation where I remove redundand code or add procedures to replace repeating code, and use advanced commands of ZXBC, sometimes also reolacing parts of BASIC by Assembly code helps me to recuce the size too. This saves usualy 1-10 Kb
Looking forward to see your work.


Re: B Integer out of range - oblo - 07-13-2011

Thanks for the advices, LCD. After several weeks, this is what I achieved: <!-- m --><a class="postlink" href="http://www.megaupload.com/?d=KIAPM8UU">http://www.megaupload.com/?d=KIAPM8UU</a><!-- m -->
It's a first step but I want to improve and develop more and better games, so the next step is "Spectrum Machine Language for the Absolute Beginner" Smile

Cheers


Re: B Integer out of range - boriel - 07-13-2011

Hey, this is very nice!!
You should upload this game to the worldofspectrum.org archive :roll: (and also put somewhere you use the ZX BASIC compiler, Tongue ahem... so more people might want to try it).

You can also upload your program at this thread.


Re: B Integer out of range - oblo - 07-13-2011

Thanks, I'll do it Smile

Regards