Interpreter internal variables
by Richard Russell, June 2009
The table below lists the addresses and purposes of a number of memory locations used internally by the BBC BASIC for Windows interpreter. Only very rarely will a BASIC programmer be interested in these values, and only experienced programmers with a good understanding of the inner workings of the interpreter should attempt to use them. It will hardly ever be required to write to these locations, and doing so without a full understanding of the consequences is likely to crash the interpreter or make it unstable.
The addresses shown in the first column are appropriate when accessed directly from BASIC, but they cannot be used from assembler code. In the latter case the locations must be accessed indirectly, for example instead of !408 use [^!408].
Address | Purpose |
---|---|
!108 | Base pointer to linked list of variables etc. starting with A |
!112 | Base pointer to linked list of variables etc. starting with B |
!116 | Base pointer to linked list of variables etc. starting with C |
!120 | Base pointer to linked list of variables etc. starting with D |
!124 | Base pointer to linked list of variables etc. starting with E |
!128 | Base pointer to linked list of variables etc. starting with F |
!132 | Base pointer to linked list of variables etc. starting with G |
!136 | Base pointer to linked list of variables etc. starting with H |
!140 | Base pointer to linked list of variables etc. starting with I |
!144 | Base pointer to linked list of variables etc. starting with J |
!148 | Base pointer to linked list of variables etc. starting with K |
!152 | Base pointer to linked list of variables etc. starting with L |
!156 | Base pointer to linked list of variables etc. starting with M |
!160 | Base pointer to linked list of variables etc. starting with N |
!164 | Base pointer to linked list of variables etc. starting with O |
!168 | Base pointer to linked list of variables etc. starting with P |
!172 | Base pointer to linked list of variables etc. starting with Q |
!176 | Base pointer to linked list of variables etc. starting with R |
!180 | Base pointer to linked list of variables etc. starting with S |
!184 | Base pointer to linked list of variables etc. starting with T |
!188 | Base pointer to linked list of variables etc. starting with U |
!192 | Base pointer to linked list of variables etc. starting with V |
!196 | Base pointer to linked list of variables etc. starting with W |
!200 | Base pointer to linked list of variables etc. starting with X |
!204 | Base pointer to linked list of variables etc. starting with Y |
!208 | Base pointer to linked list of variables etc. starting with Z |
!212 | Base pointer to linked list of variables etc. starting with _ |
!216 | Base pointer to linked list of variables etc. starting with ` |
!220 | Base pointer to linked list of variables etc. starting with a |
!224 | Base pointer to linked list of variables etc. starting with b |
!228 | Base pointer to linked list of variables etc. starting with c |
!232 | Base pointer to linked list of variables etc. starting with d |
!236 | Base pointer to linked list of variables etc. starting with e |
!240 | Base pointer to linked list of variables etc. starting with f |
!244 | Base pointer to linked list of variables etc. starting with g |
!248 | Base pointer to linked list of variables etc. starting with h |
!252 | Base pointer to linked list of variables etc. starting with i |
!256 | Base pointer to linked list of variables etc. starting with j |
!260 | Base pointer to linked list of variables etc. starting with k |
!264 | Base pointer to linked list of variables etc. starting with l |
!268 | Base pointer to linked list of variables etc. starting with m |
!272 | Base pointer to linked list of variables etc. starting with n |
!276 | Base pointer to linked list of variables etc. starting with o |
!280 | Base pointer to linked list of variables etc. starting with p |
!284 | Base pointer to linked list of variables etc. starting with q |
!288 | Base pointer to linked list of variables etc. starting with r |
!292 | Base pointer to linked list of variables etc. starting with s |
!296 | Base pointer to linked list of variables etc. starting with t |
!300 | Base pointer to linked list of variables etc. starting with u |
!304 | Base pointer to linked list of variables etc. starting with v |
!308 | Base pointer to linked list of variables etc. starting with w |
!312 | Base pointer to linked list of variables etc. starting with x |
!316 | Base pointer to linked list of variables etc. starting with y |
!320 | Base pointer to linked list of variables etc. starting with z |
!324 | Base pointer to linked list of functions (FN) |
!328 | Base pointer to linked list of procedures (PROC) |
!332 | Pointer to string accumulator (65536 bytes) |
!336 | Pointer to string input and temporary buffer (256 bytes) |
!340 | Current value of PAGE |
!344 | Current TRACE setting |
!348 | Current value of LOMEM |
!352 | Pointer to start of heap free space (END) |
!356 | Current value of HIMEM |
!360 | Pointer to first installed LIBRARY (if any) |
!364 | Pointer to NUL-terminated error string (REPORT$) |
!368 | Temporary storage for ON ERROR LOCAL |
!372 | Pointer to current ON ERROR statement (if any) |
!376 | Current DATA pointer (if any) |
!380 | Current value of COUNT |
!384 | Pointer to (or within) currently-executing statement |
!388 | Pointer to current ON TIME statement (if any) |
!392 | Pointer to current ON CLOSE statement (if any) |
!396 | Pointer to current ON MOVE statement (if any) |
!400 | Pointer to current ON SYS statement (if any) |
!404 | Pointer to current ON MOUSE statement (if any) |
!408 | Address at which the most recent error was detected (used to find ERL) |
!412 | Current 'random' number, bits 0-31 (RND) |
?416 | Current 'random' number, bit 32 (0 or 1) |
?417 | Current value of WIDTH |
?418 | Current value of ERR |
?419 | Current *FLOAT (bits 0,1) *HEX (bit 2) *LOWERCASE (bit 3) and OPT (bits 4-7) setting |
| |
!420 | Pointer to temporary path/filename buffer (256 bytes) |
!424 | Pointer to *KEY string storage (256 bytes) |
!428 | Pointer to keyboard queue (256 bytes) |
!432 | Pointer to event queue (512 bytes) |
!436 | Pointer to current *KEY string expansion |
!440 | Pointer to user-defined character storage (2048 bytes) |
| |
!536 | *SPOOL/*SPOOLON channel number (not 64-bit editions) |
!540 | *EXEC channel number (not 64-bit editions) |
In 64-bit editions some interpreter internal variables are moved or absent, notably !336 (pointer to temporary buffer), !368 (temporary storage for ON ERROR LOCAL), !424 (pointer to *KEY storage), !432 (pointer to event queue) and !440 (pointer to user-defined characters). These make way for 64-bit pointers ]332 (pointer to string accumulator), ]364 (pointer to error string), ]420 (pointer to path/filename buffer), ]428 (pointer to keyboard queue) and ]436 (pointer to current *KEY expansion).