FAQ  •  Register  •  Login

B Integer out of range

<<

oblo

Posts: 58

Joined: Tue Jul 12, 2011 5:23 pm

Post Tue Jul 12, 2011 5:38 pm

B Integer out of range

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
<<

boriel

Site Admin

Posts: 1143

Joined: Wed Nov 01, 2006 6:18 pm

Location: Santa Cruz de Tenerife, Spain

Post Tue Jul 12, 2011 6:08 pm

Re: B Integer out of range

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...
<<

oblo

Posts: 58

Joined: Tue Jul 12, 2011 5:23 pm

Post Tue Jul 12, 2011 6:26 pm

Re: B Integer out of range

Thanks but still the same :( 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 :)

Cheers
<<

boriel

Site Admin

Posts: 1143

Joined: Wed Nov 01, 2006 6:18 pm

Location: Santa Cruz de Tenerife, Spain

Post Tue Jul 12, 2011 6:48 pm

Re: B Integer out of range

oblo wrote:Thanks but still the same :( 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 :)

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: http://www.boriel.com/wiki/en/index.php/ZX_BASIC:Syntax
<<

oblo

Posts: 58

Joined: Tue Jul 12, 2011 5:23 pm

Post Tue Jul 12, 2011 7:28 pm

Re: B Integer out of range

Thanks, at last it works! :D 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!:)
<<

LCD

Posts: 506

Joined: Fri Feb 13, 2009 3:11 pm

Location: Vienna, Austria

Post Wed Jul 13, 2011 8:18 am

Re: B Integer out of range

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.
------------------------------------------------------------
http://lcd-one.da.ru redirector is dead
Visit my http://members.inode.at/838331/index.html home page!
<<

oblo

Posts: 58

Joined: Tue Jul 12, 2011 5:23 pm

Post Wed Jul 13, 2011 7:56 pm

Re: B Integer out of range

Thanks for the advices, LCD. After several weeks, this is what I achieved: http://www.megaupload.com/?d=KIAPM8UU
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" :)

Cheers
<<

boriel

Site Admin

Posts: 1143

Joined: Wed Nov 01, 2006 6:18 pm

Location: Santa Cruz de Tenerife, Spain

Post Wed Jul 13, 2011 8:06 pm

Re: B Integer out of range

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, :P ahem... so more people might want to try it).

You can also upload your program at this thread.
<<

oblo

Posts: 58

Joined: Tue Jul 12, 2011 5:23 pm

Post Wed Jul 13, 2011 8:19 pm

Re: B Integer out of range

Thanks, I'll do it :)

Regards

Return to Help & Support

Who is online

Users browsing this forum: No registered users and 0 guests

Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by Vjacheslav Trushkin for Free Forums/DivisionCore.

phpBB SEO