BASIC IV ROM Routines
Glossary
Submitted by Steve Fewell
A
A usually refers to the Accumulator. This is an 8-bit register within
the processor, which is written/read via many assembler commands.
argp
The argp is the argument pointer - a pointer to a floating-point variable.
Its location is usually &4A (for low byte) and &4B (for high byte).
Carry Flag
The Carry flag is one of the processor flags, which can contain the
values 0 or 1. It is often used to implement carrying and borrowing
functionality when calculating with numbers larger than 8-bits in length. If it
has a value of 1 then this indicates that a carry has occurred. This tells the
command ADC to include the carry in its calculations. If it has a value of 0
then this indicates that a borrow has occurred. This tells the command SBC to
include the borrow in its calculations. Programs usually reset this flag to 0
before beginning any add calculations, and set it to 1 before beginning any
subtract calculations, as this clears the carry/borrow condition.
Error Vector
The BASIC error vector is located in zero-page locations &16 (low
byte) and &17 (high byte). This vector contains the address of the BASIC
error code which BASIC will execute after an error condition occurs. This vector
will point to the code located after an ON ERROR statement in a program. The
BASIC instructions pointed to by the error vector are executed by the BASIC interpreter
when an error condition occurs.
FWA
The FWA is the Floating-point working area 'A', this is an 8 byte zero-page location
for the temporary storage of one floating-point number. Its location is
&2E for the sign byte, &2F for the Exponent Overflow, &30 for the
number's Exponent and &31 (most significant byte) to &35 (least significant
byte) for the number's Mantissa. Byte 5 of the mantissa (&35) is a rounding
byte, as it doesn't form part of the number when it is copied from the FWA and
stored to a floating-point variable. It allows extra precision during
calculations while the number is in the FWA. There is also a Floating-point working area 'B'.
FWB
The FWB is the Floating-point working area 'B', this is a 7 byte zero-page location
for the temporary storage of one floating-point number. Its location is &3B
for the sign byte, &3C for the number's Exponent and &3D (most significant byte) to &41
(least significant byte) for the number's Mantissa. It does not have an Exponent
Overflow byte (like the FWA). Byte 5 of the mantissa (&41) is a rounding
byte, as it doesn't form part of the number when it is copied from the FWB and
stored to a floating-point variable. It allows extra precision during
calculations while the number is in the FWB.
Heap Pointer
The BASIC Heap Pointer is located in zero page memory at locations &02 (low
byte) and &03 (high byte). It contains the address of the top of the Heap.
The Heap is the work space for the current program. It contains all variables
used by the program. The Heap expands (as more items get allocated to memory)
upwards starting from the top of the program code. When the Heap clashes with
the Stack, there is no memory left, and a "No Room" error is produced.
IWA
The IWA is the Integer working area 'A', this is a 4-byte zero-page location
for the temporary storage of one 32-bit Integer number. Its location is &2A
(least significant byte) to &2D (most significant byte).
N Flag
The N flag is one of the processor flags. It is set if the processor has
just worked on (or calculated) a value that has bit 7 set. In two's compliment
this indicates a negative number.
PTRA
PTRA is BASIC's primary Text Pointer. It is located in a 3-byte zero page
location: &0B and &0C are the PTRA Base, i.e. The address of the first
character in the text string pointed to. And &0A is the PTRA offset (this
points to the current character being processed in the Text string).
This pointer usually points to the current position in the Command/Program line
as the line is processed.
PTRB
PTRB is BASIC's second Text Pointer. It is located in a 3-byte zero page
location: &19 and &1A are the PTRB Base, i.e. The address of the first
character in the text string pointed to. And &1B is the PTRB offset (this
points to the current character being processed in the Text string).
This pointer usually points to the current value/variable being processed.
Reset
To reset a flag, or a bit, usually means giving it a value of 0.
Set
To set a flag, or a bit, usually means giving it a value of 1.
Stack Pointer
The BASIC Stack Pointer is located in zero page memory at locations &04 (low
byte) and &05 (high byte). It contains the address of the top item on the
stack. In numeric calculations, this is usually the next number to process. When
an item is popped from the stack, the Stack Pointer is usually moved up so that
it points to the previous item on the Stack. The BASIC Stack grows downwards in
memory from HIMEM.
SWA
The SWA is the String working area, this location has a maximum of
255-bytes for the storage of one string. Its location is &600 (First
Character), with each subsequent byte representing the subsequent
character, until the end of the String (or to the maximum of &6FF).
The length of the SWA (pointer to the last character) is stored in zero page
location &36. This means that a terminator byte is not needed to signify the
end of the string, as this length byte provides the required information.
VARTOP
VARTOP is a pointer to the next free variable storage location. It is located
in zero page locations &02-&03. When the value of VARTOP exceeds the value pointed
to by the BASIC Stack pointer (&04-&05) then a No Room error occurs as BASIC has run
out of storage space for the program's variables. VARTOP is the same as the Heap Pointer.
X
X usually refers to the X register. This is an 8-bit register within the
processor, which is written/read via many assembler commands. It is often used
as an index.
Y
Y usually refers to the Y register. This is an 8-bit register within the
processor, which is written/read via many assembler commands. It is often used
as an index in address lookups.
Zero Flag
The Zero flag is one of the processor flags. It is set if the processor
has just worked on (or calculated) a value of zero.