When I was in Seattle at the Sinclair Fest, I discovered people had questions about the memory layout of the QL. In particular, the command RESPR was not understood.
The QL memory map has two aspects, what the hardware allows & what QDOS expects. The hardware aspect is straightforward; the 68008 has 20 address lines which define a space of 1 million locations. These are arranged as shown in Table_0.
The memory map as seen by QDOS is independent of the available ram, in relative terms. There are several major sections. These are as shown in Table_1.
When you first power up, the Resident Procedure area and the Transient Program area are empty. As you extend SuperBasic or run jobs these System Variables are changed accordingly. For example, a common operation in a boot program will be something like;
100 ADDR = RESPR(1024)
110 Lbytes mdv1_EXTCODE,ADDR
120 CALL ADDR
The instruction RESPR(1024) has the effect of lowering SV_RESPR 1024 bytes, if there is memory to spare. This is not unlike the old ZX81 technique of lowering ramtop.
It is easy enough to write a PROCedure which reads the System Variables and tells you how the memory allocations of your QL are changing as you use it. The PROCedure TELL below does this if you don’t want to write your own.
TABLE_0
------------------------------------------------------------
K DEC HEX USE
1024K 1,048,576 00100000 Top of Address Space +1
000FFFFF
960K 983,040 000F0000
896K 917,504 000E0000 16 - 16K Peripheral Cards
832K 851,968 000D0000
768K 786,432 000C0000
-----------------------------
000BFFFF
704K 720,896 000B0000
640K 655,360 000A0000
576K 589,824 00090000
512K 524,288 00080000 512K Expansion Ram
448K 458,752 00070000
384K 393,216 00060000
320K 327,680 00050000
256K 262,144 00040000
-----------------------------
0003FFFF
192K 196,608 00030000
128K On Board Ram
128K 131,072 00020000
----------------------------- I/O Hardware
64K 65,536 00010000
ROM
0K 0 00000000
Table 1
System Variable Function
SV_RAMT ------------------------------------- Top of Ram
Resident Procedures
SV_RESPR ------------------------------------
Transient Programs
SV_TRNSP ------------------------------------
SuperBasic Data
& Programs
SV_BASIC ------------------------------------
Slave Blocks
use this Free
memory
SV_FREE ------------------------------------
Channel Definition Blocks
Device Drivers & Program
use of Common Heap.
SV_HEAP ------------------------------------
System Variables
SV_BASE ------------------------------------ $28000
Default Video Ram
RAM_BASE ------------------------------------ $20000
100 REMark Print Sys_Var & Mem_Alloc
110 :
120 DEFine PROCedure PRT_STATS
130 VR_BASE=131072
140 SV_BASE=163840
150 SV_END =164992
160 SV_CHEAP=SV_BASE+4
170 SV_FREE =SV_BASE+12
180 SV_BASIC=SV_BASE+16
190 SV_TRNSP=SV_BASE+20
200 SV_RESPR=SV_BASE+28
210 SV_RAMTP=SV_BASE+32
220 a=PEEK_L(SV_CHEAP)
230 c=PEEK_L(SV_FREE)
240 d=PEEK_L(SV_BASIC)
250 e=PEEK_L(SV_TRNSP)
260 f=PEEK_L(SV_RESPR)
270 g=PEEK_L(SV_RAMTP)
280 PRINT 'System Variables'
290 PRINT 'SV_RAMTP =';g
300 PRINT 'SV_RESPR =';f
310 PRINT 'SV_TRNSP =';e
320 PRINT 'SV_BASIC =';d
330 PRINT 'SU_FREE =';c
340 PRINT 'SV_CHEAP =';a
350 PRINT 'SV_BASE =';SV_BASE
360 PRINT 'VR_BASE =';VR_BASE
370 END DEFine PRT_STATS
380 :
390 DEFine PROCedure TELL
400 PRT_STATS
410 PRINT\'MAJOR SYSTEM MEMORY ALLOCATIONS'
420 PRINT ' TOTAL RAM AVAILABLE: ';g-VR_BASE
430 PRINT 'RESIDENT PROCEDURE AREA: ';g-f
440 PRINT ' TRANSIENT PROGRAM AREA: ';f-e
450 PRINT ' SUPERBASIC AREA: ';e-d
460 PRINT ' FREE MEMORY AREA: ';d-c
470 PRINT ' COMMON HEAP AREA: ';c-SV_END
480 PRINT ' SYSTEM VARIABLES: ';SV_END-SV_BASE
490 PRINT ' VIDEO RAM: ';SV_BASE-VR_BASE
500 END DEFine TELL
510 :