Certain locations in memory are set aside for specific uses by the system. There are a few routines (used to keep the paging in order), and some locations called system variables (or SYSVARS). You can use PEEK and DPEEK to read them, in order to find out various things about the system, and on some of them you can usefully change with POKE and DPOKE. They are listed here with their uses.
The area occupied by SYSVARS spans the addresses 23296 (5B00h) to 23733 (5CB5h) (inclusive) and a subset of them are used in 48K BASIC – addresses 23552 (5C00h) to 23733 (5CB5h).
Note that in 48K mode, there is a buffer area between 23296 (5B00h) and 23552 (5C00h) which was used for controlling the printer. This was quite a popular location for small machine code programs on the old 48K Spectrum and if any of these routines are tried in NextBASIC, the computer will invariably crash. It's advisable that any 48K BASIC program that uses PEEK, POKE and USR to either be run in 48K BASIC mode (although it can be entered in NextBASIC mode and transferred using the SPECTRUM command) or examined thoroughly and converted so it won't use any of these commands. Alternatively, any machine code routine embedded within it should be moved to a safer area.
The system variables listed below, all have unique names, but do not confuse them with NextBASIC variables. The computer will not recognize the names as referring to system variables, and they are given solely as mnemonics to be human-readable.
The abbreviations in column 1 of the table that follows have the following meanings:
X The variables should not be poked because the system might crash.
N Poking the variable will have no lasting effect
R Routine entry point. Not a variable.
The number in column 1 is the number of bytes in the variable. For two bytes, the first one is the least significant byte; the reverse of what you might expect. So to POKE a value v to a two byte variable at address n, use DPOKE instead, as it does the conversion for you. Otherwise you'll need to enter the following for SYSVAR n value v:
POKE n,v-256*INT (v/256)
POKE n+1,INT (v/256)
and to peek its value, either use DPEEK or the expression:
PEEK n+256*PEEK (n+1)
| Notes | Address | Name | Description | |
|---|---|---|---|---|
| Hex | Dec | |||
| R16 | 5B00 | 23296 | SWAP | Paging subroutine |
| R17 | 5B10 | 23312 | STOO | Paging subroutine. Entered with interrupts already disabled and AF, BC on the stack. |
| R9 | 5B21 | 23329 | YOUNGER | Paging subroutine |
| R16 | 5B2A | 23338 | REGNUOY | Paging subroutine |
| R24 | 5B3A | 23354 | ONERR | Paging subroutine |
| X2 | 5B52 | 23378 | OLDHL | Temporary register store while switching ROMs |
| X2 | 5B54 | 23380 | OLDBC | Temporary register store while switching ROMs |
| X2 | 5B56 | 23382 | OLDAF | Temporary register store while switching ROMs |
| X1 | 5B58 | 23384 | CACHEBNK | 8K Bank ID holding cached program data |
| N1 | 5859 | 23385 | Reserved for system use | |
ZX Spectrum Next User Manual, 3rd Edition (ISBN 978-1-5272-5496-1), written and illustrated by Phoebus R. Dokos. Copyright © 2020-2024 Phoebus Dokos / SpecNext Ltd. Licensed under CC BY-NC-SA 4.0. This is a transcription and can contain errors; check any doubt against the printed page.