User Tools

Site Tools


fast_variables

Fast variables

by Richard Russell, June 2020

A 'fast' variable is stored as a token in the range &18 to &1F, followed by two bytes to be interpreted as a 16-bit number (little-endian). This number indexes a 4-byte 'slot' pre-allocated at the start of the heap; some variables use more than one slot. So to find the memory address of a fast variable multiply the 16-bit index by 4 and add it to LOMEM. Some slots are never used and are 'wasted', because their index would include a disallowed byte.

The tokens are:

  • &18 Fast FN/PROC (see below); 2 slots
  • &19 Fast byte variable, e.g. v& or v&(); 1 slot (2 slots for array)
  • &1A Fast 32-bit integer, e.g. v% or v%(); 1 slot (2 slots for array)
  • &1B Fast double, e.g. v# or v#(); 2 slots
  • &1C Fast numeric variant, e.g. v or v(); 3 slots (2 slots for array)
  • &1D Fast structure, e.g. v{} or v{()}; 4 slots (2 slots for array)
  • &1E Fast 64-bit integer, e.g. v or v(); 2 slots
  • &1F Fast string, e.g. v$ or v$(); 2 slots

The format of a fast FN/PROC is slightly different. It consists of the regular token for FN or PROC followed by &18 and the 16-bit index, so 4 bytes in all rather than 3 for the other fast variables.

Everything above applies equally to BBC BASIC for Windows and BBC BASIC for SDL 2.0. The difference is that the BB4W cruncher creates fast variables only when one or more REM!Fast directives are present in the program; the BBCSDL cruncher will use fast variables whenever it can, irrespective of the presence of a REM!Fast.

This website uses cookies. By using the website, you agree with storing cookies on your computer. Also you acknowledge that you have read and understand our Privacy Policy. If you do not agree leave the website.More information about cookies
fast_variables.txt · Last modified: 2024/01/05 00:22 by 127.0.0.1