QDOS+ Basic Memory Areas


QDOS+ Basic Memory Areas


There are 12 distinct areas:
LOW ADDRESS
job header -- Same layout as any other JB area. $68 bytes. SV_BASIC points to the base of this area.
SuperBASIC work area -- Interpreter work variables. fixed length: includes pointers to other areas, which may be moved around. During interpretation, A6 points to the base of this area: the BV values are the offsets: the whole area can be moved (hence A6 is changed to new base address). See below.
name table -- For access to SuperBasic variables and parameters. A table of 8-byte entries: see below.
namelist -- For access to SuperBasic variables and parameters. Each entry is a BYTE character count, then the characters of the name [ALL OTHER STRINGS USE*WORD* -LENGTH COUNTS].
variable values area -- For access to SuperBasic variables and parameters. A heap in which the values of the variables are cstored: see below for the formats of the entries.
channel table -- For SuperBASIC channels. See below.
arithmetic (RI) stack -- Convenient for reserving space in added routines: and for passing parameters from SuperBASIC to routines. See above.
token list -- Not described in TechRefMan
line number table -- Not described in TechRefMan
program file -- Not described in TechRefMan
return list -- Not described in TechRefMan
buffer -- Not described in TechRefMan
HIGH ADDRESS

1 SuperBASIC work area

$00 BC_START Relative to SV_BASIC
*** START OF POINTERS ***
$00.L BV_BFBAS Buffer base
$04.L BV_BFP Buffer running pointer
$08.L BV_TKBAS Token list
$0C.L BV_TKP ?
$10.L BV_PFBAS Program file
$14.L BV_PFP ?
$18.L BV_NBAS Name table
$1C.L BV_NTP ?
$20.L BV_NLBAS Name list
$24.L BV_NLP ?
$28.L BV_VVBAS Variable values
$2C.L BV_VVP ?
$30.L BV_CHBAS Channel name
$34.L BV_CHP ?
$38.L BV_RTBAS Return table
$3C.L BV_RTP ?
$40.L BV_LNBAS Line number table
$44.L BV_LNP ?
*** CHANGE OF DIRECTION ***
$48.L BV_BTP Backtrack stack during parsing
$4C.L BV_BTBAS ?
$50.L BV_TGP Temporary graph stack during parsing
$54.L BV_TGBAS ?
$58.L BV_RIP Arithmetic stack
$5C.L BV_RIBAS ?
$60.L BV_SSP System stack
$64.L BV_SSBAS ?
*** END OF POINTERS ***
$68.W BV_LINUM Current line number
$6A.W BV_LENGTHCurrent length
$6C.B BV_STMNT Current statement on line
$6D.B BV_CONT Continue ($80) or stop (0) processing
$6E.B BV_INLIN Processing in-line clause (loop=1, other=$FF) or not (=0)
$6F.B BV_SING Single line execution ON ($FF) or OFF (0)
$70.W BV_INDEX Name tab row of last inline loop index read
$72.L BV_VVFREE First free space in variable value table
$76.L BV_SSSAV Saved sp for out/mem to back to
$7C.? BV_UPROC MINERVA: Set address of use trace routine [p ASM.5-]
$80.L BV_RAND Random number
$84.L BV_COMCH Command channel
$88.W BV_NXLIN Which line number to start after
$8A.B BV_NXSTM Which statement to start after
$8B.B BV_COMLN Command line saved ($FF) or not (0)
$8C.W BV_STOPN Which stop number set
$8E.B BV_EDIT Program has been edited ($FF) or not (0)
$8F.B BV_BRK There has been a break (0) or not ($80)
$90.B BV_UNRVL Need to unravel ($FF) or not (0)
$91.B BV_CNSTM Statement to CONTINUE from
$92.W BV_CNLND Line to CONTINUE from
$94.W BV_DALNO Current DATA line number
$96.B BV_DASTM Current DATA statement number
$97.B BV_DAITM Next DATA item to read
$98.W BV_CNIND Inline loop index to CONTINUE with
$9A.B BV_CNINL Inline loop flag for CONTINUE
$9B.B BV_LSANY Whether checking list ($FF) or not (0</)</td>
$9C.W BV_LSBEF Invisible top line
$9E.W BV_LSBAS Bottom line in window
$A0.W BV_LSAFT Invisible bottom line
$A2.W BV_LENLN Length of window line
$A4.W BV_MAXLN Max. number of window lines
$A6.W BV_TOTLN Number of window line so far
$AA.B BV_AUTO Whether AUTO/EDIT is on ($FF) or off (0)
$AB.B BV_PRINT Print from prtok ($FF) or leave in buffer (0)
$AC.W BV_EDLIN Line number to edit next
$AE.W BV_EDINC Increment on edit range
$B0 to $100 See p163 of the Tech Ref Man
Basic channel definitions: (1) see later (2) p164 Tech Ref Man

2 NAME TABLE ENTRIES

The entries can be of the following kinds:
bytes 7-4 bytes 3-2 byte 1 byte 0 [1] Kind
value pointer name pointer $00 $01/02/03 Unset typed value
ptr to RI stack -1 $01 $01/02/03 Typed expression [2]
value pointer name pointer $02 $01/02/03 Typed value
value pointer -1 $03 $00 Substring [2]
value pointer name pointer $03 $01/02/03 Typed array
line # in msw name pointer $04 $00 SuperBASIC procedure
line # in msw name pointer $05 $01/02/03 SuperBASIC typed function
value pointer name pointer $06 $02 REPeat loop index
value pointer name pointer $07 $02 FOR loop index
abs address name pointer $08 $00 Machine code procedure
abs address name pointer $09 $00 Machine code function

[1] Byte 0 has bitwise format h sss tttt where
h # before the
parameter
0 no/not param
1 yes

(Only tttt is shown
in the main table)

sss separator after the parameter
0 none/not param
1 comma
2 semi-colon
3 backslash
4 exclamation mark
5 'TO' keyword
tttt type of entry
0 null
1 string
2 f.p.
3 integer

[2] Not normally reccomended for use by added routines.

3 VARIABLE VALUES AREA

A heap in which the values are stored. The item entries are:
integer -- 16-bit two's complement word.
f.p. -- 2-byte exponent, then 4-byte mantissa. Ms 4 bits of exponent are 0, LS 12 bits are offset -$800.
Mantissa is 2's complement with bit 31 -1, bit 30 +1/2, normalized so that bit31 /= bit30 (unless the whole number is exactly zero, in which case all 6 bytes are 0). So value is
* mantissa*2^(exponent-$800)
if the mantissa is taken as fraction or
* mantissa*2^(exponent-$81F)
if the mantissa is taken as .L integer.
string -- 2 byte character count, then that number of characters, then (if the count was odd) an ignored byte to make the whole an even # of bytes
array -- header of format
* .L offset from base of variable values area to the array values
* .W number of dimensions
* .W max index of the dimension **
* .W index multiplier for the dimension **
[** The last pair of items are repeated once for each dimension.]
STRING ARRAY: is an array of characters, except zeroth element of the final dimension is .W containing the string length; Final dimension defines the maximum string length, +1 if odd.
SUBSTRING: result of a slicing: an array of characters, except that the base of indexing is one rather than zero.

4 THE BASIC CHANNEL TABLE

A channel number #n indexes the SuperBASIC channel table. Each entry in the table is of length CH_LENCH ($28) bytes. The base of the table is at BV(CHBAS(A6) and the top at BV_CHP(A6). So the base for entry #n is at ( BV_CHBAS(A6) + CH_LENCH*n ) (A6)

Each entry is of format:
$00.L The channel ID
$04.F Current graphics cursor x
$0A.F Current graphics cursor y
$10.F Turtle angle (degrees)
$16.B Pen status
$20.W Character position on line for PRINT and INPUT
$22.W WIDTH of page
The table has as many entries as the number of the current highest-numbered channel: an un-opened channel either has a number greater than that, OR has a negative channel ID.


Last updated 4th January 1999.

Back to my QL home page
Disclaimer