RAM Addresses and Routines
Page Customization
Note:
This page needs some love. There are duplicate lines which may say the same thing. Anyone who is willing to help clean up any part of this page, please speak up! Thanks!
The following keys for DOSes apply:
| T1 - Model 1 TRSDOS | T3 - Model 3 TRSDOS |
| N1 - Model 1 NEWDOS | N3 - Model 3 NEWDOS |
| L1 - Model 1 LDOS | L3 - Model 3 LDOS |
| M1 - Model 1 MULTIDOS | M3 - Model 3 MULTIDOS |
| D1 - Model 1 DOSPLUS | D3 - Model 3 DOSPLUS |
| All - All DOSes, Model I and Model 3. | |
RAM Addresses and Routines:
| Address (Hex/Dec/Label) | Model Code | Description |
|---|---|---|
| 3000H-37DDH ↳12288-14301 | Model 1 | Reserved. Unused in Model I. |
| 3000H ↳12288 | 3 | Write 500 baud cassette leader and sync byte. |
| 3003H ↳12291 | 3 | Write 1500 baud cassette leader and sync byte. |
| 3006H ↳12294 | 3 | Search for 500 baud cassette leader and sync byte. |
| 3009H ↳12297 | 3 | Search for 1500 baud cassette leader and sync byte. |
| 300CH ↳12300 | 3 | Turn off cassette. |
| 300FH ↳12303 | 3 | Turn on cassette. |
| 3012H ↳12306 | 3 | Disk bootstrap routine. |
| 3015H ↳12309 | 3 | Power-up routine (jump here from 0002H). |
| 3018H ↳12312 | 3 | Maskable interrupt handler. |
| 301BH ↳12315 | 3 | RS-232-C initialization driver routine. |
| 301EH ↳12318 | 3 | RS-232-C input driver routine. |
| 3021H ↳12321 | 3 | RS-232-C output driver routine. |
| 3024H ↳12324 | 3 | Keyboard driver routine. |
| 3027H ↳12327 | 3 | I/O Route driver routine (not available on Model 4). |
| 3029H ↳12329 | 3/4 | To determine if a computer is a Model 3 or Model 4, peek this location.
|
| 302AH ↳12330 | 3 | Part of routine to search for cassette leader and sync byte (jumps here from 0229H). |
| 302DH ↳12333 | 3 | Part of LIST command (jumps here from 2B91H). |
| 3030H ↳12336 | 3 | BASIC TIME$ function routine. |
| 3033H ↳12339 | 3 | $DATE routine (date to 8-character buffer pointed to by HL). |
| 3036H ↳12342 | 3 | $TIME routine (time to 8-character buffer pointed to by HL). |
| 3039H ↳12345 | 3 | Non-maskable interrupt handler. |
| 3042H ↳12354 | 3 | $SETCAS routine (prompt user to set cassette baud rate) |
| 37DEH ↳14302 | Model 1 | Communication Status Address |
| 37DFH ↳14303 | Model 1 | Communication Data Address |
| 37E0H ↳14304 | Model 1 | Interrupt Latch Address |
| 37E1H ↳14305 ↳DSEL$ | Model 1 | Disk Drive Select Latch Address.
|
| 37E4H ↳14308 | Model 1 | Cassette Select Latch Address
|
| 37E8H ↳14312 ↳PRTAD$ | 1/3 | $PRSTAT: Printer Status Byte a/k/a Line Printer Address. If a parallel line printer is in use, it is mapped to this address. Writing a byte to this address sends it to the printer, while reading this address determines printer status as follows:
|
| 37E9H ↳14313 | 1/3 | $PROUT: Output a Byte to the Printer. |
| 37EAH ↳14314 | Model 1 | Contains the byte from 37E8H (PRTAD) |
| 37EBH ↳14315 | Model 1 | Contains the byte from 37E8H (PRTAD) |
| 37ECH ↳14316 ↳FDCAD$ | Model 1 | Floppy Disk Controller COMMAND/STATUS. This location is tested during the power-up sequence to determine if a floppy disk controller is online, and if so, the TRS-80 will jump to the disk bootstrap routine (unless the BREAK key is held).
|
| 37EDH ↳14317 | Model 1 | DISK TRACK SELECT |
| 37EEH ↳14318 ↳FDCAD$+2 | Model 1 | DISK SECTOR SELECT |
| 37EFH ↳14319 ↳FDCAD$+3 | Model 1 | Byte read from disk (DISK DATA) |
| 3800H-3840H ↳14336-14400 ↳KEYAD$ | 1/3 | Keyboard Memory / Address Matrix |
| 3B80H ↳15232 | 1/3 | Keyboard Memory / Address Matrix for SHIFT Keys |
| 3C00H-3FFFH ↳15360-16383 ↳DSPAD$ | 1/3 | $VIDRAM: The beginning of video ram or VIDRAM. It ends at 3FFFH or 16383. |
| 3FFFH ↳16383 | 3 | END OF VIDEO MEMORY |
| 4000H ↳16384 ↳RST1$ | 1/3 | RST 08 (Syntax Check): Compare value pointed to by HL to that immediately following RST instruction. |
| 4000H ↳16384 | Model 1 | Start of Level II BASIC Fixed RAM. |
| 4003H-4005H ↳16387-16389 | TD | RST 10H (Get Next Character): Jump Vector. |
| 4003H ↳16387 | RST 10 Examine next symbol pointed to by HL. | |
| 4003H | Model 1 | The next 3 bytes are used to hold the length and address of a string when it is moved to the string area. |
| 4006H | Model 1 | RST 18 vector |
| 4006H ↳16390 | RST 18H (Cp HL, DE) Jump Vector. | |
| 4006H ↳16390 | RST 18 Compare DE and HL. | |
| 4009H ↳16393 | RST 20 Test the type of current variable. | |
| 4009H | Model 1 | RST 20 vector |
| 4009H ↳16393 | RST 20H (Get Current Type) Jump Vector. | |
| 400CH-400EH ↳16396-16398 ↳RST5$ | 1/3 | RST 28H (Break Key Vector). By default, it contains C9 00 00 (201 00 00) which is RET in NON-DOS BASIC. Any 3 byte instruction code put here will execute on hitting the BREAK key. On a Model I, to disable the BREAK key, Radio Shack recommends filling 16396 with 23 (17H) which is RLA (which just messes with Register A), and with 201 (C9H) RET to re-enable it. On a Model 3, to disable the BREAK key, Radio Shack recommends filling the area with AF C9 00 (175 and 201) which is XOR A / RET. Other methods include filling the area with C3 9A 0A (195 154 10) which is JP 0A9AH. |
| 400CH ↳RST5$ | Model 1 | RST 28 DOS request processing |
| 400CH ↳16396 | RST 28 3 byte BREAK key vector (cass. BASIC & TRSDOS1.3) and normal DOS function call. | |
| 400FH ↳16399 | RST 30 Reserved for DOS; normally for invoking Debug | |
| 400FH ↳RST6$ | Model 1 | Load debug (ld a,xx/RST 28) |
| 400FH ↳16399 ↳RST6$ | Model 3 | RST 30H Jump Vector. |
| 4012H-4014H ↳16402-16404 ↳RST7$ or INTERP | 1/3 | RST 38H Jump Vector. |
| 4012H ↳RST7$ or INTERP | Model 1 | RST 38 interrupt service call |
| 4012H ↳16402 | RST 38 Maskable interrupt vector. |
4015H-401CH - Keyboard Device Control Block
| Address (Hex/Dec/Label) | Model Code | Description |
|---|---|---|
| 4015H ↳16405 ↳KDCB$ | Model 1/3 | Beginning of Keyboard DCB. One byte device type.
|
| 4016H ↳16406 | Model 3 | Two byte keyboard driver vector. Model 3 it's 3024H, which JUMPs to 338EH which then processes the keyboard) |
| 4016H-4017H ↳16406-16407 | Model I | Keyboard Device Control Block. Two byte keyboard driver vector. To Disable The Model I Keyboard: N1=PEEK(16406) To Enable The Model I Keyboard:N2=PEEK(16407) POKE 16406,154 POKE 16407, 10 POKE 16406,N1 POKE 16407,N2 |
| 4015H ↳16405 ↳KDCB$ | Model I | Keyboard DCB+0: This address holds the DCB Type |
| 4016H ↳16406 | Model I | Keyboard DCB+1: This address holds byte 1 of the 2 byte Driver Address |
| 4016H ↳16406 | Two byte keyboard driver vector. | |
| 4017H ↳16407 | Model I | Keyboard DCB+2: This address holds byte 2 of the 2 byte Driver Address |
| 4018H ↳16408 | Model I | Keyboard DCB+3: This address holds
|
| 4018H ↳16408 | 1/3 | Keyboard DCB: Right Shift Toggle |
| 4019H ↳16409 | Model I | Keyboard DCB+4: This address holds
|
| 4019H ↳16409 | Caps lock switch
| |
| 4019H ↳16409 | Model 3 | Caps Lock Toggle
|
| 401AH ↳16410 | Model I | Keyboard DCB+5: This address holds
|
| 401AH ↳16410 | Model 3 | Cursor Blink Count. |
| 401BH ↳16411 | Model I | Keyboard DCB+6: This address holds K |
| 401BH ↳16411 | Model 3 | Cursor Blink Status.
|
| 401CH ↳16412 | Model I | Keyboard DCB+7: This address holds I |
| 401CH ↳16412 | 1/3 | Cursor Blink Switch.
|
401DH-4024H - Video Display Control Block
| Address (Hex/Dec/Label) | Model Code | Description |
|---|---|---|
| 401DH-4024H ↳16413-16420 ↳DDCB$ | 1/3 | Beginning of Video Display Control Block (DCB). DCB is Number 7. Classification is both Input and Output. |
| 401DH ↳16413 | Beginning of Video DCB. One byte device type.
| |
| 401EH-401FH ↳16414-16415 ↳IX+1, IX+2 | 1/3 | Two byte video driver address in LSB / MSB order |
| 401EH ↳16414 | Two byte video driver vector. | |
| 4020H-4021H ↳16416-16417 ↳CURSOR, IX+3, IX+4 | 1/3 | Cursor Position On Screen. 2 Bytes in LSB/MSB Order. |
| 4020H ↳16416 | Two byte cursor position. | |
| 4022H ↳16418 ↳IX+5 | Model 1 | Cursor Character:
|
| 4022H ↳16418 | Model 3 | Cursor On/Off Flag:
|
| 4023H ↳16419 | 1/3 | Cursor Character (in ASCII). Defaults to 176. Must be between 32 and 255. |
| 4024H ↳16420 | FLAG:
| |
| 4024H ↳16420 | 3 | Character Set To Use
|
| 4024H ↳16420 | Model 3 | Tape RAM - Video DCB: Tabs/Special Characters Switch
|
4025H-402CH - Printer Control Block
| Address (Hex/Dec/Label) | Model Code | Description |
|---|---|---|
| 4025H ↳16421 ↳PDCB$, IX+0 | 1/3 | Beginning of Printer DCB. This location, IX+0, is the DCB Type which is set for 6. Classification = Write Only |
| 4026H-4027H ↳16422-16423 ↳IX+1, IX+2 | 1/3 | Two byte Print Driver Address (stored in LSB/MSB Order). |
| 4028H ↳16424 ↳IX+3 | 1/3 | Printer: Maximum Number of Lines which can be Printed per Page plus 1. The default is 67.
|
| 4029H ↳16425 ↳IX+4 | 1/3 | Printer: Number of lines already printed +1. To reset the counter POKE 16425,1 |
| 402AH ↳16426 | Model 1 | Model 1: Not Used |
| 402AH ↳16426 | Model 3 | Number of characters printed already + 1 |
| 402BH ↳16427 | Model 3 | Line printer maximum characters (width) per line less 2. Set at 255 for no maximum. |
| 402CH ↳16428 | R | |
| 402DH ↳16429 ↳SYS1IN | EXIT: Normal program exit back to DOS. (Disk systems only). | |
| 402DH ↳16429 ↳SYS1IN | Model 3 | Tape RAM - Printer DCB: JP 5000H Unused DOS Vector |
| 4030H ↳16432 ↳ABORT | Model 1 | DOS request code for SYS1 |
| 4030H ↳16432 ↳ABORT | For all DOSes except TRSDOS, jumping here is for an abnormal return to DOS ready, such as after an unsuccessful program exit. | |
| 4030H ↳16432 | Model 3 | Tape RAM - Printer DCB: RST 0 |
| 4032H ↳16434 | Model 1 | Write 'DOS ready' message |
| 4033H ↳16435 ↳CIO$ | Model 1 | Call device driver ala DOS |
| 4033H ↳16435 | Model 3 | Tape RAM - Printer DCB: XOR A and RET |
| 4036H-403CH ↳16438-16444 ↳KYBT$ | 1/3 | Keyboard Bit Image (7 Byte Buffer). This is the work area for keyboard input routine. The contents of the keyboard rows are stored here so that when the keyboard routine is called, it can determine whether the key has just been depressed (or is still being held down).
|
| 4036H ↳16438 | Keyboard buffer (7 bytes). | |
| 403DH ↳16445 | Level 2 | Cassette port and print size flag (bit 3) copy (For Model 3, see 4210H).
|
| 403DH ↳16445 ↳CAST$ | M1 DOS / Model 3 | Tape RAM - Interrupt Vector 3 - JP 35FAH. This MAY be the routine to add a task to the interrupt chain. |
| 403DH ↳16445 ↳CAST$ | M3 DOS | Used primarily by the Disk Operating System, vectors at 403DH, 4040H, and 4043H service interrupt vectors 3, 6, and 7 respectively (under non-disk systems all contain a jump to 35FAH, which in turn contains a "RET" instruction). 4046H is an interrupt vector servicing the clock (interrupt vector 2) and contains a jump to 35A9H in a non-disk system. 4049H is the Non-Maskable Interrupt vector and normally contains a RST 0 instruction. The remainder of this area is unused in non-disk systems. |
| 403DH ↳16445 | Cassette port and print size flag (bit 3) copy (For Model 3, see 4210H). L3: location of routine to add task to interrupt chain. | |
| 403EH-407FH ↳16446-16511 ↳CURDOS | M1 | Unused in non-Disk systems. Real time clock storage locations are kept here. For the Model 3 this would be 4216H-421CH. |
| 403EH ↳16446 ↳CURDOS | Model 1 | Used by DOS |
| 403EH ↳16446 ↳CURDOS | D1 | OSVER$: Holds the DOS Version Number. Stored in DCB format. Note: on a M3 this is stored in 441FH and on the M4 in 0085H |
| 403EH ↳16446 | For Model I DOSPLUS, holds DOS version in DCB format. | |
| 403FH ↳16447 | Model 1 | Used by DOS |
| 4040H ↳16448 | Model 1 | System bits |
| 4040H ↳16448 | Model I | 25 ms heartbeat counter. |
| 4040H ↳16448 | Model 3 | Interrupt Vector 6 - JP 35FAH. Vector 6 may be "remove task from interrupt chain". |
| 4040H ↳16448 | For L1 & M1 | 25 ms heartbeat counter. For L3, used to remove task from interrupt chain. |
| 4041H-4043H ↳16449-16451 ↳XTIME | L1, D1, and M1 | TIME$, time of day: Seconds, Minutes, Hours |
| 4041H ↳16449 ↳XTIME | Model 1 | Seconds |
| 4041H ↳16449 | Beginning of Time and Date bytes: seconds, minutes, hours, year, day, month. Ends at 4046H or 16454. L1, D1, and M1 | |
| 4042H ↳16450 | Model 1 | Minutes |
| 4043H ↳16451 | Model 1 | Hours |
| 4043H ↳16451 | Model 3 | Tape RAM - Interrupt Vector 7 - JP 35FAH |
| 4043H ↳16451 | L3 | Change address of interrupt task. |
| 4044H-4046H ↳16452-16454 | L1, D1, and M1 | DATE$, date: Year, Day, Month. Stored in BCD. |
| 4044H ↳16452 | Model 1 | Year |
| 4044H ↳16452 | L1, D1, & M1 | Contains date in binary format. |
| 4045H ↳16453 | Model 1 | Day |
| 4046H ↳16454 | Model 1 | Month |
| 4046H ↳16454 | L3 | Remove task from interrupt chain. |
| 4046H ↳16454 | Model 3 | Tape RAM - Interrupt Vector 2 - JP 35A9H |
| 4047H ↳16455 | Model 1 | Load address for system utilities 2 bytes, initialized to 5200 by sys0/sys |
| 4047H ↳16455 | L1 | Current day in coded form. |
| 4048H ↳16456 | Model 1 | Current interrupt status word |
| 4049H-404AH ↳16457-16458 ↳MEMEND | Model 1 | DOS MEMORY SIZE. Highest available memory location (On a Model 3 it is stored at 4411H) |
| 4049H ↳16457 ↳MEMEND | Model 3 | Tape RAM - RST 0 NMI Vector (Reset If So) |
| 4049H ↳16457 | For the Model 3 disk is non-maskable interrupt vector, for Model I disk is highest available memory location (Model 3 = 4411H) | |
| 404BH ↳16459 | L1 | Contains image of interrupt latch. |
| 404CH ↳16460 | Model 1 | Interrupt subroutine mask |
| 404DH-404EH ↳16461-16462 | T1 | Address of interrupt service routine for interrupt bit 0 |
| 404DH ↳16461 | Model 1 | Reserved (interrupt bit 0) |
| 404FH-4050H ↳16463-16464 | T1 | Address of interrupt service routine for interrupt bit 1 |
| 404FH ↳16463 | Model 1 | Reserved (interrupt bit 1) |
| 4050H-4051H ↳16464-16465 | Model I | FDC Interrupt Vector |
| 4050H ↳16464 | Model 1 | Stack during IPL |
| 4051H-4052H ↳16465-16466 | T1 | Address of interrupt service routine for interrupt bit 2 |
| 4051H ↳16465 | Model 1 | Communications interrupt subroutine |
| 4052H-4053H ↳16466-16467 | Model I | Communications Interrupt Vector |
| 4053H-4054H ↳16467-16468 | T1 | Address of interrupt service routine for interrupt bit 3 |
| 4055H-4056H ↳16469-16470 | T1 | Address of interrupt service routine for interrupt bit 4 |
| 4057H-4058H ↳16471-16472 | T1 | Address of interrupt service routine for interrupt bit 5 |
| 4058H ↳16472 | Model 1 | Address of clock interrupt routine |
| 4059H-405AH ↳16473-16474 | T1 | Address of interrupt service routine for interrupt bit 6 (which is the DISK interrupt routine) |
| 405BH-405CH ↳16475-16476 | T1 | Address of interrupt service routine for interrupt bit 7 |
| 405EH ↳16478 | Model I | 25 MSec Heartbeat Interrupt |
| 4070H ↳16496 | Model 1 | Start of stack during ROM IPL |
| 407DH ↳16509 ↳TSTK$ | DOS | Stack pointer for DOS, set by the ROM bootstrap routine |
| 407EH ↳16510 | Model 1 | Reserved |
| 407FH ↳16511 | Model 1 | Reserved |
| 4080H ↳16512 ↳FDIVC or RAMLOW | Model 1 | Subtraction routine used by division code. Code is moved from 18F7H - 1904H during non-disk IPL or by BASIC UTILITY FOR DISK SYSTEMS |
| 4081H ↳16513 ↳FDIVC+1 | Model 1/3 | Used in the single precision division routine (stores the LSB). On power up, this routine is moved from 18F7H-1904H to here. |
| 4084H ↳16516 ↳FDIVB | Model 1/3 | Used in the single precision division routine. |
| 4085H ↳16517 ↳FDIVB+1 | Model 1/3 | Used in the single precision division routine (stores the NMSB). |
| 4088H ↳16520 ↳FDIVA | Model 1/3 | Used in the single precision division routine. |
| 4089H ↳16521 ↳FDIVA+1 | Model 1/3 | Used in the single precision division routine (stores the MSB). |
| 408BH ↳16523 ↳FDIVG | Model 1/3 | Used in the single precision division routine |
| 408CH ↳16524 ↳FDIVG+1 | Model 1/3 | Used in the single precision division routine (stores the High Order). |
USR and Random Number Routines
| Address (Hex/Dec/Label) | Model Code | Description |
|---|---|---|
| 408EH-408FH ↳16526-16527 ↳USRTAB | I/III Tape RAM | Entry point to the USR subroutine. If you poke the starting addresses correctly, then X=USR(0) will run that routine. 16526 gets the LSB and 16527 gets the MSB. |
| 408EH ↳16526 ↳MAXFIL | T1 | TRSDOS 2.3 stores the answer to the FILES? Question |
| 408FH ↳16527 ↳VARREC | T1 | TRSDOS 2.3 Flag for whether Variable Files were permitted on Entry into BASIC |
| 4090H ↳16528 ↳MULTR | I/III | Random number seed |
| 4093H-4098H ↳16531-16536 ↳STAINP | Model 1/3 | Input and output port routines |
| 4096H ↳16534 ↳OUTWRD | Model 1/3 | Tape RAM - Tape RAM: Out Support |
| 4099H ↳16537 ↳CHARC | Model 1/3 | INKEY$ storage. This holds the most recently typed keyboard character, stored in ASCII. |
| 409AH ↳16538 ↳ERRFLG | Model 1/3 | Current Error Code is stored at this address (for BASIC only). It would be returned by the ERR function. |
| 409BH ↳16539 ↳LPTPOS | Level 2 / Model 3 | Number of characters already printed in the current line. This would also make it the printer carriage position. It may be used to simulate a TAB function that works correctly past the 63 or 127 character limit of the BASIC TAB function, as TAB cannot be greater than 63 for an old Model I or 127 for a new Model I or any Model 3. |
| 409CH ↳16540 ↳PRTFLG, OUTSEL | Model 1/3 | This is the device output flag.
|
| 409DH ↳16541 ↳LINLEN | Level 2 | Maximum number of characters on video display line. Used by PRINT command routine when printing numeric variables or constants so that a number does not overflow the end of a video display line. This location is set to 64 at power-up and is not changed by the BASIC interpreter once set. However, a POKE to this location may be used to prevent the PRINTing of numerics beyond a certain point on a line. Also, if you are operating in 32-character display mode it may be necessary to POKE 16541, 32 to prevent numeric printouts from overflowing the end of the line. The setting of this location does not affect the printout of strings (variables or constants). |
| 409EH ↳16542 ↳CLMLST | Model 1 | Size of print line |
| 409EH ↳16542 ↳CLMLST | Model 3 | The value in this location specifies the maximum number of 16-character print zones on a line (used when items in a PRINT statement are separated by commas). Value stored here is decoded as follows:
|
| 409FH ↳16543 | Model 1 | Reserved |
| 409FH ↳16543 | Model 3 | Tape RAM - Data flag. Will indicate if the parser is in a QUOTED STRING (Bit 0 high), REM (Bit 2 high), or DATA (Bit 1 high). |
BASIC Memory Management
| Address (Hex/Dec/Label) | Model Code | Description |
|---|---|---|
| 40A0H-40A1H ↳16544-16545 ↳STKTOP | Model 1/3 | String Storage Area: 2 Bytes point to the lowest address available for string storage. This is ALSO the top of free memory. Start of string storage area, set to 50 less than top of memory pointer (at 40B1H) at power-up to provide 50 bytes of string storage area. Changed by use of CLEAR n command (with argument). |
| 40A2H-40A3H ↳16546-16547 ↳CURLIN | Model 1/3 | Holds the Last executed (or current) line number in a BASIC Program in 2 Bytes (LSB/MSB) or FFFFH if in direct mode. |
| 40A4H-40A5H ↳16548-16549 ↳TXTTAB | Model 1/3 | Points to the beginning of the BASIC program in RAM, stored in 2 bytes (LSB/MSB). It is the start of the BASIC program in RAM (referred to sometimes as the PST). Normal values for: (L2)=42E9; (Disk BASIC)=varies with version of DOS/BASIC. TO APPEND: POKE 16548,PEEK(16633)-2 : POKE 16549,PEEK(16634) .CLOAD POKE 16548,233 : POKE 16549,66 What this does is trick the NEW command, which is called as part of CLOAD, into clearing everything AFTER your current program and then restoring where the beginning of the program is afterwards). This is NOT a MERGE, it will APPEND, and leave line numbers out of order. |
| 40A6H ↳16550 ↳TTYPOS | Model 1/3 | Holds the current cursor position (column number) on the video display line (as returned by the POS function). |
| 40A7H-40A8H ↳16551-16552 ↳BUFPNT | Model 1/3 | Input Buffer Pointer (in BASIC). The address of the BASIC keyboard buffer. Note: Also used by BASIC while encoding and decoding BASIC lines (as during LIST, etc.) |
| 40A9H ↳16553 ↳CASFLG | Model 1/3 | Used by INPUT command routine, contains zero byte if (and only if) input is from cassette. A bug in the first release of the Model I Level II BASIC ROM required that this location be POKEd with a non-zero value prior to reading program DIM statements. This bug was corrected soon after Level II BASIC was released, so that this POKE is required only for older TRS-80 Model I machines. |
| 40AAH-40ACH ↳16554-16556 ↳RNDX | Model 1/3 | Seed Number 1 for Random Number |
| 40ABH ↳16555 ↳RNDX+1 | Model 1/3 | Value from refresh register. When a RANDOM is executed in BASIC, this is the byte that gets changed (it is loaded with current value of Refresh register whenever RANDOM statement is executed). |
| 40ACH ↳16556 ↳RNDX+2 | Model 1 | Last random number (2 bytes) |
| 40ADH ↳16557 | Model 1/3 | Unused in non-disk systems. |
| 40AEH ↳16558 ↳DIMFLG | Model 1 | Flag:
|
| 40AEH ↳16558 ↳DIMFLG | Model 1/3 | This flag is used by the BASIC locate or create variable routine. If location contains zero, variable is to be created or located (if already created). If byte is not zero, variable is to be created only and an error exists if the variable is found to be already created. The latter situation exists when an array is being created using the DIM statement. |
| 40AFH ↳16559 ↳VALTYP, SAFLAG | Model 1/3 | Contains the variable type flag for the number sitting in the software accumulator (also known as the Work-Register-Area-1).
|
| 40B0H ↳16560 ↳DORES | Model 1 | Holds intermediate value during expression evaluation |
| 40B0H ↳16560 ↳DORES | Model 1/3 | Used to flag DIM statements while encoding BASIC lines, and to store operator number during expression evaluation. |
| 40B1H-40B2H ↳16561-16562 ↳MEMSIZ, MEMTOP | Model 1/3 | Top of memory pointer. Last usable location for BASIC. This pointer is set by one of the following: If the user answers Memory Size? question with a value, it will be used. However, if only ENTER is pressed in response to Memory Size?, then on a non-disk system the highest available memory location will be used, but under Disk BASIC the DOS top of memory pointer will be copied into this location. If one is programming in BASIC and attempting to change this pointer by POKEing in new values, a CLEAR n statement (with a mandatory numeric argument) should be used immediately following the POKEs, in order to adjust other system pointers to the new memory size. Also, temporarily changing this pointer will allow a short BASIC program to CLEAR more than 32767 bytes of string space on a 48K system, provided that enough free memory is available (BASIC normally does not permit this). |
| 40B1H ↳16561 | Two byte MEMTOP (for BASIC). | |
| 40B3H-40B4H ↳16563-16564 ↳TEMPPT | Level 2 | Pointer to the next available location for storage of a three-byte string variable VARPTR in the string VARPTR storage area that begins at 40B5H. |
| 40B5H-40D2H ↳16565-16597 ↳TEMPST | Level 2 | String variable VARPTR storage area. Holds three-byte string descriptors (first byte contains length, second and third bytes contain address of string) for strings currently being used in BASIC string operations (such as "temporary" strings). |
| 40D3H-40D5H ↳16595-16597 ↳DSCTMP | VARPTR storage area for string currently being created by BASIC. (first byte contains length, second and third bytes contain address of string). | |
| 40D3H ↳16595 | Saves length ASCII representation of binary integer. | |
| 40D4H ↳16596 | Two byte address. Points to buffer where ASCII decimal representation written. | |
| 40D6H-40D7H ↳16598-16599 ↳FRETOP | Model 1/3 | Pointer to next free byte in string storage area. Strings build downward from the top of memory, therefore at power-up (or when a CLEAR command is executed) this pointer will contain the same address as the top of memory pointer (40B1H-40B2H). If a ten byte long string is then created, this pointer will point to the top of memory minus ten, and so on. When there is not enough room left to insert a new string (the difference between this pointer and the one at 40A0H-40A1H is less than the length of a string to be stored), a "garbage collection" is performed, and if that does not free enough string space an Out of String Space error occurs. Under some circumstances, we may be able to manipulate this pointer in order to forestall a "garbage collection" (which may appear to "lock up" the computer for as much as several MINUTES). For example, if we are performing some operation that will create many "temporary" strings (but none that we want to save after a certain point), we could PEEK at the values in these pointer locations and store them in numeric variables. At the completion of our string operation, we could then re-POKE the original pointer values, thus abandoning the unneeded strings without performing a "garbage collection". Under certain circumstances this technique could cut program execution time considerably. |
| 40D6H ↳16598 | String pointer. Keeps track within CLEARed area as to where last string data was put. | |
| 40D8H-40D9H ↳16600-16601 ↳TEMP3 | Level 2 | This pair (two byte) of locations is used as temporary storage location by more than one routine. Uses include program pointer during expression evaluation, pointer to data while processing DIM statement, pointer to end of array while packing strings, and within the PRINT USING routine the byte at 40D8H is used to temporarily store the PRINT USING format flag bits. |
| 40D8H ↳16600 ↳TEMP3 | Model 1 |
|
| 40D8H ↳16600 | Two byte location of where BASIC is currently reading program. | |
| 40DAH-40DBH ↳16602-16603 ↳DATLIN | Level 2 | Line number of last DATA item read. Line number is saved so that in the event of a syntax error in a DATA statement, the proper error line number will be displayed and the EDIT mode will function on the correct line. |
| 40DCH ↳16604 ↳SUBFLG | Model 1 | FOR command flag:
|
| 40DCH ↳16604 ↳SUBFLG | Level 2 | If this byte contains 64 a FOR-NEXT loop is being processed, otherwise byte will contain zero. Used to prevent an array variable from being used as the index counter in a FOR-NEXT loop (for example, the statement FOR X(0) = 1 TO 10 will cause a syntax error, because X(0) is an array variable and cannot be used as the counter variable). |
| 40DDH ↳16605 ↳BFKLFL | Model 1 |
|
| 40DDH ↳16605 ↳BFKLFL | Level 2 | Flag indicates whether inputting text. Used by RETURN and RESUME NEXT commands. |
| 40DEH ↳16606 ↳FLGINP | Model 1 | Read flag:
|
| 40DEH ↳16606 ↳FLGINP | Level 2 | Used for two different purposes: Flags whether READ or INPUT statement when processing those commands (zero represents INPUT). Also used to store delimiter character during processing of PRINT USING statement. |
| 40DFH-40E0H ↳16607-16608 ↳TEMP | Model 1/3 | Used by several routines, as a pointer to variable receiving new value during evaluation of a LET expression, execution address of BASIC program, etc. Also, after a SYSTEM tape is loaded these locations contain the entry point address of the program (which is used if only a / is typed in response to the next SYSTEM command prompt). Is in LSB, MSB order. |
| 40DFH ↳16607 ↳TEMP | Model 1 | Holds execution address for program loaded with DOS request |
| 40DFH ↳16607 | Default entry point for SYSTEM tapes. | |
| 40E1H ↳16609 ↳AUTFLG | AUTO command.
| |
| 40E2H-40E3H ↳16610-16611 ↳AUTLIN | Level 2 | Line Number: Current line number for the AUTO command. This number is stored in binary during the input phase. |
| 40E4H ↳16612 ↳AUTINC | AUTO command increment value | |
| 40E6H-40E7H ↳16614-16615 ↳SAVTXT | Model 1/3 | Pointer to terminator (end of line 00H byte or ":") of the last executed BASIC statement is at this address. |
| 40E6H ↳16614 ↳SAVTXT | Model 1 | During input: address of code string for current statement. During execution: line number for current statement |
| 40E6H ↳16614 | Pointer to terminator (end of line 00H byte or ":") of last executed BASIC statement is at this address. | |
| 40E8H-40E9H ↳16616-16617 ↳SAVSTK | Model 1/3 | Pointer to the beginning of the STACK POINTER. |
| 40E8H ↳16616 ↳SAVSTK | Model 1 | During execution: holds stack pointer value when statement execution begins |
| 40E8H ↳16616 | Beginning of BASIC's stack. | |
| 40EAH-40EBH ↳16618-16619 ↳ERRLIN | Model 1/3 | Line Number: The line number which generated an error. This is used for RESUME. If it is 65535, the error originated in command mode instead of in a program. |
| 40EAH ↳16618 ↳ERRLIN | Model 1 | Line number in which error occurred |
| 40EAH ↳16618 | Two byte address. Contains line number with error. | |
| 40ECH-40EDH ↳16620-16621 ↳DOT | Level 2 | Stores the current line number. Can also be the Line Number for the EDIT command. |
| 40ECH ↳16620 | Two byte address. "." line number. | |
| 40EEH-40EFH ↳16622-16623 ↳ERRTXT | Level 2 | Pointer to last byte executed when error occurred. Used by RESUME command. |
| 40EEH ↳16622 | Pointer to I/O buffer. | |
| 40F0H-40F1H ↳16624-16625 ↳ONELIN | Level 2 | Line Number: ON ERROR location for ON ERROR GOTO. That means it is the line number which the error will jump to. |
| 40F2H ↳16626 ↳ONEFLG | Flag to indicate whether an error has occurred. Set to -1 (FFH) on error, otherwise set to zero (such as after RESUME statement has been executed). POKEing the appropriate values into this location will allow you to do many things that BASIC normally does not permit, such as exiting an error trap without using a RESUME statement, or redefining the error trap (by using an ON ERROR GOTO statement) from within a previously defined error trap. | |
| 40F3H-40F4H ↳16627-16628 ↳TEMP2 | Model 1 | Address of decimal point in pbuff |
| 40F5H-40F6H ↳16629-16630 ↳OLDLIN | Level 2 | Last line number executed prior to execution of STOP or END statement or termination using the BREAK key. |
| 40F7H-40F8H ↳16631-16632 ↳OLDTXT | Level 2 | Pointer to end of last statement executed (points to the colon or zero byte terminator). Used by CONT command. |
| 40F9H-40FAH ↳16633-16634 ↳VARTAB | Level 2 | Starting address of the simple variables list table. This is also one higher than the last of the three zero bytes marking the end of the BASIC program. Used to determine end of BASIC program when saving the program. Note that by taking the address stored here, subtracting 2, and POKEing the resulting address into the start of BASIC program pointer at 40A4H-40A5H, then loading a program with higher line numbers than the one presently in memory, and finally re-POKEing the original values of 40A4H-40A5H back into those locations, it is possible to append a program to a program already in memory. |
| 40FBH-40FCH ↳16635-16636 ↳ARYTAB | Model 1/3 | Starting address of the ARRAY VARIABLE TABLE (end of simple variables) |
| 40FDH-40FEH ↳16637-16638 ↳STREND | Model 1/3 | Pointer to the END of array variables a/k/a start of free memory pointer in LSB, MSB order |
| 40F0H ↳16624 | Pointer to line of BASIC error handling. | |
| 40F2H ↳16626 | Error flag. | |
| 40F5H ↳16629 | Current line number. | |
| 40F9H ↳16633 | End of BASIC program/ start of simple variable list pointer. | |
| 40FBH ↳16635 | Start of arrays variables pointer. | |
| 40FDH ↳16637 | End of arrays variables/ start of free memory pointer. | |
| 40FFH ↳16639 | Two byte address. Current location of BASIC's DATA pointer. | |
| 40FFH-4100H ↳16639-16640 ↳DATPTR | Model 1/3 | DATA Pointer (2 Byte Address; LSB, MSB). Points to comma or other terminator at end of last item read - search for next DATA item to be read will begin here. RESTORE changes this pointer to point to one byte prior to beginning of BASIC program. A selective RESTORE to some data item past the first can be accomplished by manipulating this pointer. For example, suppose that at some point in your program you will want to RESTORE to the 51st DATA item. At the start of your program you could insert a line similar to this: FOR X=1 TO 50 : READ X$ : NEXT Then, whenever you wanted to RESTORE to the 51st DATA item, you would simply execute the following statements:R1=PEEK(16639): R2=PEEK(16640) : RESTORE POKE 16639,R1: POKE 16640,R2 The next READ instruction would then get the 51st DATA item. |
| 4101H-411AH ↳16641-16666 ↳DEFTBL | Model 1/3 | Variable declaration list. There are 26 entries (1 for each letter of the alphabet). The location at 4101H applies to variables starting with the letter A, 4102H applies to variables starting with B, 4103H to variables starting with C and so on up to 411AH, which contains the default type for all variables starting with the letter Z. Each location contains one of the following values:
|
| 4101H ↳16641 | Beginning of variable type table. | |
| 411AH ↳16666 | End of variable type table. | |
| 411BH ↳16667 | Trace flag. | |
| 411BH ↳16667 ↳TRCFLG | Model 1 | TRON Trace flag
|
| 411CH ↳16668 ↳DFACLO-1 | Model 1 | Temporary storage used by numeric routines when unpacking a floating point number. Usually it holds the last byte shifted out of the LSB position |
| 411DH-4124H ↳16669-16676 ↳DFACLO | Model 1/3 | Software Accumulator (SA) - 2 Bytes |
| 411DH ↳16669 ↳DFACLO | Model 1 | Work-Register-Area-1 - LSB of double precision value |
| 411DH ↳16669 | First byte of SA. | |
| 4124H ↳16676 | Last byte of SA. | |
| 4127H ↳16679 | First byte of SA1. | |
| 412EH ↳16686 | Last byte of SA1. | |
| 4120H ↳16672 ↳FACLO-1 | Model 1 | Work-Register-Area-1 - double precision value |
| 4121H-4122H ↳16673-16674 ↳FACLO | Model 1/3 | Single precision number storage area for single precision math routines - 2 Bytes (4121H=MSB) |
| 4123H-4124H ↳16675-16676 ↳FAC-1 | Model 3 | Single precision number storage area for single precision math routines - 2 Bytes (4123H=MSB) |
| 4123H ↳16675 ↳FAC-1 | Model 1 | Work-Register-Area-1 - MSB for single precision |
| 4124H ↳16676 ↳FAC | Model 1 | Work-Register-Area-1 - exponent for single precision |
| 4125H ↳16677 ↳FAC+1 | Model 1 | Sign of result during math & arithmetic operations |
| 4126H ↳16678 ↳ARGLO-1 | Model 1 | Bit bucket used during double precision addition |
| 4127H-412EH ↳16679-16686 ↳ARGLO a/k/a ARG-7 | Model 1/3 | Alternate Software Accumulator (SA1 or REG2) - 2 Bytes |
| 4127H ↳16679 ↳ARGLO | Model 1 | Work-Register-Area-2 - LSB |
| 4128H ↳16680 | Model 1 | Work-Register-Area-2 |
| 4129H ↳16681 | Model 1 | Work-Register-Area-2 |
| 412AH ↳16682 | Model 1 | Work-Register-Area-2 |
| 412CH ↳16684 | Model 1 | Work-Register-Area-2 |
| 412DH ↳16685 ↳ARG-1 | Model 1 | Work-Register-Area-2 - MSB |
| 412EH ↳16686 ↳ARG | Model 1 | Alternate Software Accumulator - exponent |
| 412FH ↳16687 ↳FBUFFR | Level 2 (Non-Disk) | Unused. |
| 4130H-4149H ↳16688-16713 ↳FBUFFR+1 | Level 2 | Multipurpose Storage/Work Area. Buffer used to store result of conversion of numbers to displayable ASCII characters. When positive integers (BASIC line numbers, etc.) are converted, the area from 4130H to 4136H is used, and the string is stored right justified with leading spaces in locations 4130H to 4135H (4130H always contains a space character), while 4136H always contains a zero byte to terminate the string. Other routines (such as PRINT USING) may use more of this area. |
| 414AH ↳16714 ↳FBUFFR+27 | Model 3 | Tape RAM - Workspace For Double Precision Division (8 Bytes). Basically, a temporary ACCUM sometimes used by arithmetic routines (such as to hold divisor used by double precision division routine). |
| 414FH ↳16719 ↳FMLTT1 | Model 1 | Temporary Storage |
| 4150H ↳16720 ↳FMLTT2 | Model 1 | Temporary Storage |
| 4151H ↳16721 ↳FBUFFR+34 | Model 1 | End of temporary area. Locations 4152H through 41E2H contain DOS exits and disk BASIC exits. On non-disk systems these locations are initialized to RETurns (RET'S) while on disk based systems they will be initialized as shown. |
4152H-41A6H - DISK BASIC entry points
RAM Addresses and Routines for Level 1
| Address (Hex/Dec) | Description |
|---|---|
| 3C00H ↳15360 | Start of screen memory |
| 3FFFH ↳16383 | End of screen memory |
| 4000H ↳16384 | A value |
| 4004H ↳16388 | B value |
| 4008H ↳16392 | C value |
| 400CH ↳16396 | D value |
| 4010H ↳16400 | E value |
| 4014H ↳16404 | F value |
| 4018H ↳16408 | G value |
| 401CH ↳16412 | H value |
| 4020H ↳16416 | I value |
| 4024H ↳16420 | J value |
| 4028H ↳16424 | K value |
| 402CH ↳16428 | L value |
| 4030H ↳16432 | M value |
| 4034H ↳16436 | N value |
| 4038H ↳16440 | O value |
| 403CH ↳16444 | P value |
| 4040H ↳16448 | Q value |
| 4044H ↳16452 | R value |
| 4048H ↳16456 | S value |
| 404CH ↳16460 | T value |
| 4050H ↳16464 | U value |
| 4054H ↳16468 | V value |
| 4058H ↳16472 | W value |
| 405CH ↳16476 | X value |
| 4060H ↳16480 | Y value |
| 4064H ↳16484 | Z value |
| 4068H ↳16488 | Pointer to cursor position |
| 406AH ↳16490 | Points to top of physical memory |
| 406CH ↳16492 | Pointer to top of used memory |
| 406EH ↳16494 | Current FOR end value |
| 4070H ↳16496 | A$ Value (16 bytes) |
| 4080H ↳16512 | B$ Value (16 bytes) |
| 4090H ↳16528 | Cassette port status cache (byte) |
| 4091H ↳16529 | Current FOR step value |
| 4093H ↳16531 | Pointer to top of current FOR statement |
| 4095H ↳16533 | Pointer to current FOR statement |
| 4097H ↳16535 | Save for pointer to current line |
| 4099H ↳16537 | Pointer to print buffer |
| 409BH ↳16539 | Pointer to NEXT variable |
| 409DH ↳16541 | Parse pointer saved at a STOP |
| 409FH ↳16543 | Pointer to current line being executed |
| 40A1H ↳16545 | READ pointer |
| 40A3H ↳16547 | Saved SP for this BASIC frame |
| 40A5H ↳16549 | Pointer to current FOR variable |
| 40A7H ↳16551 | Three bytes of RNG state |
| 40AAH ↳16554 | Unused |
| 40ACH ↳16556 | Buffer for command input, print output to cassette |
| 40F3H ↳16627 | End of buffer |
| 40F4H ↳16628 | Bottom of floating point stack. Each entry is 5 bytes consisting of LSB, Middle, MSB (with Bit 7 set), Exponent and Sign (in Bit 7) |
| 4180H ↳16768 | Bottom of system stack pointer |
| 4200H ↳16896 | Top of system stack pointer |
| 4201H ↳16897 | Start of BASIC Program Storage. 16 bit line number followed by line text, terminated with a 0DH |