Acorn BBC BASIC II Memory Map
Addresses outside the ROM used by Acorn BBC BASIC II at run time — zero-page
workspace, RAM buffers, and memory-mapped I/O. For the ROM code
itself (&8000–&BFFF), see the
disassembly listing.
Access:
R read, W write,
B indexing base — the address is named as
base,X/,Y, so the byte actually touched is
base + index and the literal byte at this address is
never itself accessed.
Zero page
| Address | Name | Access | Description |
|---|---|---|---|
&0000–&0001 |
zp_lomem |
R/W/B | LOMEM: the start of variable storage. Defaults to |
&0002–&0003 |
zp_vartop |
R/W/B | VARTOP: the address just past the last allocated variable — where the next new variable goes. Runs from |
&0004–&0005 |
zp_stack_ptr |
R/W/B | Pointer to the top of BASIC's value stack, which grows
downward from |
&0006–&0007 |
zp_himem |
R/W | HIMEM: the top of memory available to BASIC. The value stack ( |
&0008–&0009 |
zp_erl |
R | ERL: the line number in which the last error occurred, set by the error handler and read by the |
&000A |
zp_text_ptr_off |
R/W | PtrA offset: the offset of the next character within the program line addressed by |
&000B–&000C |
zp_text_ptr |
R/W | PtrA: the primary program/text pointer — the base address of the line currently being interpreted. Combined with |
&000D–&0011 |
zp_rnd_seed |
R/W/B | RND state: the 33-bit linear-feedback shift register behind |
&0012–&0013 |
zp_top |
R/W | TOP: the address just past the end of the tokenised program text (and the default for |
&0014 |
zp_print_bytes |
R/W | Print field width: the @%-derived field width used while formatting a number for |
&0015 |
zp_print_flag |
R/W | Number-base flag for output: 0 selects decimal, negative selects hexadecimal (set by |
&0016–&0017 |
zp_error_vec |
R/W |
|
&0018 |
zp_page |
R | PAGE high byte: the start of the BASIC program as a page number (PAGE = this × 256). Read from OSHWM at startup; the |
&0019–&001A |
zp_text_ptr2 |
R/W | PtrB: the secondary text pointer, used by the expression evaluator and the tokeniser while |
&001B |
zp_text_ptr2_off |
R/W | PtrB offset: the offset of the next character for the secondary text pointer |
&001C–&001D |
zp_data_ptr |
R/W | DATA pointer: the address of the next |
&001E |
zp_count |
R/W | COUNT: the number of characters printed since the last newline (the print column). Used for |
&001F |
zp_listo |
R/W | LISTO flags: the listing-indent options set by |
&0020 |
zp_trace_flag |
R/W | TRACE flag: &00 = tracing off, &FF = on ( |
&0021–&0022 |
zp_trace_max |
R/W | TRACE ceiling: the highest line number that |
&0023 |
zp_width |
R/W | WIDTH: the print line width for the auto-newline ( |
&0024 |
zp_repeat_level |
R/W | REPEAT stack depth: how many |
&0025 |
zp_gosub_level |
R/W | GOSUB stack depth: how many |
&0026 |
zp_for_level |
R/W | FOR stack depth: how many |
&0027 |
zp_var_type |
R/W | Value type of the most recently fetched/evaluated value: 0 = string, positive (&40) = integer, negative = real. Drives the type dispatch throughout the evaluator. |
&0028 |
zp_opt_flag |
R/W | Inline-assembler OPT flags ( |
&0029 |
zp_asm_opcode |
R/W/B | Inline assembler: the opcode byte being built for the instruction currently being assembled, before its operand bytes are appended. |
&002A–&002D |
zp_iwa |
R/W/B | IWA — the 32-bit integer work accumulator. Holds the integer operand/result of the evaluator and the integer arithmetic primitives, and doubles as a pointer to a variable’s value during a fetch. |
&002E–&0035 |
zp_fwa_sign |
R/W | FWA — floating-point work accumulator A (&2E-&35): sign (&2E), overflow/guard (&2F), excess-128 exponent (&30), 32-bit mantissa MSB-first (&31-&34) and a rounding byte (&35). The main register for real arithmetic; see |
&0036 |
zp_strbuf_len |
R/W | Length of the string currently in the string work area at |
&0037–&0038 |
zp_general |
R/W/B | General-purpose work pointer (&37-&3A). Reused widely — the tokeniser/line scanner, the variable-chain walk, the program editor — as a scratch 16-bit pointer. |
&0039–&003A |
zp_fileblk |
R/W | Filing-system control block (&39 onward): the OSFILE / load-save parameter block. Filing is not active during arithmetic, so this overlaps the FP workspace below ( |
&003B–&0042 |
zp_fwb_sign |
R/W | FWB — floating-point work accumulator B (&3B-&42), same layout as |
&003C |
zp_fwb_ovf |
FWB overflow byte (&3C), part of |
|
&0043–&0047 |
zp_fp_temp |
R/W | Floating-point temporary / scratch (&43-&47). Holds spill bytes for the FP routines and serves as the quotient build area for integer |
&0048 |
zp_dp_flag |
R/W | Decimal-point-seen flag, set while parsing a number literal so a second |
&0049 |
zp_dec_exp |
R/W | Decimal exponent accumulated while parsing the |
&004A |
zp_int_exp |
R/W | Integer-part / exponent scratch: holds the integer exponent during number parsing and the integer part of a value in |
&004B–&004C |
zp_fp_ptr |
R/W | Pointer to a packed 5-byte floating-point value (a variable or an FP temporary) for the pack/unpack routines. |
&004D–&004E |
zp_coeff_ptr |
R/W | Pointer to the current coefficient table, used while evaluating the continued-fraction approximations in the trig functions. |
&00FD–&00FE |
zp_error_ptr |
R/W | Pointer to the error block currently being reported (the bytes after a |
&00FF |
zp_escflg |
R/W | ESCFLG — the MOS escape flag. Its top bit is set when Escape is pressed; BASIC polls it between statements, acknowledges it via OSBYTE, and raises the "Escape" error. |
6502 hardware stack
| Address | Name | Access | Description |
|---|---|---|---|
&0100–&01FF |
hw_stack |
R/W/B | The 6502 hardware stack (page 1), used normally for JSR/RTS and register saves. A PROC/FN call copies a snapshot of the live stack onto the BASIC value stack and restores it on return, so call nesting is bounded by free stack space rather than a fixed table. |
&0106 |
frame_local_count |
B | Base for the PROC/FN call frame's |
Resident integers & FP workspace
| Address | Name | Access | Description |
|---|---|---|---|
&0400–&046B |
resint_at |
R/W/B | The resident integer variables, four bytes each: @% here at &0400, then A%-Z% at &0404-&046B. @% sets the |
&046C–&047F |
fp_temp1 |
R/W/B | Four 5-byte packed floating-point temporaries: TEMP1 (&046C), TEMP2 (&0471), TEMP3 (&0476) and TEMP4 (&047B). The maths routines stash intermediate reals here while reusing |
&047F |
var_table_base |
B | The −1 base for the variable chain-head table |
&0480–&04FF |
var_ptr_table |
R/W | The dynamic-variable chain-head table: a two-byte head pointer per initial-character class (A-Z, a-z, |
FOR / REPEAT / GOSUB stacks
| Address | Name | Access | Description |
|---|---|---|---|
&04F1 |
for_var_lo |
B | Current |
&04F2 |
for_var_hi |
B | Current |
&04F3 |
for_type |
B | Current |
&04F4 |
for_step0 |
B | Current |
&04F5 |
for_step1 |
B | Current |
&04F6 |
for_step2 |
B | Current |
&04F7 |
for_step3 |
B | Current |
&04F9 |
for_limit0 |
B | Current |
&04FA |
for_limit1 |
B | Current |
&04FB |
for_limit2 |
B | Current |
&04FC |
for_limit3 |
B | Current |
&04FE |
for_loopback_lo |
B | Current |
&04FF |
for_loopback_hi |
B | Current |
&0500–&0595 |
for_stack |
B | The |
&0501 |
for_set_ptr_hi |
B | Write base |
&0502 |
for_set_type |
B | New-frame write base: control-variable type (offset +2). |
&0503 |
for_set_step0 |
B | New-frame write base: STEP byte 0 (offset +3). |
&0504 |
for_set_step1 |
B | New-frame write base: STEP byte 1 (offset +4). |
&0505 |
for_set_step2 |
B | New-frame write base: STEP byte 2 (offset +5). |
&0506 |
for_set_step3 |
B | New-frame write base: STEP byte 3 (offset +6). |
&0508 |
for_set_limit0 |
B | New-frame write base: loop-limit byte 0 (offset +8). |
&0509 |
for_set_limit1 |
B | New-frame write base: loop-limit byte 1 (offset +9). |
&050A |
for_set_limit2 |
B | New-frame write base: loop-limit byte 2 (offset +A). |
&050B |
for_set_limit3 |
B | New-frame write base: loop-limit byte 3 (offset +B). |
&050D |
for_set_loop_lo |
B | New-frame write base: loop-body text pointer low (offset +D). |
&050E |
for_set_loop_hi |
B | New-frame write base: loop-body text pointer high (offset +E). |
&05A3 |
repeat_loop_lo |
B | The −1 read base for the |
&05A4–&05B7 |
repeat_stack |
B |
|
&05B7 |
repeat_loop_hi |
B | The −1 read base for the |
&05B8–&05CB |
repeat_stack_hi |
B | High bytes of the |
&05CB |
gosub_return_lo |
B | The −1 read base for the |
&05CC–&05E5 |
gosub_stack |
B |
|
&05E5 |
gosub_return_hi |
B | The −1 read base for the |
&05E6–&05FF |
gosub_stack_hi |
B | High bytes of the |
String and line buffers
| Address | Name | Access | Description |
|---|---|---|---|
&05FF |
strbuf_base |
B | The −1 base for the string work area |
&0600–&06FF |
string_work |
R/W/B | The string work area / |
&0700–&07FF |
line_input_buf |
R/W | The line input buffer. The line editor reads a typed line (at the |
