Jump to content
IGNORED

FastBasic : How do you peek and poke above 32767 with variables?


Recommended Posts

I’m converting an Atari Basic display list dump program to FastBasic. But the display list starts at the edge of the 16bit integer maximum limit. So many of the addresses are overflowing When using variables. I’ve tried using float variables. But peek and dpeek doesn’t accept them. I get a parser error. Is there a way to only use positive integer variables with values 0 to 65535?

Link to comment
Share on other sites

Variables with values higher than 32767 are PRINTed as negative numbers, but they are still OK for a POKE. Address -1 is still 65535, and address -32768 is 32768. You should not get a syntax error for using an address between -32768 and 65535, where the range from -32768 to -1 is the same as the range from 32768 to 65535.

 

  • Thanks 1
Link to comment
Share on other sites

Hi!

On 12/7/2020 at 10:22 PM, gs80065xe said:

Thanks. That’s the behavior I observed. Since it only affects printing then I guess it’s OK. I’ve been spoiled by modern tech. No used to these tight constraints.

FastBasic uses standard two's complement numbers for the integer values, so they can be treated as signed (from -32768 to 32767) or unsigned (from 0 to 65536). This means:

 

- As memory addresses (on PEEK, POKE, etc) they work as unsigned, as standard Atari convention and also as signed, so you can use "PEEK(-11766)" or "A=USR(-7049)"; 

- Addition, subtraction and multiplication works in both cases;

- Division and printing take the sign into account, and can't be used with numbers > 32767;

- Greater-than and less-than comparisons also use the sign, so you need to be very careful with FOR loops, if you need and ending > 32767 you need to use WHILE or REPEAT loops and compare with "=".

 

Have Fun!

 

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...