Menu

CPU/ROM
ROM Addresses
ROM Calls
ROM RST Vectors
ROM Routines (I/O & Misc.)
ROM Routines (Integer Math)
Entry Points to Level II BASIC ROM
Z-80 Instruction Set
Undocumented Z-80 Opcodes

Cassette
System Tape Format
EDAS Tape Format
BASIC Tape Format
Cassette Volume Settings
 
 
 

I/O
Port Addresses (Model I)
Port Addresses (Model III)
Memory Mapped I/O Devices
Port Addresses (Model III/IV)
Model III RS-232 Ports
Model III WD1793 Disk Controller Ports
Radio Shack 5/15 Meg HD Port Assignments
UART Bits
Model 1/3 TRS-80 Keyboard PEEK Table
Model 4P Modem Controls
 

Other
DOS Routines
Level II/DOS RAM Map
Disk Basic Command Vectors
Disk Speed-Up Chart
RAM Addresses
Tokenized BASIC
Pokes and Peeks
Vidtex Escape Sequences
Model 4P Boot Mode Select

RAM Addresses
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 III.
Hex      Decimal    Description
3C00 15360 This is the beginning of video ram or VIDRAM. It ends at 3FFFH or 16383.
16333-16334 End of BASIC Program Pointer (LSB,MSB)
4000 16384 RST 08 Compare value pointed to by HL to that immediately following RST instruction.
4003 16387 RST 10 Examine next symbol pointed to by HL.
4006 16390 RST 18 Compare DE and HL.
4009 16393 RST 20 Test the type of current varible.
400C 16396 RST 28 3 byte break key vector (cass. Basic & TRSDOS 1.3) and normal Dos function call.
400F 16399 RST 30 Reserved for Dos – normally for invoking Debug.
4012 16402 RST 38 Maskable interupt vector.
4015 16405 Beggining of Keyboard DCB. One byte device type. = 1
4016-4017 16406-16407 Two byte keyboard driver vector.
To Disable The Keyboard:

N1=PEEK(16406)            (MOD 1)
N2=PEEK(16407)
POKE16406,154
POKE16407, 10
     THESE FOUR STEPS DISABLE THE
     KEYBOARD. TO RE-ENABLE IT:
     POKE 16406,N1
     POKE 16407,N2
					

4018 16408 Right SHIFT toggle.
4019 16409 Caps lock switch (Not 0 = Caps only)
401A 16410 Cursor blink count
401B 16411 Cursor blink status. (0=blinks)
401C 16412 Cursor blink switch (0 = blink)
401D 16413 Beggining of Video DCB. One byte device type. = 7.
401E 16414 Two byte video driver vector.
4020 16416 Two byte cursor position.
4022 16418 0 = Cursor on, Not 0 = character replaced by cursor.
4023 16419 Cursor Character (in ascii).
4024 16420 FLAG : 0 = Space compression; Not 0 = special character.
4025 16421 Beggining of Printer DCB. One byte device type. = 6.
4026 16422 Two byte printer driver vector.
4028 16424 Maximum lines printed per page +1. Default = 67.
4029 16425 Number of lines printed +1.
402A 16426 Character counter + 1.
402B 16427 Line printer maximum line length less two.
402C 16428 “R”
402D 16429 Return to Dos exit. (Disk systems only).
4030 16432 For all doses except TRSDOS, is abnormal return to DOS ready.
4036 16438 Keyboard buffer (7 bytes).
403D 16445 Cassette port and print size flag (bit 3) copy (For Model 3, see 4210). L3: location of routine to add task to interupt chain.
403E 16446 For Model I DOSPLUS, hold DOS version in DCB format.
4040 16448 For L1 & M1, 25 ms heartbeat counter. For L3, used to remove task from interrupt chain.
4041 16449 Beginning of Time and Date bytes. (seconds, min., hours, year, day, month) Ends at 4046H or 16454. L1, D1, and M1
4043 16451 L3, change address of interupt task.
4044 16452 L1, D1, & M1. Contains date in binary format.
4046 16454 L3. Remove task from interupt chain.
4047 16455 L1. Current day in coded form.
4049 16457 For the Model III disk is non maskable interupt vector, for Model I disk is highest available memory location (Model III = 4411H)
404B 16459 L1. Contains image of interrupt latch.
408E 16526 Address of USR routine (two bytes)
4099 16537 INKEY$ storage. Most recent keyboard character.
409A 16538 Error code is at this address (for BASIC only)
409C 16540 OUTSEL. On Model I, is a one byte output device flag. -1 (or 129) for cass, 0 for video, 1 for printer.
40A0 16544 Clear address pointer. Beggining of CLEARed area for string variable storage
40A0 16544 LSB of Lower Limit for String Variable Storage Space
40A1 16545 MSB of Lower Limit for String Variable Storage Space
40A2-40A3 16546-16547 Last executed line number/Program Line Counter (LSB-MSB).
40A4-40A5   16548-16549  Pointer to beggining of Basic program (LSB-MSB).
40A6 16550 Cursor’s current column number.
40A7 16551 Input buffer pointer.
40A9 16553 ???.
40AA 16554 3 byte random seed number.
40AB 16555 This byte is changed by RANDOM.
40AF 16559 SAFLAG. Contains typeflag of software accumulator.
40B1-40B2 16561-16562 Two byte End (Upper Limit) of String Storage – LSB & MSB.
40B1-40B2 16561-16562 Two byte MEMTOP (for BASIC) – LSB & MSB.
40D3 16585 Saves length ASCII representation of binary integer.
40D4 16586 Two byte address. Points to buffer where ASCII decimal representation written.
40D6 16598 String pointer. Keeps track within CLEARed area as to where last string data was put.
40D8 16600-16601 Two byte location of where Basic is currently reading program/Present BYTE Counter (LSB & MSB).
40DF 16607-16608 Default entry point for SYSTEM tapes (LSB & MSB).
40E1 16609 Auto flag.
40E2 16610 Current auto line number.
40E4 16612 Auto increment.
40E6 16614 Pointer to terminator (end of line 00H byte or “:”) of the last executed Basic statement is at this address.
40E8 16616 Beggining of Basic’s stack.
40EA 16618 Two byte address. Contains line number with error.
40EC 16621 Two byte address. “.” line number.
40EE 16622 Pointer to I/O buffer.
40F0 16624 Pointer to line of BASIC error handling.
40F2 16626 Error flag.
40F5 16629 Current line number.
40F9 16633 End of basic program/ start of simple variable list pointer.
40FB 16635 Start of arrays variables pointer.
40FD 16637-16638 End of arrays variables/ start of free memory pointer (LSB,MSB).
40FF 16639-16640 Two byte address. Current location of Basic’s DATA pointer (LSB,MSB).
4101 16641 Beginning of variable type table.
411A 16666 End of variable type table.
411B 16667 Trace flag.
411D 16669 First byte of SA.
4124 16673 Last byte of SA.
4127 16679 First byte of SA1.
412E 16686 Last byte of SA1.
4152 16722 CVI 3 byte vector.
4155 16725 FN 3 byte vector.
4158 16728 CVS 3 byte vector.
415B 16731 DEF 3 byte vector.
415E 16734 CVD 3 byte vector.
4161 16737 EOF 3 byte vector.
4164 16740 LOC 3 byte vector.
4167 16743 LOF 3 byte vector.
416A 16746 MKI$ 3 byte vector.
416D 16749 MKS$ 3 byte vector.
4170 16752 MKD$ 3 byte vector.
4173 16755 CMD 3 byte vector.
4179 16761 OPEN 3 byte vector.
417C 16764 FIELD 3 byte vector.
417F 16767 GET 3 byte vector.
4182 16770 PUT 3 byte vector.
4185 16773 CLOSE 3 byte vector.
4188 16776 LOAD 3 byte vector.
418B 16779 MERGE 3 byte vector.
418E 16782 NAME 3 byte vector.
4191 16785 KILL 3 byte vector.
4194 16788 & function 3 byte vector.
4197 16791 LSET 3 byte vector.
419A 16794 RSET 3 byte vector.
419D 16797 INSTR 3 byte vector.
41A0 16800 SAVE 3 byte vector.
41A3 16803 LINE 3 byte vector.
41A6 16806 ERROR Error processing jumps to this three byte vector. In cassette Basic it contains RET instruction, in Disk Basic, contains a jump (through RST) to long error message
41A9 16809 USR 3 byter vector.
41AC 16812 Ready prompt
41AF 16815 Called from 0368H to input line from keyboard to I/O buffer.
41B2 16818 Called from 1AA1H immediately after BASIC line is tokenized. HL points to tokenized line.
41B5 16821 Called from 1AECH immediately after BASIC’s table of prg lines are updated. After call to 41B5H, BASIC calls CLEAR routine at 1B5DH then calls this dos exit from 1AF2H
41BB 16827 Called from 1B8CH and 1DB0H during NEW and END processing to allow Disk Basic to close any open files.
41BE 16830 PRINT# processing called from 2174H
41C1 16833 Byte output to any device. Called from 032CH so output to disk can be handled as to other devices.
41C4 16836 ROM KB scan (0358H) calls this exit. BASIC processes INKEY$ here and also after each command when system searches for break or shift @.
41C7 16839 Called from 1EA6H when RUN is followed by filename or line number
41CA 16842 Related to 41BEH above. Called at beggining of print processing from 206FH to check for possible disk output.
41CD 16845 Called from 20C6H. Call is made during print processing after number is in ASCII and just before printing. Could be used for Hex and Binary printing.
41D0 16848 Called from 2103H (from PRINT routine after code that send CR.) Could be used for screen wrap-around.
41D3 16851 Called from 2108H and 2141H. First is for printing with comma tabs, second is for printing with TAB statement. Could be used to increase length of original tabs from 63 or 127 up to 255.
41D6 16854 INPUT# processing. Called from 219EH to check for INPUT# command and to provide input from disk.
41D9 16857 Left side of MID$ processing. Only DOS exit BASIC jumps to instead of calls. Used to allow MID$ on left side of equals sign.
41DC 16860 Variables assignment. During processing of READ & INPUT statements, after computer recieves value and before assigned to variable, BASIC calls this exit from 222DH.
41DF 16863 Called twice from BASIC: From 2278H after BASIC assigns input value to variable and just before BASIC searches for extra data that will generate “Extra ignored” message, and from 2B44H from the midst of list processing. Could be used to alter list command.
41E2 16866 SYSTEM command processing. Called from 02B2 just before “*?” prompt. A system tape will automatically start if a jump to its starting address is placed here. Keep in mind this is a 3 byte location. The first byte should be C3H which is the code for “JP” and should be followed by the starting address of your program.
41E8 16872 $RSRCV input buffer (1 byte)
41F0 16880 $RSTX output buffer (1 byte)
41F8 16888 $RSINIT baud rate code. TX code = most sig. nibble, RCV code = least sig. nib.
41F9 16889 $RSINIT parity/word/length stop-bit code
41FA 16890 $RSINIT wait switch (0 = wait, Not 0 = wait)
4209 16905 L3. Checks for drive and mounted disk.
4210 16912 Various controls: See port EC
4211 16913 Cassette baud rate switch (0 = 500 baud, Not 0 = 1500 baud)
4214 16916 Video display scroll protect (range = 0 – 7)
4217 16919 Model 3 time. Contains time in binary format.
421A 16922 Model 3 date. Contains date in binary format.
4220 16928 $ROUTE destination device (two bytes)
4222 16930 $ROUTE source device (two bytes)
4225 16933 T3, L3, D3. Dos command buffer.
4288 17032 L3. 33.33 ms heartbeat counter.
428A 17034 L3. Send message to Job Log and CRT.
428D 17037 T3, D3. Find drive and file number for open file. For L3, send message to Job Log.
4290 17040 T3, L3, D3. Copy directory to RAM buffer.
4293 17043 Get file name from directory.
4296 17046 L3. Execute Dos command and return to DOS ready.
4299 17049 T3. Do DOS command and return to DOS ready. L3: returns to caller is @EXIT and @ABORT vectors change to jump to return address.
429C 17052 T3. Do DOS command and return to caller.
42AD 17069 D3. Contains address of break key routine.
4312 17170 D1. Contains address of break key routine (195=Off, 201=On).
4318 17176 T1, L1, D1. DOS command buffer.
4396 17302 L1. Read directory into memory.
4400 17408 L1, D1, D3, N1, N3, M1, M3. Same as 402D: return to DOS ready.
4402 17410 Send text to file or device.
4405 17413 L1, D1, D3, N1, N3, M1, M3. Do DOS command and return to DOS ready.
4409 17417 Display error message on CRT.
440D 17421 L1, L3, D1, D3, N1, N3, M1, M3. Enter Debug.
4410 17424 L1, D1, N1, M1. Add task to interrupt chain.
4411 17425 Address of highest available memory location (Mod III disk only – Mod 1 disk = 4049H)
4413 17427 L1, D1, N1, N3, M1. Remove task from interrupt chain. For D3, add task to interrup chain.
4415 17429 T3 (undocumented) Second copy of high memory address. Copied to 4411H in case of I/O error during DO processing.
4416 17430 L1, M1. Change entry address of task in interrupt chain. D3: Remove task from interrupt chain. N1, N3: Keep drives rotating and reselect current drive.
4417 17431 L3. Contains current day in coded format.
4419 17433 T3, L3. Write disk directory to screen or buffer. N1, N3: Execute DOS command and return to caller.
441C 17436 T3, L1, L3, D1, D3, N1, N3, M1, M3. Move filespec to FCB.
4420 17440 All. Open or create a file.
4424 17444 All. Open existing file.
4428 17448 All. Close a file.
442C 17452 All. Remove file from directory.
4430 17456 All. (undocumented in T1) Load file (m.l. program) into memory.
4433 17459 All. (undocumented in T1) Load and run m.l. program.
4436 17462 All. Read logical record into memory.
4439 17465 All. Write logical record to disk.
443C 17468 All. Write record and verify.
443F 17471 T3, L1, L3, D1, D3, N1, N3, M1, M3. Point to first record in file.
4442 17474 All. Position file to specified record.
4445 17477 T3, L1, L3, D1, D3, N1, N3, M1, M3. Backspace file one record.
4448 17480 T3, L1, L3, D1, D3, N1, N3, M1, M3. Position to end of file.
444B 17483 T3, L3, D3, M3. Add extension to filespec in FCB (see also 4473). L1: Check for end of file. D1: Multiply 16 bit by 8 bit integer. N1, N3: Allocate disk space to file.
444E 17486 T3, L3, D3. Multiply 16 bit by 8 bit integer. L1: Update directory with current record as end of file. D1: Divide 16 bit by 8 bit integer. N1, N3: Position file to specified byte record.
4451 17489 T3, L3, D3. Divide 16 bit by 8 bit integer. D1: Check for end of file. N1, N3: Update directory with record as end of file.
4454 17492 L1 Read current sector. L3, D3, M3: Parse parameters in command line. D1: Find drive and file number of a file.
4457 17495 L1 Rewrite current sector. D3: Check for end of file. D1: Read directory to user buffer.
4458 17496 L3. Check for end of file.
445A 17498 L1. Calculate current logical record number. D1, D3: Display directory on CRT.
445B 17499 L3. Update directory with current record as end of file. N1, N3: Select and power up specified drive.
445D 17501 L1. Calculate EOF record number.
445E 17502 L3. Reread current sector. N1, N3: Test drive and disk.
4460 17504 L1. Skip next logical record.
4461 17505 L3. Rewrite current sector. N1, N3: Add user routine to DOS library chain.
4462 17506 D1, D3. Send text to printer.
4463 17507 L1. Read directory to buffer or CRT.
4464 17508 L3. Skip next logical record. N1, N3: Remove user routine from DOS library chain.
4467 17511 L1, L3, D1, D3, N1, N3, M1, M3. Display text on CRT.
446A 17514 L1, L3, N1, N3, M1, M3. Send text to printer.
446D 17517 T1, L1, D1, D3, N1, N3, M1. Get time in ASCII format. L3: Calculate current logical record number.
4470 17520 L3. Calculate end of file record number.
4473 17523 L3. Holds image of interrupt latch. T1, L1, D1, D3, N1, N3, M1, M3: Add default extension to filespec in FCB. (See also 444BH)
4476 17526 L1, D1, M1, M3: Parse parameters in command line.
4478 17528 NewDOS/80 v2.0 for Model 3 Break Vector (195=Off, 201=On).
4779 17529 L1. Send text to file or device. D1, D3: Scan and evaluate command line.
447B 17531 L1. Send text to job log and CRT. N3: Add task interrupt chain.
447C 17532 D1, D3. Compare filespec to wildcard mask.
447E 17534 L1. Send text to joblog.
447F 17535 D1, D3. Get device number for file or I/O device.
4482 17538 D1, D3. Sort block of memory.
4485 17541 D1. 10 disk I/O functions depending on value in A.
4488 17544 D3. 10 disk I/O functions depending on value in A. D1: Locate device control block for any device.
448B 17547 D1. Locate drive control table for any drive.
44A0 17568 D3. Locate device control block for any device.
44A3 17571 D3. Locate drive control table for any drive.
44B8 17592 L1. Check drive and disk.
44BB 17595 L1. Get file name from directory.
44C1 17601 L1. Multiply 16 bit by 8 bit integer.
44C4 17604 L1. Divide 16 bit by 8 bit integer.
44D2 17618 M3. Add task to interrupt chain.
44D5 17621 M3. Remove task from interrupt chain.
44D8 17624 M3. Change execution address of task in interrupt chain.
44DB 17627 M3. Set task pointer to default of RET.
44DE 17630 M1, M3. Verify a sector without reading to RAM.
44E1 17633 M1, M3. Read sector.
44E4 17636 M1, M3. Write sector.
44E8 17640 M1, M3. Read directory sector.
44EB 17643 M1, M3. Write directory sector.
44EE 17646 M1, M3. Read director.
44F1 17649 M1, M3. Write directory.
44F4 17652 M1, M3. User function.
44F7 17655 M1, M3. Get directory track number.
46DD 18141 RDSECT. On Model I, allows you to read a disk sector. Register C contains the drive selcted, D contains the track, E contains the sector number, HL points at data buffer. On return, Z is set if successful; otherwise A contains error code.
46E6 18150 WTSECT. On Model I, allows you to write a disk sector. Same conditions as RDSECT at 46DDH.
4754 18260 L1, L3. Select drive.
4759 18265 L1, L3. Continually reselect drive until it is ready.
475E 18270 L1, L3. Seek specified cylinder (track).
4763 18275 L1, L3. Write sector to disk.
4768 18280 L1, L3. Write system (directory) sector.
476D 18285 L1, L3. Write track to disk (used for formatting).
4772 18290 L1, L3. Verify sector without transfering data to memory.
4777 18295 L1, L3. Read sector to buffer.
478F 18319 L1, L3. Get address of drive code table for specifed drive.
479C 18332 L1, L3. Get byte field from drive code table.
4B10 19216 L1, L3. Read directory sector with specified entry code.
4B1F 19231 L1, L3. Write system buffer to specified directory sector.
4B45 19269 L1, L3. Read directory sector to user buffer.
4B64 19300 L3. Get cylinder (track) number of directory.
4B65 19301 L1. Get cylinder (track) number of directory.
4B6B 19307 L3. Multiply 8 bit by 8 bit integers.
4B6C 19308 L1. Multiply 8 bit by 8 bit integers.
4B7A 19322 L3. Divide 8 bit by 8 bit integers.
4B7B 19323 L1. Divide 8 bit by 8 bit integers.

Model III RS-232 Ports – Luis M. Garcia-Barrio
This section contains a list of Model III RS-232 Ports
PORT E8H (232)  Master Reset/MODEM Status Register
Any output to this port resets the Controller.

On input: Bit 4 — Ring Indicator
Bit 5 — Carrier Detect
Bit 6 — Data Set Ready
Bit 7 — Clear To Send
PORT E9H (233) Config. DIP switches/Baud rate select

On input: Bits 0-2 Baud rate from 50 to 1200 (5=300; 7=1200)
Bit 3 — 0=Parity On; 1=Parity Off
Bit 4 — 0=1 Stop Bit; 1=2 Stop Bits
Bit 5-6 Word length ( 00=5, 01=6, 10=7, 11=8 )
Bit 7 — 0=Parity Odd; 1=Parity Even
On output: Bits 0-3 Receive Baud Rate (50-19200)
Bits 4-7 Transmit Baud Rate (50-19200)
PORT EAH (234) Status and Control Register

On input: Bit 3 — 1=Parity Error
Bit 4 — 1=Framing Error
Bit 5 — 1=Overrun Error
Bit 6 — 1=Data Sent
Bit 7 — 1=Data Ready
On output: Bit 0 — Data Terminal Ready
Bit 1 — Request To Send
Bit 2 — Break
Bit 3 — Parity enable
Bit 4 — Stop bits
Bits 5-6 Word length select
Bit 7 — Parity
PORT EBH (235) Data Register

On input: Received Data
On output: Transmit Data

Model III/IV Ports
Port Description
80H Input: Reserved. Output: Graphics board register.
81H Input: Graphics board RAM read. Output: Graphics board RAM write.
82H Input: Reserved. Output: Graphics board Y register.
83H Input: Reserved. Output: Graphics board X register.
84H Mod IV – various controls. 80 micro, March 84, p. 122. Input is reserved. Output:
Bit 0: Video memory, keyboard memory, and Model III ROM. (See Table 1)
Bit 1: Same as bit 0. (See Table 1)
Bit 2: Video display mode. 0 = 64 by 16, 1 = 80 by 24.
Bit 3: Reverse Video.
Bit 4: Ram bank select. (See Table 2)
Bit 5: Ram bank select. (See Table 2)
Bit 6: Ram bank select. (See Table 2)
Bit 7: Video page select (64 by 16 mode) 0 = page 0, 1 = page 1.
85H – 87H. Same as 84H.
88H CRT controller control register.
89H CRT controller control register.
8AH CRT controller control register.
8BH CRT controller data register.
8CH – 8FH. Graphics board select 2.
90H Model IV sound port. Any of the sound routines used on the Model I and Model III that uses port FFH can be changed to this and then the Model IV’s built in speaker can be used!
91H – 93H. Same as 90H.
94H – BFH. Reserved.
C0H Input: Hard disk write protect. Output: Reserved.
C1H Hard disk control register.
C2H – C3H. Input: Hard disk device ID register. Output: Reserved.
C4H Hard disk CTC channel 0.
C5H Hard disk CTC channel 1.
C6H Hard disk CTC channel 2.
C7H Hard disk CTC channel 3.
C8H Hard disk data register.
C9H Hard disk error register.
E0H Maskable interupt
E4H Select NMI options/read NMI status
E8H
E9H —— RS-232
EAH —— ports
EBH
ECH Write = various controls/ read = reset clock
Bit 7 not used
Bit 6 CPU clock speed [0 = 2 mhz, 1 = 4 mhz (Mod IV only)]
Bit 5 Video waits [0 = disable, 1 = enable]
Bit 4 I/O bus [0 = disable, 1 = enable]
Bit 3 Alt. char. [0 = disable, 1 = enable]
Bit 2 Double width [0 = normal, 1 = double]
Bit 1 Cass motor [0 = on, 1 = off]
Bit 0 not used
** NOTE : Ports F0H through F4H are for Model III/IV disk I/O (not Model I) **
F0H Read FDC status/issue FDC command
Read status
80H Not ready
40H Write protect
20H Record type/Write fault/Head loaded
10H Seek error/Record not found
08H CRC error
04H Track 0/lost data
02H Index/DRQ
01H Busy
F1H FDC track register
F2H FDC sector register
F3H FDC data register
F4H Select drive and options
F8H Line printer addres port
80H Busy.
40H Out of paper
20H Unit select
10H Fault
FFH Cassette port
FDC commands via port F0 (Model III only)
00H restore
80H read sector
A0H write normal sector
A1H write read protect sector
C0H read address
D0H reset; puts FDC in mode 1
E0H read track
F0H write track

Table 1
      Bits
1 0
Model III
ROMs Enabled
Video and
Keyboard Status.
      0 0 Yes Model III.
      0 1 No Model III.
      1 0 No Model 4. (In)
      1 1 No Model 4. (Out)

Table 2
      Bits
6 5 4     
Lower 32k     
RAM
Upper 32K
RAM
      0 0 0 Bank 0 Bank 1
      0 1 0 Bank 0 Bank 2
      0 1 1 Bank 0 Bank 3
      1 1 0 Bank 2 Bank 1
      1 1 1 Bank 3 Bank 1

ROM Addresses
The following Z80 registers and register pairs apply: A,F,B,C,D,E,H,L,AF,BC,DE,HL,IX,IY. Any of these proceeded by a “‘” refers to the alternate set.
Miscellaneous:
     SA – Software accumulator
     SA1 – Alternate software accumulator
     RA – Register accumulator (E,D,C,B).
Hex    Dec.    Label    Type    Description
0000 0 DOSCLD Jp “In cassette systems, reset computer; in disk systems, cold boot of DOS. Could also be done via RST 00H.”
0008 8 SYNTAX RST Checks for syntax. HL points to byte to be checked and proper byte follows RST 08H instruction.
000B 11 WHERE Call “Vector used to resolve relocation address of calling routine. On exit, HL points to address following Call instruction.”
0013 19 GET Call This routine gets a byte from a logical device or a file that is open. Entry: DE points at FCB. Exit: A = byte.
0018 24 CP16 Rst Compare DE and HL as 16 bit unsigned intergers.
001B 27 PUT Call Outputs a byte to a logical device or FCB. DE = FCB and A = byte. Don’t confuse with CTL at 0023.
0023 35 CTL Call Outputs a control byte to a logical device or FCB. DE = FCB and A = control byte.
0028 40 Rst Pressing Break key RST’s here and then jumps to location 400CH. Also normal DOS function vector.
002B 43 KBDSCN Call Scan keyboard and return with accumulator containing result. DE is used.
0033 51 VDCHAR Call Displays a character at current cursor location.
003B 59 PRCHAR Call “Waits until printer is ready then prints charatcter. A = ASCII character. If BREAK is pressed, a return to caller is made.”
0040 64 KBLINE Call Call Input a line from the keyboard. B = max length of line. HL points at buffer. Buffer should be the length of B plus 1. To terminate, hit BREAK or ENTER. On exit, HL points at buffer and B = number of characters entered. Carry will be set if BREAK was pressed.
0049 73 KBWAIT Call “Scans the keyboard until a key is pressed. If BREAK is pressed, it is returned like other keys.”
0050 80 RSRCV Call “Recieve a character from RS-232. No entry conditions. On exit, memory location 16872 contains character recieved. DE is altered. This routine honors wait status.”
0055 85 RSTX Call “Transmit character to RS-232. On entry, Accumulator or memory location 16880 contains character. On exit, 16880 = 0 if no character sent. Wait status honored.”
005A 90 RSINIT Call Call Initialize RS-232 interface. On entry, memory location 16888 = send/recieve baud rate code, location 16890 = wait/don’t wait switch, location 16889 = RS-232 characteristics switch. On exit, DE is altered. For more detail, consult Model 3 reference manual.
0060 96 DELAY Call “Load BC with how many times to loop, then call.”
0069 105 INITIO Call “Initialize all I/O drivers to their ROM routines. No entry conditions. On exit, all registers changed.”
006C 108 ROUTE Call “On entry, location 4222H = two byte source device ASCII abbreviation and location 4220H = two byte destination ASCII abbreviation. On exit, DE is altered.”
0072 114 An alternative for entering Basic. See also 1A19H.
00B1 177 Type in SYSTEM (even from DISK BASIC) and reply to the “*?” prompt with /177. The computer will then ask you for memory size. Upon return, you’ll still be in DISK BASIC, but your program will be gone. Also, it doesn’t get along with any high memory routines present.
00FA 250 Call this routine from BASIC and your computer will brag about it having Level II or Model III BASIC.
0132 306 POINT Basic’s POINT routine.
0135 309 SET Basic’s SET routine.
0138 312 RESET Basic’s RESET routine.
0150 336 GRAPH Jp This is the routine that is Basic’s SET, RESET, and POINT functions. Here’s how to use it. Load HL with return address and push. Load register A with one of the following: 00H = POINT, 01H = RESET, and 80H = SET. Push AF onto stack. Load A with X coordinate and push onto stack. Load A with Y coordianate and JP GRAPH.
018C 396 Call “Checks for syntax of “”)”” via RST 08H.”
01C9 457 CLS Call Clear screen.
01D3 467 RANDOM Call Randomize.
01F8 504 CSOFF Call This routine turns off the cassette drive.
0212 530 DEFCAS Call A register contains a 0 or 1 which is the cassette number. This routine defines cassette number and turns on cassette. Model I only.
022C 556 ??? ??? ???
0235 565 CSIN Call Inputs data one byte at a time from cassette after you use CSHIN. A = the data byte.
0264 612 CSOUT Call Outputs data one byte at a time to cassette after you use CSHWR. A = the output byte.
0287 647 CSHWR Call Turns on the cassette and writes the header.
0296 662 CSHIN Call Finds the cassette header info at the beggining of cassette file.
02B2 690 SYSTEM Basic’s SYSTEM routine.
0314 788 ??? ??? ???
032A 810 OUTCHR Call Ouput character in register A; OUTSEL (409CH) selects device. See OUTSEL for device values.
033A 826 DISPA Call Displays character in A on screen at next print position. Uses AF.
0358 856 Calls keyboard scan routine.
035B 859 Call Same as 002BH.
0361 865 KIBUFF Call Reads keyboard into buffer until a carriage return is entered. 40A7H contains the address of the buffer.
03C2 962 Line printer driver for Model I.
03E3 995 Keyboard driver for Model I. Model III = 3024H.
0458 1112 Video driver for Model I.
0473 1139 Video driver for Model III.
0506 1286 CURCON “Start of cursor control table. Model I. 80 Microcomputing, Sept. 1980, p. 187.”
0540 1344 End of cursor control table.
058D 1421 Line printer driver for Model I.
05D9 1497 KLINE Call Same as KBLINE. See 0040.
06CC 1740 An alternative for entering Basic. See also 1A19H.
06D2 1746 Start of Model 1 interrupts relocated to RAM on boot up.
06E6 1766 End of Model 1 interrupts relocated to RAM on boot up.
06E7 1767 Start of Model 1 keyboard DCB.
06EE 1774 End of Model 1 keyboard DCB.
06EF 1775 Start of Model 1 Video DCB.
06F6 1782 End of Model 1 Video DCB.
06F7 1783 Start of Model 1 Printer DCB.
06FE 1790 End of Model 1 Printer DCB.
0713 1811 SUBSP Call Subtract SA from RA; result in SA.
0716 1814 ADDSP Call Add RA and SA; result in SA.
0778 1912 RSETSA Call “If SA contains a 00H, RND generates a number between 0 and 1. Use this call to place a 00H in SA.”
0809 2057 LOG Call Basic’s LOG function.
0847 2119 MLTSP Call Multiply RA and SA; result in SA.
08A2 2210 DIVSP Call Divide RA by SA; result in SA.
0977 2423 ABS Call Basic’s ABS function.
0982 2434 MVVAR Call Move number of bytes shown by typeflag from area pointed to by DE to area pointed to by HL.
098A 2442 SGN Call Basic’s SGN function.
09A4 2468 LDSTSA Call Load SA into stack.
09B1 2481 LDSAHL Call Load single precision number pointed to by HL into SA.
09B4 2484 LDSARA Call Load RA into SA.
09BF 2495 LDRASA Call Load SA into RA.
09C2 2498 LDRAHL Call Load single precision number pointed to by HL into RA.
09CB 2507 LDHLSA Call Load SA into area pointed to by HL.
09D2 2514 LDDEHL Call Load single precision number pointed to by HL into area pointed to by DE; needs FLAGSP.
09D3 2515 LDHLDE Call Load single precision number pointed to by DE into area pointed to by HL; needs FLAGSP.
09D6 2518 MOVEA Call “Move data; DE = source, HL = destination, A = how much to move.”
09D7 2519 MOVEB Call “Same as above, except B contains the count.”
09F7 2551 MVSAHL Call Move number pointed to by HL into SA; needs FLAGDP.
09FC 2556 MVALT Call Move SA into SA1.
0A0C 2572 CPSP Call Compare RA and SA1.
0A39 2617 CPINT Call Compare DE and HL.
0A78 2680 CPDP Call Compare SA and SA1.
0A7F 2687 GETPAR Call Load parameter in USR(x) into HL; this must be first instruction of USR call. Also used for CINT function.
0A9A 2714 BSCPAR Jp Return to Basic program with parameter.
0A9D 2717 FLAGIN Call Set typeflag of SA to interger.
0AB1 2737 CSASP Call Convert SA to single precision. Also Basic’s CSNG routine.
0ACC 2764 CHGIS Call Value in workspace/accumulator is changed from integer to single precision.
0ADB 2779 CSADP Call Convert SA to double precision. Also Basic’s CDBL routine.
0AEC 2796 FLAGDP Call Set typeflag for SA to double precision.
0AEF 2799 FLAGSP Call Set typeflag for SA to single presision.
0B26 2854 FIX Call Basic’s FIX function.
0B37 2871 INT Call Basic’s INT function.
0BC7 3015 SUBINT Call Subtract HL from DE; result in HL and SA if no overflow (flag = 2); result in SA only if overflow (flag = 4).
0BD2 3026 ADDINT Call Add DE and HL; result in HL and in SA if no overflow.
0BF2 3058 MLTINT Call “Multiply DE and HL; result in HL and SA if no overflow (flag=2), result in SA only if overflow (flag=4)”
0C70 3184 SUBDP Call Subtract SA1 from SA; result in SA.
0C77 3191 ADDDP Call Add SA and SA1; result in SA.
0DA1 3489 MLTDP Call Multiply SA and SA1; result in SA.
0DE5 3557 DIVDP Call Divided SA by SA1; result in SA.
0FAF 4015 Display integer number in HL in ASCII decimal. The ASCII number will also be in memory at 4131H – 4135H.
0FBD 4029 CSAASC Call Convert SA (set typeflag) to ASCII. Result (in dec) is placed in buffer starting at 4130H and terminated by a 00H byte and HL = 4130H.
13E7 5095 SQR Call Basic’s SQR function.
13F7 5111 POWER Call Raise RA to the power SA; result in SA.
1439 5177 EXP Call Basic’s EXP function.
14C9 5321 RND Call Basic’s RND function.
14CC 5324 ???
1541 5441 COS Call Basic’s COSine function.
1547 5447 SIN Call Basic’s SIN function.
15A8 5544 TAN Call Basic’s TAN function.
15BD 5565 ATN Call Basic’s ATN function
1608 5640 “Beginning of jump table for Basic’s functions. For Basic’s jump statement table, see 1822H.”
164F 5711 End of jump table for Basic’s functions.
1650 5712 Beginning of table of names of Basic’s reserved words.
181F 6175 End of table of names of Basic’s reserved words.
1822 6178 “Beginning of jump table for Basic’s statements. For Basic’s jump funtion table, see 1608H.”
1899 6297 End of jump table for Basic’s statements.
18C9 6345 “Start of BASIC error messages. Ie: NF, OM, etc.”
18F6 6390 End of BASIC error messages.
196C 6508 Check for enough RAM for stack operation.
1997 6551 SN ERROR routine.
19A2 6562 ERROR routine.
1A19 6681 BASIC Jp “Return to Basic and display Basic READY prompt (if you have difficulty with 1A19, try 06CCH or 0072H instead)”
1AF8 6904 Writes line pointers beginning from start of Basic program.
1AFC 6908 Writes line pointers beginning with line pointed to by DE.
1B2C 6956 FNDLIN “To use: Load DE with line number, call and this location. Upon exit, BC will contain location. 80 Micro, Feb. 1981, p. 148.”
1B49 6985 NEW Basic’s NEW routine.
1B4D 6989 “Reset Basic pointers? 80 Microcomputing, Nov 81, p. 386.”
1B5D 6705 Basic initialization routines (RUN).
1BC0 7104 TOKEN Basic’s tokenizing routine. Point register pair HL to the start of the string to be tokenized terminated by a 0 byte and call 1BC0H. Upon exit, HL will point to one byte below the tokenized string which will be terminated by a 0 byte.
1CA1 7329 FOR Basic’s FOR routine.
1D1E 7454 RUNSTM Jp “HL points at “”:”” or 00H terminating a Basic statement or line; execution will proceed from next statement.”
1D91 7569 RESTORE Basic’s RESTORE routine.
1D9B 7579 Scan for shift @ and BREAK.
1DA9 7593 STOP Basic’s STOP routine.
1DAE 7598 END Basic’s END routine.
1DE4 7652 CONT Basic’s CONT routine.
1DF7 7671 TRON Basic’s TRON routine.
1DF8 7672 TROFF Basic’s TROFF routine.
1E00 7680 DEFSTR Basic’s DEFSTR routine.
1E03 7683 DEFINT Basic’s DEFINT routine.
1E06 7686 DEFSNG Basic’s DEFSNG routine.
1E09 7689 DEFDBL Basic’s DEFDBL routine.
1E4A 7754 FCERR Call “Prints “”FC Error””.”
1E5A 7770 VAL Call “Convert a string representing a decimal number and terminated by a 00H byte to a binary number. HL points at first character, DE contains result after call.”
1E7A 7802 CLEAR Basic’s CLEAR routine.
1EA3 7843 RUN Basic’s RUN routine.
1EB1 7857 GOSUB Basic’s GOSUB routine.
1EC2 7874 GOTO Basic’s GOTO routine.
1EDE 7902 RETURN Basic’s RETURN routine.
1F05 7941 DATA Basic’s DATA routine.
1F07 7943 REM/ELSE Basic’s REM and/or ELSE routine.
1F21 7969 EVALU Call Call Evaluate expression. Useful for doing complicated math functions in machine language. HL must point to a portion of memory that is in tokenized BASIC and terminated by a 00H byte or a “:” byte. Also known as Basic’s LET routine.
1F6C 8044 ON Basic’s ON routine.
1FAF 8111 RESUME Basic’s RESUME routine.
1FF4 8180 ERROR Basic’s ERROR routine.
2008 8200 AUTO Basic’s AUTO routine.
2039 8249 IF Basic’s IF routine.
2067 8295 LPRINT Basic’s LPRINT routine.
206F 8303 PRINT Basic’s PRINT routine.
219A 8602 INPUT Basic’s INPUT routine.
21E3 8675 MVSTR Call Move string into space; HL points at first byte of buffer and BC points at variable name.
21EF 8687 READ Basic’s READ routine.
22B6 8886 NEXT Basic’s NEXT routine.
2337 9015 “Gets a general (string, integer, single, or double precision) parameter in the accumulator and sets the type flag (40AFH) accordingly.”
2490 9360 DIVINT Call Call Divide DE by HL; result in SA in single precision format. 2540 9536 LDVAWS Call Loads value of variable into workspace/ accumulator. On entry, HL points to first character of variable name. On exit, HL points to first character following variable name.
25A1 9633 CPSTR Call “Compare two strings. HL and BC point at strings, D and E contain lengths.”
2608 9736 DIM Basic’s DIM statement.
260D 9741 VARPTR Call “Get variable address in DE, HL points at variable name.”
27D4 10196 FRE Basic’s FRE routine.
27F5 10229 POS Basic’s POS routine.
2836 10294 STR$ Basic’s STR$ routine.
28A7 10407 OUTSTR Call “Output string terminated by a 00H byte or 22H (“”) byte.; HL points at first character, OUTSEL (409CH) selects device. See OUTSEL for device numbers.”
2A03 10755 LEN Basic’s LEN routine.
2A0F 10767 ASC Basic’s ASC routine.
2A1F 10783 CHR$ Basic’s CHR$ routine.
2A61 10849 LEFT$ Basic’s LEFT$ routine.
2A91 10897 RIGHT$ Basic’s RIGHT$ routine.
2A9A 10906 MID$ Basic’s MID$ routine.
2AEF 10991 INP Basic’s INP routine.
2A2F 10799 STRING$ Basic’s STRING$ routine.
2AC5 10949 VAL Basic’s VAL routine.
2AFB 11003 OUT Basic’s OUT routine.
2B02 11010 Gets a two byte integer in DE.
2B17 11031 “Evaluate expression? 80 Microcomputing, Nov 81, p. 386”
2B1C 11036 Gets a one byte integer in A.
2B29 11049 LLIST Basic’s LLIST routine.
2B2E 11054 LIST Basic’s LIST routine.
2B75 11125 OSTR Call “Output string to current device. On entry, HL points to first character in string which ends in a 00 byte.”
2B7E 11134 “Write line of Basic in buffer, change tokens to words.”
2BC6 11206 DELETE Basic’s DELETE routine.
2BF5 11253 CSAVE Basic’s CSAVE routine.
2C1F 11295 CLOAD Basic’s CLOAD routine.
2C77 11383 “Initialize for Basic. 80 Micro, Sep. 1980, p. 72.”
2CAA 11434 PEEK Basic’s PEEK routine.
2CB1 11441 POKE Basic’s POKE routine.
2E60 11872 EDIT Basic’s EDIT routine.
2E66 11878 EDITOR “Load HL with line number to edit and use this routine. 80 Micro, Feb. 1981, p. 148.”
3024 12324 Video driver for Model III.
3033 12339 GETDAT Call “Get date in ASCII format. Mod III TRSDOS, LDOS, & MULTIDOS.”
3036 12342 GETTIM Call “Get time in ASCII format. Mod III TRSDOS, LDOS, & MULTIDOS.”
3042 12354 ??? ??? ???
37E0 14304 Port “Model I interrupt address port. Bit 7 set for clock, bit 6 set for disk.”
37E1 14305 Port Model I disk drive select.
37E4 14308 Port Model I cassette 1 or 2 select (0 or 1).
37E8 14312 Port Lineprinter address port.
37EC 14316 Port Model I disk command/status.
37ED 14317 Port Model I disk track select.
37EE 14318 Port Model I disk sector select.
37EF 14319 Port Model I disk data.
3800 14336 Ports Beginning of model I & III keyboard address ports.
3840 1440 Ports End of model I & III keyboard address ports.

Radio Shack 5/15 Meg HD Port Assignments – Bob Haynes, 10/15/87
This chart provides reference on the Western Digital Hard Disk Controller board WD1000-TB1, based on the WD1010 controller chip and WD1100 support chip. This board is used in later (white) versions of the Radio Shack 15 Meg Hard Disk (26-4155).
Earlier versions of the 15M, the 5M, and 12M hard disk systems all use a larger controller board based on the 8X300 controller chip. I’ve heard the R/S 8M hard disk also uses the 8X300 board, but that’s unconfirmed.
I have little information on the 8X300 board, but since both 15 and 5 Meg systems are known to work with the same driver/format software from at least three sources (Tandy/MISOSYS/PowerSOFT), it is assumed most of this chart also applies to the earlier 8X300 board. (one difference is noted above)
Although Radio Shack has mapped the HD access ports from C0-CFH as a standard configuration, both boards can re-map the ports to 50-5FH, 60-6FH, or 70-7FH simply by changing some jumpers. (If interested, drop a line for details.)
Special thanks to Adam Rubin, who reviewed the information to help confirm its accuracy. Comments, corrections and updates are welcome!

                 Radio Shack 5/15 Meg HD Port Assignments
.--------------------------------------------------------------------------.
|PORT C0H - READ ONLY                |PORT C1H - R/W - HD Control Register |
|Bits 2-3 unused                     |Bits 0-2, 5-7 unused (see note 4)    |
|     0-INTRQ-Interrupt request      |     3    If set, enables controller |
|     1-HWPL-If set, at least one HD |     4    If set, resets controller  |
|            is write protected      |-------------------------------------|
|     4-WPD4-drive 4 write protected |PORT C2-C3H - READ - HD Dev. ID Reg. |
|     5-WPD3-drive 3 write protected |     C4-C7H - HD CTC Channels 0-3    |
|     6-WPD2-drive 2 write protected |     See note 1                      |
|     7-WPD1-drive 1 write protected |-------------------------------------|
|------------------------------------|PORT C8H - R/W - HD Data Register    |
|PORT C9H - READ - Error Register    |-------------------------------------|
|Bits 3,5 all reserved (zero)        |PORT C9H - WRITE - Wrt Pre-Comp Cyl. |
|     0-DAM not found (see note 2)   |The value stored here multiplied x4  |
|     1-Track 0 Error (restore cmnd) |is the RWC start cylinder number.    |
|     2-Aborted Command              |-------------------------------------|
|     4-ID Not Found Error           |PORT CAH - R/W - Sector Count        |
|     6-CRC Data Field Error         |Used only for multiple sector access |
|     7-Bad Block Detected           |don't care w/ single sector commands,|
|------------------------------------|internally decrements when used.     |
|PORT CBH - R/W - Sector number      |-------------------------------------|
|------------------------------------| PORT CDH - R/W - Cylinder MSB       |
|PORT CCH - R/W - Cylinder LSB       |   (bits 0-1 only; max cyls = 1024)  |
|--------------------------------------------------------------------------|
|PORT CEH - R/W - SDH - Sector size/Drive #/Head #                         |
|Bits 0-2  Head number  (0-7)                                              |
|     3-4  Drive number (00-11 reference DSEL1-DSEL4 respectively)         |
|     5-6  Sector size  (00=256, 01=512, 10=1024, 11=128)                  |
|     7    EXTension:   if set, ECC (Error Checking and Correction) codes  |
|                       are in use, R/W data (sector length+7 bytes) do    |
|                       not check/generate CRC.                            |
|--------------------------------------------------------------------------|
|PORT CFH - READ - Error Status Register                                   |
|Bit 0  Error (OR of bits 1-7)       Bit 4  Seek complete                  |
|    1  Command in progress              5  Write fault                    |
|    2  Reserved (0)                     6  Drive ready                    |
|    3  Data request                     7  Busy                           |
|--------------------------------------------------------------------------|
|PORT CFH - WRITE - Command Register Instruction Set - see note 3          |
|          Bits: 7 6 5 4 3 2 1 0    |            Bits: 7 6 5 4 3 2 1 0     |
|  Restore     | 0 0 0 1 d c b a    |  Read Sector   | 0 0 1 0 i m 0 0     |
|  Seek        | 0 1 1 1 d c b a    |  Write Sector  | 0 0 1 1 0 m 0 0     |
|  Scan ID     | 0 1 0 0 0 0 0 0    |  Write Format  | 0 1 0 1 0 0 0 0     |
|                                   |                                      |
| "dcba" defines step rate field:   | "i" defines interrupt enable status: |
|      0000 =  35 us.               |   0 = interrupt when data request    |
| 0001-1111 =  0.5-7.5 ms in        |       line (DRQ*) is enabled         |
|               0.5 ms steps        |   1 = interrupt at end of command    |
|                                                                          |
| "m" defines multiple sector flag: 0 = one sector, 1 = multiple sectors   |
`--------------------------------------------------------------------------'

Notes:
1.  Ports C2-C7 are applicable to the Model II configuration with interface
    board and 8X300 controller board only.  (no further information was
    available, sorry!)

2.  Port C9, bit 0, READ: R/S 15M HD Service Manual indicates this bit is
    reserved (forced zero), but WD1010-00 spec sheet indicates it is used to
    indicate a "DAM not found" error.

3.  Port CF, WRITE: The 4P ROM is known to send three commands to this port:
    16H-restore, 20H-read one sector, 70H-seek. Draw your own conclusions re
    the step rate and interrupt values.

4.  Although there is no formal documentation of this, according to the
    schematics, port C1H bit 2 seems to be used to enable wait state support
    on the 8X300 controller board.  I cannot absolutely confirm this, neither
    can I say whether the later WD-1000-TB1 board implements this function.
						

Tokenized BASIC – Dick Straw
HOW THE LEVEL II INTERPRETER SEES IT
Dick Straw
Down at the end of appendix C12 in your Level II BASIC Reference Manual you will discover the information that ASCII codes 129 through 191 are graphics codes, and ASCII 192 through 255 are tab codes. And they are. If you run something like

     PRINT CHR$(200); CHR$(140)
					

You will get a graphic block set spaced appropriately eight spaces from the left margin of your screen. Actually, 128 is a graphics code too — it just doesn’t have any of the six segments of the graphics matrix set, so it comes out blank.
But that only tells part of the story, because those same 128 code values are used by the interpreter as spacesaving symbols equivalent to that list of reserved words on page A115 of the appendix in the manual. Here’s how it works –and how to see it for yourself.
When you start typing a line on your keyboard in the usual fashion, each keystroke is duly recorded in the 110 buffer as its ASCII code equivalent. When you push ENTER at the end of the line, the line you just typed is interpreted right on the spot — in the buffer. Each of the command or instruction words is converted to a single byte equivalent, with values between 128 and 255, inclusive. If there was no number at the beginning of the line, the instructions you just entered will be acted upon at once. If there was a line number, the whole line is transferred to the text memory location and put into its proper place.
Both of those locations can be examined using the PEEK command. The 110 buffer occupies 256 locations beginning at 16870, while the text memory starts at 17129 if you have no disk BASIC entered . I don’t have a printer or a disc, so it takes a lot of staring at the screen, but no big hazards.
Try this: write a short program, say, three lines or so. For example:

     10 DEFINTA,L: DIM A(9)
     20 FOR L = 0 TO 9: A(L) = 5 * L + 2
     30 PRINTA (L);:NEXTL
					

Then run it. You get the line of ten numbers you expected. Now, in command mode, enter

     FOR Z = 0 TO 200 : ?PEEK(17129 + Z);: NEXTZ
					

I got a string of numbers like the following you should too, if you used the same spacing I did. I will mark some places as I type this, in order to refer to them later, so remember that the underlining and the letters don’t come with the output.
Most of the numbers here are simply the ASCII codes for the individual letters and numbers used in the program — and the punctuation, too, of course. If you look them up in appendix C, you will find, for example, that 32 is a space and 58 a a colon.
First of all, remember that the program had three lines, numbered 10, 20, and 30. We can see those line numbers in the parts of the text marked B. It is easy to see them if you use line numbers below 256, because the numbers are entered in the usual manner for recording integers, with the least significant byte(LSB) first and the most significant byte (MSB) next, in two bytes. For low numbers, the MSB is zero and the LSB comes out as its real number. For higher numbers, you need to multiply the MSB by 256 and add the LSB to see what you have.
The two numbers ahead of the line numbers are marked B. These, In the same integer format, are the pointers to the next line of the program in the text memory. For example, 252 66 translates to 17148. Since the location of the first number, 252, Is 17129, we count over until we reach 17148 and find a 24, the first byte of the pointer to the third line. The pointer at the beginning of the third line points to a pair of zeroes, marked with an M – this means there is no next line, so the line we were in, in this case line 30, is the last in the program. Since every line of the program ends with a zero (marked E, above) you can locate not only the end of each line but the end of the program as well.
All those other big numbers in the program itself are the function codes I referred to earlier, and you can translate them either by comparison with the program itself or by looking them up in the table of function codes listed there. The first, for example, is 153, the equivalent of DEFINT.
Following the program itself you will find all the variables that were assigned values in the program (that Is why it was worth while to run it .before the PEEK). You need to know that every variable has a three-byte “name” that precedes each value itself. The first byte is a digit that both defines the type of variable and tells how many value-bytes there are. For example, the sequence 2 0 76, marked “L”, is the name of the integer variable L used as an index. The 2 tells you it is stored In two bytes. The next byte is the second symbol In the name, here a zero because we didn’t use a second symbol. It would be 49, the ASCII value of 1 if we had called the variable L1. The MSB of the name is 76, which is ASCII “L”.
The next one is something of a surprise at first. It starts out 4 0 90 — 4 is a single precision variable that needs four bytes for the value, and the name is Z – the variable used in the command line to print out the peek was put in here, shoving the other variables aside. If a double precision variable were used, its indicator would be an 8. After the Z valuer (the value it had when the printing command passed it up), we find the array, A. Its name is that of an integer, but the next values are descriptions of the array – two bytes for the length of the storage string (after the MSB of its value), one byte for the number of dimensions (here 1), and two bytes for the number of locations in each dimension. There is only one dimension here, with ten locations (0 to 9). Then come the ten values, two bytes each.
String arrays have a header beginning with 3, meaning three bytes are in storage. Those three bytes are not its value, obviously, but indicate the length of the string in the first byte (thus a limit of 256 characters), and the integer-format location of the first character in the string. If you assign the string value in the program, as in a print statement, the location pointed to will be in the program text. If it is a string whose value is assigned as a variable, it will be found at the end of the RAM memory.
So there is your whole program, laid out in the memory of your processor for the interpreter to read. And you can read it too. I have included the Hex values for the function codes in the table so that those who get a Hex dump say, from the RSM-1S monitor, can translate it also. Those masochists will also need to translate the ASCII values of letters and numbers from and into Hex, of course!
It is also interesting to look at the I/O buffer. If you type in a long command string, such as the PEEK routine we used to look at the text memory, you will discover that the little program is still there. The first parts of it will be written over as the line is shortened by conversion of the functions to their one-byte codes, and will end with three zeroes, but after that you can find the key-by-key entries you put in when typing.
You can also try this: with your program in residence and after a PEEK, as we did before, en-ter NEW, then run the PEEK on the same area again. You will find that the first two numbers are zeroes — meaning, sorry, no program. You will also find the variable you used to PEEK written in there too. But after that, the rest of the program will be in its original form. You can POKE the original numbers back into locations 17129 and 17130 and list the program again, with only the loss of the first line (if it was long enough not to be overwritten in your playing around).
You can figure out what most of the numbers between 128 and 255 mean by PEEKing at them just as described. But a lot of those numbers don’t mean-anything unless you have disc basic. You can still see what they mean if you try the following:
Entera short program, say, two lines, like this:

     10 A = 10
     20 PRINT A
					

You know that the text will be located beginning at location 17129, with the first four bytes devoted to the pointer and line number. So POKE into 17133 (the first byte of the program itself) and maybe a couple of others — but be sure not to get past the end of the line, and then LIST the program. Line 10 will be there, and so will the meanings of the numbers you POKEd in. Most of them won’t run, of course, unless you have disc running, but the listing will still do the translating for you.

Tokenized BASIC – Leonard Erickson (a/k/a Shadow)
Each “line” starts with the 2-byte address of the start of the *next* line. Then there’s the line number. Both are binary integers in LSB MSB format. This is followed by the text of the line, with BASIC keywords replaced by one byte tokens. All tokens have bit 8 set.

128     END
129     FOR             170     KILL            211     OR
130     RESET           171     LSET            212     >
131     SET             172     RSET            213     =
132     CLS             173     SAVE            214     <
133     CMD             174     SYSTEM          215     SGN
134     RANDOM          175     LPRINT          216     INT
135     NEXT            176     DEF             217     ABS
136     DATA            177     POKE            218     FRE
137     INPUT           178     PRINT           219     INP
138     DIM             179     CONT            220     POS
139     READ            180     LIST            221     SQR
140     LET             181     LLIST           222     RND
141     GOTO            182     DELETE          223     LOG
142     RUN             183     AUTO            224     EXP
143     IF              184     CLEAR           225     COS
144     RESTORE         185     CLOAD           226     SIN
145     GOSUB           186     CSAVE           227     TAN
146     RETURN          187     NEW             228     ATN
147     REM             188     TAB             229     PEEK
148     STOP            189     TO              230     CVI
149     ELSE            190     FN              231     CVS
150     TRON            191     USING           232     CVD
151     TROFF           192     VARPTR          233     EOF
152     DEFSTR          193     USR             234     LOC
153     DEFINT          194     ERL             235     LOF
154     DEFSNG          195     ERR             236     MKI$
155     DEFDBL          196     STRING$         237     MKS$
156     LINE            197     INSTR           238     MKD$
157     EDIT            198     POINT           239     CINT
158     ERROR           199     TIME$           240     CSNG
159     RESUME          200     MEM             241     CDBL
160     OUT             201     INKEY$          242     FIX
161     ON              202     THEN            243     LEN
162     OPEN            203     NOT             244     STR$
163     FIELD           204     STEP            245     VAL
164     GET             205     +               246     ASC
165     PUT             206     -               247     CHR$
166     CLOSE           207     *               248     LEFT$
167     LOAD            208     /               249     RIGHT$
168     MERGE           209     ^               250     MID$
169     NAME            210     AND             251     (REM QUOTE)
					

Here are the single byte model 4 codes:

128                     171     AUTO            214     NOT
129     END             172     RENUM           215     ERL
130     FOR             173     DEFSTR          216     ERR
131     NEXT            174     DEFINT          217
132                     175     DEFSNG          218     USING
133     INPUT           176     DEFDBL          219     INSTR
134     DIM             177     LINE            220     '
135     READ            178                     221     VARPTR
136     LET             179                     222
137     GOTO            180     WHILE           223     ERRS$
138     RUN             181     WEND            224     INKEY$
139     IF              182     CALL            225     MEM
140     RESTORE         183     WRITE           226     TIME$
141     GOSUB           184     COMMON          227
142     RETURN          185     CHAIN           228
143     REM             186     OPTION          229
144     STOP            187     RANDOM          230
145     PRINT           188                     231
146     CLEAR           189     SYSTEM          232
147     LIST            190                     233
148     NEW             191     OPEN            234
149     ON              192     FIELD           235
150     WAIT            193     GET             236
151     DEF             194     PUT             237
152     POKE            195     CLOSE           238
153     CONT            196     LOAD            239
154                     197                     240     >
155                     198                     241     =
156     OUT             199     NAME            242     <
157     LPRINT          200     KILL            243     +
158     LLIST           201     LSET            244     -
159     CLS             202     RSET            245     *
160                     203     SAVE            246     /
161                     204                     247     ^
162     ELSE            205     SOUND           248     AND
163     TRON            206                     249     OR
164     TROFF           207     TO              250     XOR
165     SWAP            208     THEN            251     EQV
166     ERASE           209     TAB             252     IMP
167     EDIT            210     STEP            253     MOD
168     ERROR           211     USR             254     \
169     RESUME          212     FN              255
170     DELETE          213     SPC
					

The 2 byte codes all start with a 255 byte (FFh), the second byte is listed below:

128
129     LEFT$
130     RIGHT$
131     MID$
132     SGN
133     INT
134     ABS
135     SQR
136     RND
137     SIN
138     LOG
139     EXP
140     COS
141     TAN
142     ATN
143     FRE
144     INP
145     POS
146     LEN
147     STR$
148     VAL
149     ASC
150     CHR$
151     PEEK
152     SPACE$
153     OCT$
154     HEX$
155     LPOS
156     CINT
157     CSNG
158     CDBL
159     FIX
160
161
162
163
164
165
166
167
168
169
170     CVI
171     CVS
172     CVD
173     EOF
174     LOC
175     LOF
176     MKI$
177     MKS$
178     MKD$
179     ROW
						

Tokens - Pete Cervasio
REM is 143. The three byte sequence is :, 143, 251 and in the program below I decode 251 as the single quote.
I've converted this one and my Model 4 converter to Turbo Pascal recently, and they allow things like having the keywords come out in upper/lower/mixed case, and other fun stuff like that. I'll put them up on the web when I get them finished up a little more.
One weird thing: Model 1/3 basic stores literal numbers as the ASCII representation of those numbers. Model 4 basic stores them in the binary representation.

' Model 1/3 compresed BASIC to ASCII format converter thingie
' Copyright (c) 1998, Peter Cervasio (cervasio@airmail.net)
' Permission to distribute freely is granted to all.
DEFINT A-Z

DIM KeyWord$(256)

false = 0
true = NOT false

READ First%, Last%

FOR i = First% TO Last%
        READ KeyWord$(i)
NEXT

PRINT "MOD1BAS - Model 1/3 BASIC to ASCII Conversion Program"
PRINT "Copyright (c) 1997, Pete Cervasio"
PRINT "Distribute freely"
PRINT
PRINT "Model 1/3 BASIC file to convert: ";
LINE INPUT TheFile$
IF TheFile$ = "" THEN END


PRINT "Enter output filename: ";
LINE INPUT OutFile$
IF OutFile$ = "" THEN
  IF INSTR(TheFile$, ".") = 0 THEN
    OutFile$ = TheFile$ + ".qbx"
  ELSE
    OutFile$ = LEFT$(TheFile$, INSTR(TheFile$, ".")) + "qbx"
  END IF
END IF


OPEN TheFile$ FOR BINARY AS 1


A$ = " "
GET 1, , A$


IF A$ = CHR$(255) THEN
  PRINT TheFile$; " -> "; OutFile$
  OPEN OutFile$ FOR OUTPUT AS 2
  WHILE NOT EOF(1)
    GET 1, , i%
    IF i% = 0 THEN END
    GET 1, , i%
    IF i% > 0 THEN
      PRINT #2, LTRIM$(RTRIM$(STR$(i%))); " ";
    ELSE
      PRINT #2, LTRIM$(RTRIM$(STR$(65536! + i%))); " ";
    END IF
    linedone = false
    WHILE NOT linedone
      GET 1, , A$
      IF A$ = CHR$(0) THEN
        linedone = true
      ELSE
        j = ASC(A$)
        IF (j >= First%) AND (j <= Last%) THEN
          PRINT #2, KeyWord$(j);
        ELSE
          PRINT #2, A$;
        END IF
      END IF
    WEND
    PRINT #2, ""
  WEND
ELSE
  PRINT "Could not recognize "; TheFile$; " - 1st byte not 0xFF"
END IF
CLOSE


END


DATA 128, 251
DATA END, FOR, RESET, SET, CLS, CMD, RANDOM, NEXT, DATA, INPUT, DIM
DATA READ, LET, GOTO, RUN, IF, RESTORE, GOSUB, RETURN, REM, STOP
DATA ELSE, TRON, TROFF, DEFSTR, DEFINT, DEFSNG, DEFDBL, LINE, EDIT
DATA ERROR, RESUME, OUT, ON, OPEN, FIELD, GET, PUT, CLOSE, LOAD
DATA MERGE, NAME, KILL, LSET, RSET, SAVE, SYSTEM, LPRINT, DEF, POKE
DATA PRINT, CONT, LIST, LLIST, DELETE, AUTO, CLEAR, CLOAD, CSAVE
DATA NEW, "TAB(", TO, FN, USING, VARPTR, USR, ERL, ERR, STRING$, INSTR
DATA POINT, TIME$, MEM, INKEY$, THEN, NOT, STEP, "+", "-", "*", "/"
DATA "^", AND, OR, ">", "=", "<", SGN, INT, ABS, FRE, INP, POS, SQR
DATA RND, LOG, EXP, COS, SIN, TAN, ATN, PEEK, CVI, CVS, CVD, EOF, LOC
DATA LOF, MKI$, MKS$, MKD$, CINT, CSNG, CDBL, FIX, LEN, STR$, VAL, ASC
DATA CHR$, LEFT$, RIGHT$, MID$, "'"
						

Pokes and Peeks - Valley TRS-80 Hackers Group (A Levinson and E Bagai)
MODEL ADDRESSES FUNCTION



3 0 TO 14335 ROM - LOW MEMORY - BASIC INTERPRETER
3 0 (0000H) $RESET SOFTWARE SYSTEM RESET
3 43 (002BH) $KBCHAR SCAN KEYBOARD FOR A CHARACTER
3 51 (0033H) $VDCHAR DISPLAY A CHARACTER ON THE SCREEN
3 59 (003BH) $PRCHAR PRINT A CHARACTER ON THE PRINTER
3 64 (0040H) $KBLINE GET A LINE FROM THE KEYBOARD
3 73 (0049H) $KBWAIT WAIT FOR A KEYBOARD CHARACTER
3 80 (0050H) $RSRCV RECEIVE A CHARACTER FROM RS-232-C
1/3 84 UNOFFICIAL PEEK POINT (SEE 293) 1=M1 ELSE=M3
3 85 (0055H) $RSTX SEND A CHARACTER TO RS-232-C
3 90 (005AH) $RSINIT INITIALIZE THE RS-232-C
3 96 (0060H) $DELAY DELAY FOR A SPECIFIED TIME
3 105 (0069H) $INITIO INITIALIZE I/O DRIVERS
3 108 (006CH) $ROUTE ROUTE I/O DEVICES
1/3 293 OFFICIAL RADIO SHACK PEEK POINT 73=M3 ELSE=M1
3 457 (01C9H) $VDCLS CLEAR THE SCREEN
3 473 (01D9H) $PRSCN PRINT THE SCREEN ON THE PRINTER
3 504 (01F8H) $CSOFF TURN OFF THE CASSETTE
3 539 (021BH) $VDLINE DISPLAY A LINE TO THE SCREEN
3 565 (0235H) $CSIN INPUT A BYTE FROM THE CASSETTE
3 612 (0264H) $CSOUT OUTPUT A BYTE TO THE CASSETTE
3 647 (0287H) $CSHWR WRITE THE CASSETTE HEADER
3 653 (028DH) $KBBRK QUICK SCAN FOR BREAK KEY ONLY
3 662 (0296H) $CSHIN SEARCH FOR HEADER ON CASSETTE
3 664 (0298H) $CLKON TURN ON THE CLOCK DISPLAY
3 673 (02A1H) $CLKOFF TURN OFF THE CLOCK DISPLAY
3 6681 (1A19H) $READY BASIC READY ENTRY ADDRESS
3 12339 (3033H) $DATE GET THE SYSTEM DATE
3 12342 (3036H) $TIME GET THE SYSTEM TIME
3 12354 (3042H) $SETCAS SELECT CASSETTE BAUD RATE
1 14305 DISK DRIVE SELECT
1 14308 Values: 0-1
SELECT TAPE DRIVE: 0=#1 1=#2
3 14312 (37E8H) $PRSTAT PRINTER STATUS BYTE
1/3 14312 PRINTER ON=63 OFF=143 (NOT DEPENDABLE)
1 14316 DISK COMMAND/STATUS --
1 14317 DISK TRACK SELECT
1 14318 DISK SECTOR SELECT
1 14319 DISK DATA
1/3 14336 TO 14400 KEYBOARD ADDRESS MATRIX
1/3 14337 SEE 15105
1/3 14338 SEE 15106
1/3 14340 SEE 15108
1/3 14352 SEE 15120
1/3 14368 SEE 15136
1/3 14400 SEE 15168
1/3 14464 SEE 15232

MEM.   1   2   4   8  16  32  64  128
 ......................................
14337= `   A   B   C   D   E   F   G
14338= H   I   J   K   L   M   N   O
14340= P   Q   R   S   T   U   V   W
14344= X   Y   Z
14352= 0   1   2   3   4   5   6   7
14368= 8   9   :   ;   ,   -   .   /
14400=ENT CLR BRK UP  DN   LT  RT SPC
14464=SHF SHF CTL CAP F1   F2  F3

MODEL I IS MAPPED FOR DECIMAL 1 IN THE
POSITION 14464 FOR EITHER SHIFT KEY. IN
THE MODEL III AND 4, THE LOCATION 14464
WOULD BE DECIMAL 1 FOR THE LEFT SHIFT KEY
AND DECIMAL 2 FOR THE RIGHT SHIFT KEY.

FOR EXAMPLE, IF PEEK(14340)=16,
THEN THE "T" KEY IS BEING PRESSED.
OR IF PEEK(14400)=1, THEN THE
ENTER KEY IS BEING PRESSED.
THIS DOES NOT USE THE INKEY$
ROUTINE, AND THEREFORE YOU CAN
HOLD A KEY DOWN INSTEAD OF HITTING
IT REPEATINGLY. (USEFUL FOR ACTION
GAMES) ALSO, IF TWO KEYS THAT HAVE
THE SAME KEYBOARD ADDRESS ARE
PRESSED AT THE SAME TIME, THE
VALUE WILL BE THE SUM OF THE TWO
KEYS. EX: If ENTER and CLEAR are
pressed at the same time, location
14400 will equal 3. (UP =Up Arrow
DN=Down Arrow, LT=Left Arrow, and
RT=Right Arrow)
					

1/3 15105 Values: 1,2,4,...128
PEEK KEYBOARD RESPECTIVELY: A,B,C,D,E,F,G
1/3 15106 Values: 1,2,4,...128
PEEK KEYBOARD RESPECTIVELY: H,I,J,K,L,M,N,O
1/3 15108 Values: 1,2,4,...128
PEEK KEYBOARD RESPECTIVELY: P,Q,R,S,T,U,V,W
1/3 15112 Values: 1,2,4
PEEK KEYBOARD RESPECTIVELY: X,Y,Z
1/3 15120 Values: 1,2,4,...128
PEEK KEYBOARD RESPECTIVELY: 0,1,2,3,4,5,6,7
1/3 15136 Values: 1,2,4,...128
PEEK KEYBOARD RESPECTIVELY: 8 9 : ; , - . /
1/3 15168 Values: 1,2,4,...128
PEEK: ENTER, CLR,BREAK,UP-ARW,DN-ARW,L-ARW,R-ARW,SPACE
1/3 15232 PEEK KEYBD RT/LT SHIFT
1 15360 Value: 1/65
1:RADIO SHACK LC MOD 65=NOT RS MOD OR L/C DRIVER INSTALLED
1/3 15360 TO 16383 RAM - VIDEO DISPLAY (BEGINS UPPER RIGHT CORNER)
3 16383 (3FFFH) END OF VIDEO MEMORY
1/3 16387 TO 16389 RST 10H TRANSFER ADDRESS
1/3 16396 Value: 201
RE-ENABLE BREAK KEY
1 16396 Value: 23/221
IN LEVEL II: 23=DISABLES BREAK 221=ENABLES BREAK
3 16396 Value: 175
1ST OF TWO TO DISABLE BREAK (RS RECOMMENDS)
3 16396 (400CH) BREAK KEY JUMP VECTOR
3 16396 Value: 195
1ST OF 3 COMBINED TO DISABLE BREAK
3 16397 Value: 154
2ND OF 3 COMBINED TO DISABLE BREAK
3 16397 Value: 201
2ND OF TWO TO DISABLE BREAK (RS RECOMMENDS)
3 16398 Value: 10
3RD OF 3 COMBINED TO DISABLE BREAK
1/3 16402 TO 16405 RST 38H TRANSFER ADDRESS
1/3 16405 TO 16412 KEYBOARD CONTROL BLOCK
3 16409 Value: 0/1
0=INPUT LEFT U/L CASE 1=INPUT CONVERTED TO U CASE (UNLESS FOREIGN DRIVER - DOS+)
1/3 16412 Value: 0/1
CURSOR BLINK=0 NO BLINK=1
1/3 16413 TO 16420 VIDEO CONTROL BLOCK
1/3 16414 Value: 141/194
1ST OF 2 TO SEND PRINT TO LPRINT (M1=141 M3=194)
1/3 16415 Value: 5/6
2ND OF 2 TO SEND PRINT TO LPRINT (M1=5 M3=3)
1/3 16414 Value: 88/115
1ST OF 2 TO RESTORE PRINT (VIDEO) (M1=88 M3=115)
1/3 16415 Value: 4
2ND OF 2 TO RESTORE PRINT (VIDEO) (M1 & M3)
1/3 16416 & 16417 CURSOR ADDRESS 2 BYTES LSB/MSB
1/3 16418 or 16419 Value: 32-255
CURSOR CHARACTER IN ASCII (NORMAL CURSOR=171)
3 16420 CHARACTER SET: 1=ALTERNATE 0=REG
1/3 16421 TO 16428 PRINTER CONTROL BLOCK
1/3 16422 Value: 88/15
1ST OF 2 TO SEND LPRINT TO VIDEO (M1=88 M3=115)
1/3 16423 Value: 4
2ND OF 2 TO SEND LPRINT TO VIDEO (M1 & M3)
1/3 16422 Value: 141/194
1ST OF 2 TO RESTORE LPRINT (PRINTER) (M1=141 M3=194)
1/3 16423 Value: 5/3
2ND OF 2 TO RESTORE LPRINT (PRINTER) (M1=5 M3=3)
1/3 16424 (4028H) MAX PRINTER LINES PER PAGE PLUS 1
1/3 16425 Value: 1
RESETS LINE COUNT
1/3 16425 Value: 1 TO ?
PEEKS # LINES PRINTED+1 -- POKE N,1: RESETS LINE COUNT
1/3 16427 MAX CHAR PER LPRINT LINE LESS 2 (255=NO MAX)
1 16445 CASSETTE PORT AND PRINT-SIZE FLAG (BIT 3) COPY
1 16445 Value: 0/8
0=CHR$( 28 ):64 CHAR LINE. 8=CHR$(23):32 CHAR LINE
1 16449 TO 16454 TIME/DATE (SEC,MIN,HRS,YR,DA,MO) (SEE 16919/924)
1 16457 & 16458 DOS MEMORY SIZE
1 16526 & 16527 POINTER TO USR ROUTINE - LEVEL II ONLY
3 16526 NUMBER CHAR PRINTED PER LINE PLUS 1
1/3 16537 INKEY$ STORAGE (IN ASCII)
1/3 16538 ERROR CODE
1/3 16539 e.g.:LPRINT STRING$(N-PEEK(16539),32) . . .
1/3 16539 TO LPRINT TAB(N) WHEN N>63 (SEE NOTE)
1/3 16540 OUTPUT FLAG (-1=KBD 0=VIDEO 1=PRINTER)
1/3 16544 & 16545 STRING SPACE START ADDRESS
1/3 16546 & 16547 CURRENT LINE NUMBER IN BASIC PROGRAM
1/3 16548 & 16549 POINTER TO BEGIN BASIC PROGRAM (SEE NOTE)
1/3 16548 TO APPEND: POKE 16548,PEEK(16633)-2:POKE16549,PEEK(16634)
1/3 16548 TO CLOAD: POKE16548,233:POKE16549,66
1/3 16551 & 16552 WHEN IN BASIC - POINTS TO ADDR OF BASIC KBD BUFFER
1 16553 Value: 255
FOR OLD M1'S -POKE AFTER "INPUT#" FOR A "READ" TO FUNCTION
1/3 16554 TO 16556 SEED FOR RND
1/3 16555 THIS BYTE CHANGED BY 'RANDOM'
1/3 16559 VARIABLE-TYPE FLAG FOR THE SOFTWARE ACCUMULATOR
1/3 16561 & 16562 LAST BYTE OF MEMORY AVAILABLE FOR BASIC
1/3 16598 & 16599 NEXT USABLE BYTE IN STRING SPACE
1/3 16607 & 16608 ENTRY POINT OF SYSTEM TAPE
1/3 16614 & 16615 POINTS AT TERMINATOR OF THE LAST EXECUTED BASIC STATEMENT
1/3 16618 & 16619 LINE # WITH ERROR (IF 65535 : COMMAND MODE)
1 16633 & 16634 POINTER TO END OF BASIC PROG - SEE 16548
1/3 16633 & 16634 STARTING ADDRESS OF SIMPLE VARIABLE TABLE
1/3 16635 & 16636 STARTING ADDRESS OF ARRAY VARIABLE TABLE
1/3 16637 & 16638 1ST BYTE OF FREE MEMORY AFTER ARRAY TABLE
1/3 16639 & 16640 'DATA' POINTER - TELLS YOU WHERE YOU'RE GOING TO RECORD
1/3 16641 TO 16666 VARIABLE-TYPE TABLE
1/3 16669 TO 16676 SOFTWARE ACCUMULATOR (SA)
1/3 16679 TO 16686 ALTERNATE SOFTWARE ACCUMULATOR (SA)
1/3 16722 TO 16815 DISK BASIC INTERFACE
1/3 16806 TO 16868 DOS INTERFACE AREA
1/3 16872 (41E8H) $RSRCV INPUT BUFFER
4 16875, 16876 & 16883 M4 IN M3 MODE: ASCII VALUES OF F1,2,3 KEYS
1/3 16880 (41F0H) $RSTX OUTPUT BUFFER
1/3 16884 (41F4H) Value 103
1st of 2 to Change LINE keyword to act as LPRINT
1/3 16885 (41F5H) Value 32
2nd of 2 to Change LINE keyword to act as LPRINT
1/3 16888 (41F8H) $RSINIT BAUD RATE CODE
1/3 16889 (41F9H) $RSINIT PARITY/WD LEN/STOP CODE
1/3 16890 (41FAH) $RSINIT WAIT SWITCH (0=DON'T WAIT)
3 16912 Value: 0/8
0=CHR$( 28 ):64 CHAR LINE. 8=CHR$(23):32 CHAR LINE
4/3 16912 Value: 64,0
SPEEDUP IN III MODE, 0=RETURN TO 2MHZ
3 16913 CASSETTE BAUD RATE: 0=500 NON-0=1500
3 16916 Value: 0-7
VIDEO DISPLAY SCROLL PROTECT 1-7 LINES
3 16919 Value: 00-59
SECONDS
3 16920 Value: 00-59
MINUTES
3 16921 Value: 00-23
HOURS
3 16922 Value: 00-99
YEARS
3 16923 Value: 01-31
DAYS
3 16924 Value: 01-12
MONTHS
1/3 16928 (4220H) $ROUTE DESTINATION (1ST) BYTE
1/3 16929 (4221H) $ROUTE DESTINATION (2ND) BYTE
1/3 16930 (4222H) $ROUTE SOURCE (1ST) BYTE
1 17129 BEGINNING OF BASIC PROGRAMS IN LEVEL II BASIC
1 17170 MODEL 1 NEWDOS/80 V2.0 BREAK VECTOR
195=OFF, 201=ON
3 17385 TO -- RAM - BASIC PROGRAM IN A CASSETTE SYSTEM
3 17425 & 17426 MEMORY SIZE M3 DISK BASIC
1 17528 MODEL 3 NEWDOS/80 V2.0 BREAK VECTOR
195=OFF, 201=ON
1/3 19631 (4223H) $ROUTE SOURCE (2ND) BYTE
3 26841 TO -- RAM - BASIC PROGRAM IN TRS-DOS 1.3
1/3 32767 (7FFFH) 16K SYSTEM TOP OF PHYSICAL MEMORY
3 49151 (BFFFH) TOP OF MEMORY 32K SYSTEM
3 65535 (FFFFH) TOP OF MEMORY 48K SYSTEM
... a few more ...

PEEK 14312      If the line printer status port is >63 then the printer is
                not on or ready to print.  Power off =255; print inhibit
                switch (off line) enabled =233 or 223; print buffer full
                =191; ready to accept data =63 (normal).

PEEK 14316      The disk status register =255 when there is no expansion
                interface conncected or powered on.

POKE 14308,0    Latches cassette #1
     14308,1    Latches cassette #2

POKE 16396,23   Disable the BREAK key (Level II)
     16396,199  Causes BASIC to reinitialize when the BREAK key is hit
                (Level II)

POKE 16405,0    Locks up the keyboard, but lets your program keep running

PEEK 16549      If <66 then this is not Disk BASIC

POKE 17170,175  Disable the BREAK key
POKE 17171,201  both of these POKEs are necessary

POKE 23461,0    Disable the BREAK key (NEWDOS 2.1)

POKE 23886,0    Disable the BREAK key (TRSDOS 2.3)
					

Model III WD1793 Disk Controller Ports
The Model III talks to its WD1793 disk controller through the following ports:
0E4H
Bit


7
6
5
Write


0/1: dis/enable INTRQ intrpt
dis/enable DRQ interpt
N/A
Read


0/1: INTRQ status: true/false
0/1: DRQ status = true/false
0/1: Reset status = true/false
0F0H
Bit


7
6
5
4
3
2
1
0
Disk Command Register


Disk Status Register


Not Ready
Write Protect
Read: Record Type; Write: Write Fault
Record Not Found
CRC Error
Data Lost
DRQ
Busy
0F1H (Read/Write) - Disk Track Register
Byte


N/A
Write


Track Number
Read


Track Number
0F2H (Read/Write) - Disk Sector Register
Byte


N/A
Write


Sector Number
Read


Sector Number
0F3H (Read/Write) - Disk Data Register
Byte


N/A
Write


Data byte to be written to disk      
Read


Data byte read from disk
0F4H
Bit


7

6

5

4

3
2
1
0

Write Only


0 Selects FM Mode (Single Density)
1 Selects MFM Mode (Double Density)
0 disable wait state generation
1 enable
0 disable write precompensation
1 enables
0 select side 0
1 select side 1
0/1: deselect/select drive 3
0/1: deselect/select drive 2
0/1: deselect/select drive 1
0/1: deselect/select drive 0

UART Bits
One of the minor incompatibilities between the MODEL-I and the MODEL-III lie in the way in which serial (RS-232-C) I/O is handled. they are almost, but not quite the same. This article will discuss the differences, provide patches for SCRIPSIT/LC'S serial printer driver and give some general guidelines for adapting MODEL-I serial I/O code for use on the MODEL-III.
Both the MODEL-I and the MODEL-III use four Z-80 I/O ports for the RS-232-C interface: E8H, E9H, EAH and EBH. The ports are used as follows:
E8H Outputting any byte to this port resets the uart. This is usually done only when initializing the interface. Inputting a byte from this port places the contents of the modem status register in the a register. see the manual for Radio Shack's RS-232-C Interface (Catalog #26-1145) for details. MODEL-I and MODEL-III use this port in exactly the same way.
E9H Writing a byte to this port programs the baud rate generator (BRG). The high-order nybble sets the transmit baud rate and the low-order nybble sets the receive baud rate. This is the same for both MODEL-I and MODEL-III. In the MODEL-I, reading this port transfers the settings of the configuration sense switches (the eight dip switches on the RS-232 card) to the a register. these values can then be used for setting the interface to default parameters. the read function for this port is not used in the MODEL-III.
EAH Writing to this port sets up the UART control parameters and the handshake latch. reading this port transfers the contents of the uart status register to the a register. same for both MODEL-I and MODEL-III.
EBH Writing to this port loads the transmit data register with the contents of the a register. reading this port transfers the contents of the received data register to the a register. same for both MODEL-I AND MODEL-III.
From this we can see that the only difference between the two machines is that the MODEL-III has no dip switches to read and thus does not have to input from port E9H. A MODEL-III with the RS-232-C interface installed will automatically set up the interface for 300 baud, 8 bit word, 1 stop bit and no parity, when the system boots up. The disk version uses the SETCOM command to change these values as desired. In the MODEL-I, the RS-232-C Interface is not set up by the operating system and must be configured by the user program which will be using the interface. Some simple drivers merely read the dip switches and set the interface accordingly. programs like ST80 can also do this and additionally allow the user to over-ride these default settings with different values. In converting MODEL-I software to run on the MODEL-III, All code relating to the reading of port E9H and setting the interface accordingly must be removed.

Port Add.! D7  ! D6  ! D5  ! D4  ! D3  ! D2  ! D1  ! D0  !
=========!=====!=====!=====!=====!=====!=====!=====!=====!
E8 Write ! <---- UART  RESET & INITIALISATION ONLY ----->!
         !           NO  DATA  BITS  REQUIRED            !  T
---------!-----!-----!-----!-----!-----!-----!-----!-----!
E8 Read  ! cts ! dsr ! cd  ! ri  !  -  !  -  ! rec !  -  !
         !     !     !     !     !     !     ! i/p !     !  R
=========!=====!=====!=====!=====!=====!=====!=====!=====!
E9 Write !   Software Baud rate settings  (see manual)   !
         !     !     !     !     !     !     !     !     !  S
---------!-----!-----!-----!-----!-----!-----!-----!-----!
E9 Read  !Parit! w/l ! w/l ! stop!Parit! Baud! Baud! Baud!
switches !ev/od!slct1!slct2! 1or2!en/di!  1  !  2  !  3  !
=========!=====!=====!=====!=====!=====!=====!=====!=====!  I
EA Write !Parit! w/l ! w/l ! stop!Parit! TX  ! DTR ! RTS !
control  !ev/od!slct1!slct2! 1or2!en/di!en/di!     !     !
---------!-----!-----!-----!-----!-----!-----!-----!-----!
EA Read  ! DAV ! TBMT!o/run!frame!Parit!  -  !  -  !  -  !  8
 Uart    !     !     !error!error!error!     !     !     !
=========!=====!=====!=====!=====!=====!=====!=====!=====!
EB Write ! <---------- 8 BIT DATA  to  UART -----------> !  0
EB Read  ! <---------- 8 BIT DATA from UART -----------> !
========='====='====='====='====='====='====='====='====='---
           D7    D6    D5    D4    D3    D2    D1    D0
=========v=====v=====v=====v=====v=====v=====v=====v=====v---
F8 Write !  -  !  -  !  -  !  -  !  -  !Uart ! DTR ! RTS !  S
         !     !     !     !     !     !Reset!     !     !
---------!-----!-----!-----!-----!-----!-----!-----!-----!  Y
F8 Read  ! <---------- 8 BIT DATA from UART -----------> !
         !     !     !     !     !     !     !     !     !  S
=========!=====!=====!=====!=====!=====!=====!=====!=====!
F9 Write ! <---------- 8 BIT DATA  to  UART -----------> !
         !     !     !     !     !     !     !     !     !  8
---------!-----!-----!-----!-----!-----!-----!-----!-----!
F9 Read  !TMBT ! CTS ! DSR ! CD  ! PE  ! FE  ! OR  ! DAV !  0
         !     !     !     !     !     !     !     !     !
========='====='====='====='====='====='====='====='====='
					

Z-80 Instruction Set

                             Table I
               Z-80 Instructions from 00 through 3F

           HEX OCT  OP   AD            HEX OCT  OP    AD
            00 000  NOP                 01 001  LD    BC,nn
          * 08 010  EX   AF,AF'         09 011  ADD   HL,BC
          * 10 020  DJNZ n              11 021  LD    DE,nn
          * 18 030  JR   n              19 031  ADD   HL,DE
            20 040  JR   NZ,n           21 041  LD    HL,nn
          * 28 050  JR   Z,n            29 051  ADD   HL,HL
            30 060  JR   NC,n           31 061  LD    SP,nn
          * 38 070  JR   C,n            39 071  ADD   HL,SP

            02 002  LD   (BC),A         03 003  INC   BC
            0A 012  LD   A,(BC)         0B 013  DEC   BC
            12 022  LD   (DE),A         13 023  INC   DE
            1A 032  LD   A,(DE)         1B 033  DEC   DE
            22 042  LD   (nn),HL        23 043  INC   HL
            2A 052  LD   HL,(nn)        2B 053  DEC   HL
            32 062  LD   (nn),A         33 063  INC   SP
            3A 072  LD   A,(nn)         3B 073  DEC   SP

            04 004  INC  B              05 005  DEC   B
            0C 014  INC  C              0D 015  DEC   C
            14 024  INC  D              15 025  DEC   D
            1C 034  INC  E              1D 035  DEC   E
            24 0D4  INC  H              25 045  DEC   H
            2C 054  INC  L              2D 055  DEC   L
            34 064  INC  (HL)           35 065  DEC   (HL)
            3C 074  INC  A              3D 075  DEC   A

            06 006  LD   B,n            07 007  RLCA
            0E 016  LD   C,n            0F 017  RRCA
            16 026  LD   D,n            17 027  RLA
            1E 036  LD   E,n            1F 037  RRA
            26 046  LD   H,n            27 047  DAA
            2E 056  LD   L,n            2F 057  CPL
            36 066  LD   (HL),n         37 067  SCF
            3E 076  LD   A,n            3F 077  CCF



                            Table II
                Z-80 Instructions from 40 through 7F
                    8-Bit Interregister Transfers

General form:
       OCT          OP    AD
       1(r1)(r2)    LD    REG(r1),REG(r2)
Source is REG(r2), destination is REG(r1), where r1 and r2 are 8-bit registers
(see Table VI).

           HEX OCT  OP   AD            HEX OCT  OP    AD
            40 100  LD   B,B            41 101  LD    B,C
            48 110  LD   C,B            49 111  LD    C,C
            50 120  LD   D,B            51 121  LD    D,C
            58 130  LD   E,B            59 131  LD    E,C
            60 140  LD   H,B            61 141  LD    H,C
            68 150  LD   L,B            69 151  LD    L,C
            70 160  LD   (HL),B         71 161  LD    (HL),C
            78 170  LD   A,B            79 171  ADD   A,C

            42 102  LD   B,D            43 103  LD    B,E
            4A 112  LD   C,D            4B 113  LD    C,E
            52 122  LD   D,D            53 123  LD    D,E
            5A 132  LD   E,D            5B 133  LD    E,E
            62 142  LD   H,D            63 143  LD    H,E
            6A 152  LD   L,D            6B 153  LD    L,E
            72 162  LD   (HL),D         73 163  LD    (HL),E
            7A 172  LD   A,D            7B 173  LD    A,E

            44 104  LD   B,H            45 105  LD    B,L
            4C 114  LD   C,H            4D 115  LD    C,L
            54 124  LD   D,H            55 125  LD    D,L
            5C 134  LD   E,H            5D 135  LD    E,L
            64 144  LD   H,H            65 145  LD    H,L
            6C 154  LD   L,H            6D 155  LD    L,L
            74 164  LD   (HL),H         75 165  LD    (HL),L
            7C 174  LD   A,H            7D 175  LD    A,L

            46 106  LD   B,(HL)         47 107  LD    B,A
            4E 116  LD   C,(HL)         4F 117  LD    C,A
            56 126  LD   D,(HL)         57 127  LD    D,A
            5E 136  LD   E,(HL)         5F 137  LD    E,A
            66 146  LD   H,(HL)         67 147  LD    H,A
            6E 156  LD   L,(HL)         6F 157  LD    L,A
            76 166  HALT                77 167  LD    (HL),A
            7E 176  LD   A,(HL)         7F 177  LD    A,A



                            Table III
               Z-80 Instructions from 80 through BF
                   8-Bit Arithmetic and Logic

General form:
       OCT        OP       AD
       2(op3)(r)  OP(op3) [A,]REG(r)
The [A,] field is used with ADD, ADC and SBC to avoid ambiguity with other
instructions.  For the operation codes OP(op3) and the 8-bit register codes
see Table VI.

           HEX OCT  OP   AD            HEX OCT  OP    AD
            80 200  ADD  A,B            81 201  ADD   A,C
            88 210  ADC  A,B            89 211  ADC   A,C
            90 220  SUB  B              91 221  SUB   C
            98 230  SBC  A,B            99 231  SBC   A,C
            A0 240  AND  B              A1 241  AND   C
            A8 250  XOR  B              A9 251  XOR   C
            B0 260  OR   B              B1 261  OR    C
            B8 270  CP   B              B9 271  CP    C

            82 202  ADD  A,D            83 203  ADD   A,E
            8A 212  ADC  A,D            8B 213  ADC   A,E
            92 222  SUB  D              93 223  SUB   E
            9A 232  SBC  A,D            9B 233  SBC   A,E
            A2 242  AND  D              A3 243  AND   E
            AA 252  XOR  D              AB 253  XOR   E
            B2 262  OR   D              B3 263  OR    E
            BA 272  CP   D              BB 273  CP    E

            84 204  ADD  A,H            85 205  ADD   A,L
            8C 214  ADC  A,H            8D 215  ADC   A,L
            94 224  SUB  H              95 225  SUB   L
            9C 234  SBC  A,H            9D 235  SBC   A,L
            A4 244  AND  H              A5 245  AND   L
            AC 254  XOR  H              AD 255  XOR   L
            B4 264  OR   H              B5 265  OR    L
            BC 274  CP   H              BD 275  CP    L

            86 206  ADD  A,(HL)         87 207  ADD   A,A
            8E 216  ADC  A,(HL)         8F 217  ADC   A,A
            96 226  SUB  (HL)           97 227  SUB   A
            9E 236  SBC  A,(HL)         9F 237  SBC   A,A
            A6 246  AND  (HL)           A7 247  AND   A
            AE 256  XOR  (HL)           AF 257  XOR   A
            B6 266  OR   (HL)           B7 267  OR    A
            BE 276  CP   (HL)           BF 277  CP    A



                            Table IV
                Z-80 Instructions from C0 through FF

           HEX OCT  OP   AD            HEX OCT  OP    AD
            C0 300  RET  NZ             C1 301  POP   BC
            C8 310  RET  Z              C9 311  RET
            D0 320  RET  NC             D1 321  POP   DE
            D8 330  RET  C            * D9 331  EXX
            E0 340  RET  PO             E1 341  POP   HL
            E8 350  RET  PE             E9 351  JP    (HL)
            F0 360  RET  P              F1 361  POP   AF
            F8 370  RET  M              F9 371  LD    SP,HL

            C2 302  JP   NZ,nn          C3 303  JP    nn
            CA 312  JP   Z,nn         * CB 313  (See notes)
            D2 322  JP   NC,nn          D3 323  OUT   n,A
            DA 332  JP   C,nn           DB 333  IN    A,n
            E2 342  JP   PO,nn          E3 343  EX    (SP),HL
            EA 352  JP   PE,nn          EB 353  EX    DE,HL
            F2 362  JP   P,nn           F3 363  DI
            FA 372  JP   M,nn           FB 373  EI

            C4 304  CALL NZ,nn          C5 305  PUSH  BC
            CC 314  CALL Z,nn           CD 315  CALL  nn
            D4 324  CALL NC,nn          D5 325  PUSH  DE
            DC 334  CALL C,nn         * DD 335  (See notes)
            E4 344  CALL PO,nn          E5 345  PUSH  HL
            EC 354  CALL PE,nn        * ED 355  (See notes)
            F4 364  CALL P,nn           F5 365  PUSH  AF
            FC 374  CALL M,nn         * FD 375  (See notes)

            C6 306  ADD  A,n            C7 307  RST   00H
            CE 316  ADC  A,n            CF 317  RST   08H
            D6 326  SUB  n              D7 327  RST   10H
            DE 336  SBC  A,n            DF 337  RST   18H
            E6 346  AND  n              E7 347  RST   20H
            EE 356  XOR  n              EF 357  RST   28H
            F6 366  OR   n              F7 367  RST   30H
            FE 376  CP   n              FF 377  RST   38H



                            Table V
           Extended Z-80 Instructions Prefixed by ED
                    Listed by Second Byte

           HEX OCT  OP   AD            HEX OCT  OP    AD

            40 100  IN   B,(C)          41 101  OUT   (C),B
            48 110  IN   C,(C)          49 111  OUT   (C),C
            50 120  IN   D,(C)          51 121  OUT   (C),D
            58 130  IN   E,(C)          59 131  OUT   (C),E
            60 140  IN   H,(C)          61 141  OUT   (C),H
            68 150  IN   L,(C)          69 151  OUT   (C),L
            70 160  (NONE)              71 161  (NONE)
            78 170  IN   A,(C)          79 171  OUT   (C),A

            42 102  SBC  HL,BC          43 103  LD    (nn),BC
            4A 112  ADC  HL,BC          4B 113  LD    BC,(nn)
            52 122  SBC  HL,DE          53 123  LD    (nn),DE
            5A 132  ADC  HL,DE          5B 133  LD    DE,(nn)
            62 142  SBC  HL,HL          63 143  (NONE, see 22H)
            6A 152  ADC  HL,HL          6B 153  (NONE, see 2AH)
            72 162  SBC  HL,SP          73 163  LD    (nn),SP
            7A 172  ADC  HL,SP          7B 173  LD    SP,(nn)

            44 104  NEG                 45 105  RETN
            4C 114  (NONE)              4D 115  RETI

            46 106  IM   0              47 107  LD    I,A
            4E 116  (NONE)              4F 117  LD    R,A
            56 126  IM   1              57 127  LD    A,I
            5E 136  IM   2              5F 137  LD    A,R
            66 146  (NONE)              67 147  RRD
            6E 156  (NONE)              6F 157  RLD

            A0 240  LDI                 A1 241  CPI
            A8 250  LDD                 A9 251  CPD
            B0 260  LDIR                B1 261  CPIR
            B8 270  LDDR                B9 271  CPDR

            A2 242  INI                 A3 243  OUTI
            AA 252  IND                 AB 253  OUTD
            B2 262  INIR                B3 263  OTIR
            BA 272  INDR                BB 273  OTDR



                             Table VI
              Extended Z-80 Instructions Prefixed by CB
                       Listed by Second Byte

       OCT          OP    AD            p  OP(p)
       0(p)(r)      OP(p) REG(r)        0  RLC
       1(n)(r)      BIT   n,REG(r)      1  RRC
       2(n)(r)      RES   n,REG(r)      2  RL
       3(n)(r)      SET   n,REG(r)      3  RR
                                        4  SLA
                                        5  SRA
                                        6  SLO (See notes)
                                        7  SRL

Other octal fields common in Z80 instructions

8-Bit Registers:
  r      0   1   2   3   4   5   6    7
REG(r)   B   C   D   E   H   L  (HL)  A

16 Bit Registers:
  R     0   1   2   3
REG(R) BC  DE  HL  SP

Operations (see Table I):
 op1     0    1      2     3      4    5    6    7
OP(op1) JR  LD/ADD  LD  INC/DEC  INC  DEC  LD   rotate
OP(1) and OP(3) are 16-bit instructions, OP(6) are the immediate loads.
OP(2) is 4 8-bit indexed memory, 2 16-bit and 2 8-bit memeory loads.
OP(7) includes 4 rotates of A, DAA, CPL, SCF and CCF.

Operations (see Table III):
 op3     0    1    2    3    4    5    6    7
OP(op3) ADD  ADC  SUB  SBC  AND  XOR   OR   CP

Operations (see Table IV):
 op4     0         1        2         3        4          5     6    7
OP(op4) RET CN(c) ---  JP CN(c),nn   ---  CALL CN(c),nn  PUSH  op3  RST
OP(5) includes the unconditional CALL plus the prefixes DD, FD, and ED
OP(6) is the immediate 8-bit arithmetic and logical operations ADD A,n etc.

Conditions for JR, JP, CALL, RET
 c     0   1   2   3   4   5   6   7
CN(c) NZ   Z  NC   C  PO  PE   P   M
JR implements only the first four




Notes:

(1)  Instructions in the Z80 but not in the 8080 instruction set are marked
     with an asterisk preceeding the hex instruction in Tables I through IV.
     None of the instructions in Tables V and VI are in the 8080 instruction
     set.  None of the instructions involving the auxiliary index registers
     IX and IY are in the 8080 instruction set.

(2)  The byte CB indicates the first byte of the extended Z80 instructions
     given in Table V.

(3)  The bytes DD and FD are used to prefix instructions using the
     auxiliary index registers IX and IY.  In single-byte instructions,
     using memory location (HL), the memory location pointed to m, where
     m is (IX+d) or (IY+d), may be substituted for (HL) by prefixing the
     instruction by DD or FD, respectively, and spcifying (HL) as the
     source or destination in the instruction format.  The instruction is
     followed by d when this is done and the resulting instruction is
     3 bytes long.

(4)  The byte ED indicates the first byte of the extended Z80 instructions
     given in Table VI.

(5)  Prefixing single-byte 8-bit instructions involving registers H and L
     by DD (for IX) or FD (for IY) results in use of XH, XL, YH or YL
     instead.  This usage is undocumented and works only on Zilog Z80's
     and second-sources which use Zilog masks.  XH, XL, YH and YL refer to
     the high-order bytes of IX and IY, respectively.  ALDS supports these
     instructions.

(6)  The SLO operation in Table V is undocumented and is not well defined.

(7)  All the instructions in Table V can be extended to undocumented Zilog
     Z80 instructions:  These instructions, which use (IX+d) and (IY+d) as
     the source and destination as well as load the result in r, result
     when the (IX+d) or (IY+d) format is used and registers other than
     (HL) are specified.  The resulting instrucions are 4 bytes long.  ALDS
     supports these instructions using the format [OP]LD r,m where m is
     (IX+d) or (IY+d).  The timing is the same as [OP] m.
						

ROM Calls - Bob Alger (10/27/83)
ROMCALLS is a quick reference to the more common ROM & DOS subroutines, excluding cassette I/O and floating point math. These routines have been assembled from many other publications. Also note that all addresses are in hex except the PEEK/POKE section which is in decimal.
ROM RST VECTORS:

RST     Jump    Contents Purpose
0       none    Re-boot- power on or RESET
8       4000    JP 1C96  If (HL) = ((SP))- do RST10H logic, else print SN error
10      4003    JP 1D78  Find next non-blank character in a string
18      4006    JP 1C90  DE compared to HL.  Z set if DE = HL, C set if DE > HL
20      4009    JP 25D9  Test NTF flag at 40AF.  Z flag set if string, M if
                integer, P&C if single, P&NC if double, A=NTF - 3.
28      400C    RET      BREAK key vector.  you can put your own 3 byte
                instruction here to jump to your own routine.
                NOP
                NOP
30      400F    RET      Used by DOS
                NOP
                NOP
38      4012    EI       Used by DOS
                RET
                NOP
						

MEMORY MAPPED I/O DEVICES
Address
3000-37DD
37E0
27E4
37E8
37E8
37EC
37EC
37ED
37EE
37EF
3801-3880
3C00-3FFF
Use
NO MEMORY here at all
Disk drive select latch
Cassette drive latch
Line printer data port when storing
Line printer status port when loading
Disk command register when storing
Disk status register when loading
Disk track register
Disk sector register
Disk data register
Keyboard memory
Video display memory

ROM ROUTINES (I/O & MISC.)

Address         Use
0013            Inputs a byte from an input device.
                call:   LD      DE,nnnn ;address of DCB
                        CALL    0013H   ;get byte
                        JP      NZ,NRDY ;input dev not ready

001B            Outputs a byte to an output device.
                call:   LD      DE,nnnn ;address of DCB
                        CALL    001BH   ;put byte
                        JP      NZ,NRDY ;output dev not ready

002B            INKEY subroutine- scans keyboard.  The data is not echoed on
                your screen.  Note that calling 0358H instead will eliminate
                need to save DE.

                call:   PUSH    DE      ;save
                        CALL    002BH   ;scan keyboard
                        POP     DE      ;restore
                        JP      Z,NOKEY ;no key pressed
                        ;key is now in A

0033            DISPLAY subroutine- prints character in A at current cursor
               position on video display.  Cursor position is stored at
               4020-4021.  Note that calling 033AH instead will eliminate
               need to save DE.

               call:    PUSH    DE        ;save
                        LD      HL,nnnn   ;* optionally position cursor
                        LD      (4020H),HL;*   before displaying byte
                        CALL    0033H     ;dislay character
                        POP     DE        ;restore

003B           LPRINT subroutine- prints character in A on line printer.
               Note that calling 039CH instead will eliminate need to save DE.
               call:   PUSH    DE      ;save
                       CALL    003BH   ;print character
                       PNP     DE      ;restore
                       JP      NZ,NRDY ;printer not ready

0049           INPUT subroutine- scans keyboard and waits for key to be
               pressed.  Note that calling 0384H instead will eliminate need
               to save DE.

               call:   PUSH    DE      ;save
                       CALL    0049H   ;wait for key
                       POP     DE      ;restore
                       ;key is now in A

0060           Delay loop in 14.66 microsecond increments.  A value of 0 will
               be equal to .96 seconds.

               call:   PUSH    AF      ;save
                       LD      BC,nnnn ;number of delays
                       CALL    0060H   ;delay a little
                       POP     AF      ;restore

0066           NMI vector.  Jumps here on non-maskable interrupt (ie.
               HALT or press of RESET button). Note- see 41BE.

0150           SET, RESET, POINT graphics functions.  You must make sure
               that the coordinates are within legal range.
               call:   LD      B,nn    ;x coordinate (0-127)
                       LD      A,nn    ;y coordinate (0-47)
                       LD      H,nn    ;POINT=00, RET=80H, RESET=01
                       CALL    GRAPH   ;B, A, & HL will be destroyed
                       LD     A,(4121H);*if POINT was done
                       NR      A       ;*
                       JP      Z,OFF   ;* the point was off
                       JP      ON      ;* the point was on
                       .
                       .
                       .
               GRAPH   PUSH    HL      ;push indicator
                       PUSH    BC      ;push x coordinate
                       LD      HL,DUMMY;fake out BASIC's RST8
                       JP      0150H   ;go do the selected function
               DUMMY   DEFM    ');'    ;make believe this is a BASIC program

01C9           CLS subroutine- homes cursor and clears screen.
               call:   PUSH    AF      ;save
                       CALL    01C9H   ;cls
                       POP     AF      ;restore

02B2           SYSTEM command- prints "*?" and waits for entry.  When
               using the SYSTEM command, if your program machine language
               program has an ORG for 41BEH with a 3 byte instruction
               following, then that 3 byte instruction will be automaticly
               executed after your tape is finished loading.  For example-

                       ORG     41BEH
                       JP      7000H
                       ORG     7000H
               START   .               ;first instruction of your program
                       .
                       .
                       END     START

05D9           LINE INPUT subroutine- accepts a line of keyboard input
               terminated by ENTER or BREAK.  Echoes characters typed
               and recognizes control functions (backspace, shift-backspace,
               etc.).  None of these special characters ever get put into
               your buffer.

               call:   PUSH    DE      ;save
                       LD      B,nn    ;maximum characters allowed to input
                       LD      HL,nnnn ;address of buffer to store characters
               in
                       CALL    05D9H   ;get a line of input
                       POP     DE      ;restore
                       JP      C,BRK   ;BREAK was hit
                       ;B= number of characters typed including
               terminator
                       ;C= original contents of B

06CC           Ref 1A19.

0A7F           Used to pass a 06-bit value to a machine language
               program.
               call:   CALL    0A7FH   ;get value from BASIC
                       ;value now in HL

0A9A           Used to pass a 16-bit value back to BASIC.
               call:   LD      HL,nnnn ;get value to give BASIC
                       JP      0A9AH
                       ;at this point you are back in BASIC with the value.

1A19           Normal entry point for a READY in Level II or Disk BASIC.
               Note that it is better to jump to 06CCH because it does
               not cause an OM error on the first command that follows.

1BB2           Prints "?", inputs up to 241 characters from the keyboard
               and echoes characters typed.  Data goes into BASIC's input
               buffer.  0361H is the same as 1BB3H, less the prompt.
               call:   PUSH    AF      ;save
                       PUSH    DE
                       CALL    1BB3H   ;get input
                       POP     DE      ;restore
                       POP     AF
                       ;HL= points to 1st character minus 1

1D78           (RST10H) Finds next non-blank character in a sting.  It
               increments through string, ignoring spaces and control
               characters 9 & 10 (enters) and returns when the next
               non-blank character is encountered.

               call:    LD      HL,nnnn ;starting address of string minus 1
                        CALL    1D78H   ;search string
                        ;A= non-blank character found
                        JP      Z,END   ;encountered a 00 byte (end of line)
               or ":" (end of statement)
                        JP      C,NBR   ;got an ASCII numeric digit
                        JP      ALPHA   ;not a numeric digit

1E5A           ASCII integer decimal to HEX converter.
               call:    LD      HL,nnnn ;address of ASCII decimal number
                        CALL    1E5AH   ;translate to HEX
                        ;DE= HEX result
                        ;HL= points to first non-decimal character

260D           Point to the VARPTR of a variable.  If the variable
               doesn't exist then create it first.
               call:    LD      HL,nnnn ;point to ASCII variable name
                        CALL    260DH   ;look for/create it
                        ;DE= points to VARPTR of the variable

28A7           PRINT subroutine- prints a string of text on the video
               display, terminated by ENTER (13) or NULL (00), at current
               cursor position.

               call:    PUSH    DE      ;save
                        PUSH    IY
                        LD      HL,nnnn ;address of text
                        CALL    28A7H   ;display text
                        POP     IY      ;restore
                        POP     DE
						

ROM ROUTINES (INTEGER MATH)

               The following integer math routines make use ACC to contain
               the result of the operation.  ACC is 2 locations in
               memory at 4121 & 4122 (LSB,MSB).  The number type flag (NTF)
               at 40AF must also be set to 02 to indicate integer.

Address        Use
0BD2           Add     - ACC < DE + HL
0BC7           Subtract- ACC = DE - HL
0BF2           Multiply- ACC = DE * HL
2490           Divide  - @BC = DE / HL

               Note that on integer overflow +, -, & * return a single
               precision floating point number in ACC at 4121-4124
               (LSB,LSB,MSB,EXPonent).  Also, / always returns a single
               precision floating point number.  In all cases you should
               check NTF for the type of the result (single= 4).

               Integers are stored in twos compliment form.  Single
               precision floating point numbers are stored as a normalized
               binary fraction, with an assumed decimal point before the most
               significant bit.  Since the msb is always a 1, the most
               significant bit also doubles as the sign bit by making it a 0
               for positive and 1 for negative.  The binary exponent is
               stored in excess 128 form; that is, 128 is added to the
               actual binary exponent needed.  The number 0 is stored as a
               zero mantissa and exponent.  A couple of examples are
               shown below:

Decimal         4121    4122    4123    4124
-------         ----    ----    ----    ----
   0.5          00      00      00      80
   1.0          00      00      00      81
  -1.0          00      00      80      81
 129.0          00      00      01      88
-129.0          00      00      81      88
 257.0          00      80      00      89


----- Arithmetic Accumulator (411D-4124) -----
        Integer         Single          Double
411D                                    LSB
411E                                    LSB
411F                                    LSB
4120                                    LSB
4121    LSB             LSB             LSB
4122    MSB             LSB             LSB
4123                    MSB             MSB
4124                    EXP             EXP


--- Hex Arithmetic Accululator (4127-412E) ---
        Integer         Single          Double
4127    LSB             LSB             LSB
4128    MSB             LSB             LSB
4129                    MSB             LSB
412A                    EXP             LSB
412B                                    LSB
412C                                    LSB
412D                                    MSB
412E                                    EXP
						

DOS ROUTINES

Address        Use
402D           EXIT is the normal program exit back to DOS.
               call:    JP      402DH

4030           ABORT is the exit back to DOS after an unsuccessful
               program exit.
               call:    JP      4030H

4400           CMD is a routine that accepts a new command to be evaluated.
               call:    CALL    4400H

4405           CMNDI is the entry into the command interpreter.
               call:    ;the following 3 lines are necessary only if this is
               called at the  end  of ` BASIC program
                        LD      HL,402D   ;DOS return address
                        LD      (41FAH),HL
                        LD      SP,41FAH  ;reset stack pointer for DOS use

                        ;your ASCII DOS command should be in the command buffer
                        terminated by a carriage return
                        LD      HL,4318H  ;DOS command buffer
                        JP      4405H     ;if from BASIC
                        CALL    4405H     ;else this way

440D           DEBUG is the entry into the debugging package
               call:    JP      440DH

441C           FSPEC fetches a file specification in TRSDOS standard format.
               call:    CALL    441CH

4420           INIT creates a new file in the directory and opens the DCB
               for this file.  If the filespec name is found then the file
               is simply opened for use, else a new file is created first.
               call:    LD      HL,BUFFER
                        LD      DE,DCB
                        LD      B,LRL
                        CALL    4420H
                        JP      Z,OK      ;no error
                        JP      C,NEWFIL  ;no error, but new file was created
                        ;A= TRSDOS error code

4424           OPEN opens the DCB of an existing file.
               call:    LD      HL,BUFFER
                        LD      DE,DCB
                        LD      B,LRL
                        CALL    4424H
                        JP      Z,OK      ;no error
                        JP      NZ,NOFILE ;file does not exist
                        ;A= TRSDOS error code

4428           CLOSE updates the directory and then closes the file from any
               more processing.
               call:    LD      DE,DCB
                        CALL    4428H
                        JP      Z,OK     ;no error
                        ;A= TRSDOS error code

442C           KILL deletes the directory for an open file and then closes the
               DCB.
               call:    LD      DE,DCB
                        CALL    442CH
                        JP      Z,OK     ;no error
                        ;A= TRSDOS error code

4430           LOAD loads a program file.
               call:    CALL    4430H

4433           RUN loads and executes a program file.
               call:    JP      4433H

4436           READ transfers one logical or physical disk record to
               memory.  See TRSDOS Technical Infromation for complete
               definition.
               call:    LD      HL,UREC
                        LD      DE,DCB
                        CALL    4436H
                        JP      Z,OK      ;no error
                        A= TRSDOS error code (EOF=1CH or 1DH)

4439           WRITE transfers one logical or physical disk record from
               memory.  See TRSDOS Technical Information for complete
               definition.
               call:    LD      HL,UREC
                        LD      DE,DCB
                        CALL    4439H
                        JP      Z,OK      ;no error
                        A= TRSDOS error code

443C           VERF is the same as WRITE except that it vdrifies what
               was written to disk.
               call:    LD      HL,UREC
                        LD      DE,DCB
                        CALL    443C
                        BP      Z,OK      ;no error
                        A= TRSDOS error code

4442           POSN positions a file to READ or WRITE a randomly
               selected logical record.
               call:    LD      DE,DCB
                        LD      BC,nnnn   ;logical record # to position for
                        CALL    4442H
                        JP      Z,OK      ;no error
                        ;A= TRSDOS errnr code

446D           TIME will return the current time in ASCII.
               call:    LD      HL,nnnn   ;address of 8 byte buffer
                        CALL    446DH     ;put time in buffer

4470           DATE will return the current date in ASCII.
               call:    LD      HL,nnnn   ;address of 8 byte buffer
                        CALL    4470H     ;put date in buffer

4AC1           This routine will read sectors 2 - 9 of the disk directory
               track (11H) into your designated buffer.  It is just like the
               DOS routine at 5CC8 which is overlayed by BASIC/CMD.
               ( not for Newdos 80)
               call:    LD      B,0
                        LD      DE,BUFFER ;256*8 bytds
               READ     CALL    4AC1H     ;read sector
                        LD      L,0
                        PUSH    BC
                        LD      BB,256
                        LDIR
                        POP     BC
                        INC     B
                        LD      A,B
                        CP      8
                        JR      NZ,READ
                        RET
						

LEVEL II/DOS RAM MAP

4001-4014      Jump vectors for RST 8 - RST 56
4015-401C      Keyboard Device Control Block (DCB)
401D-4024      Video display DCB
4025-402C      Line printer DCB
4036-403C      Work area for keyboard input routine
403D           Print size flag: 0=64 char., 8=32 char.
403E           OSVER$- DOS version #
4040           25 millisecond clock count
4041-4043      TIME$, time of day: seconds, minutes, hours
4044-4046      DATE$- day of year: year, day, month
4049-404A      HIFH$- highest unused RAM address (DOS)
408E-408F      (L2 only) Entry point to USR routines
4093-4098      Input and output port routines
4099           INKEY$ storage of key pressed
409A           Error code for RESUME
409B           Printer carriage position
409C           Device type flag: -1=tape, 0=video,  1=line printer
409D           Used by PRINT#
40A0-40A1      Pointer to lowest address available for string storage
40A2-40A3      program line number counter (current line # being
               processed)
40A4-40A5      Start of BASIC program pointer.  Normal values for: (L2)=42E9;
               (Disk BASIC)=varies with version of  DOS/BASIC.
40A6           Line cursor position, used for TAB
40A7-40A8      Input buffer pointer
40AA-40AC      Seed for RND
40AF           Number type flag (NTF): 2=int, 3=stng, 4=sngl, 8=dbl
40B1-40B2      Pointer to highest address available for string storage
               (set by MEMORY SIZE).  Protected memory, if any, follows.
40B3-40B4      String work area pointer
40B5-40D5      String work area
40D6-40D7      Pointer to next byte of string storage
40D8-40D9      Present byte count pointer
40DA-40DB      Last DATA,READ line #
40DC           Used by DIM
40DE           Used by PRINT USING
40DF-40E0      Entry point storage for SYSTEM tapes (accessed by "/"
               command)
40E1           AUTO flag (0=off)
40E2-40E3      Current line #
40E4           AUTO increment size
40E6-40E7      Encoded statement pointer
40E8-40E9      Stack pointer pointer
40EA           Used during RESUME
40EC-40ED      EDIT line #
40EE           Used during RESUME
40F0-40F1      ON ERROR location for ON ERROR GOTO
40F5-40F6      Last line # executed prior to a BREAK
40F7-40F8      Last statement byte counter for CONTINUE retrieval
40F9-40FA      Start simple variables pointer (top of BASIC program plus
               1)
40FB-40FC      Start of arrays pointer (end of simple variables)
40FD-40FE      Start of free space pointer (end of arrays)
40FF-4100      DATA pointer
4101-411B      Variable type declaration table for each letter: 2=int,
               3=stng, 4=sngl, 8=dbl
411B           TRON flag: 0=off (TROFF), 175=on (TRON)
411D-4124      Arithmetic accumulator
4127-412E      Hex arithmetic accumulator
4130-4131      Line # work area pointer
4152-41A6      DOS entry points
41BE-41C0      (L2 only( Jumps here on RESET button hit.  You can put your
               own 3 byte instrtction here to jump to your own routine.
41E8-42E8      Input buffer area
               (stack pointer for system is at 4288 )
4200-51FF      TRSDOS
42E9           Start of user RAM for program storage
4318-4357      DOS command buffer- Last DOS command entered (64 chars.).
4500-4517      DOS interrupt table contains address pairs for interrupt
               routines (ie. CLOCK, TRACE, etc.).  You can place your own
               routine addresses in this table.  An example is below:
                        DI                ;disable interrupts
                        LD      HL,4510H  ;address of table link
                        LD      (HL),MYROUT ;address of my interrupt
               routine
                        EI                ;enable interrupts
5200-6FFF      Disk BASIC or DOS utilities when loaded, or user memory
57F0           61 character ASCII copyright notice (DOS)
						

DISK BASIC COMMAND VECTORS
Address Command
4152 CVI
4155 FN*
4158 CVS
415B DEF
415E CVD
4161 EOF
4164 LOC
4167 LOF
416A MKI$
416D MKS$
4170 MKD$
4173 CMD
4176 TIME$*
4179 OPEN
417C FIELD
417F GET
4182 PUT
4185 CLOSE
4188 LOAD
418B MERGE
418E NAME
4191 KILL
4194 &*
4197 LSET
419A RSET
419D INSTR*
41A0 SAVE
41A3 LINE
* Items marked with an asterisk are called during expression evaluation.

TRS-80 MODEL 1/3 KEYBOARD PEEK TABLE

                      ----- Decimal Contents ----,
Address   1     2     4     8     16     32     64     128    Hex Address
------- ----- ---,- ----- ----- -----  -----  -----   -----   -----------
14337     @     A     B     C      D      E      F      G        3801       1
14338     H     I     J     K      L      M      N      O        3802       2
14340     P     Q     R     S      T      U      V      W        3804       4
14344     X     Y     Z     ,      -      -      -      -        3808       8
14352     0     1     2     3      4      5      6      7        3810      16
14368     8     9    *:    +;     <,     =-     >.     ?/        3820      32
14400  enter  clear break  up    down   left  right  space       3840      64
14464  shift    -     -     -  control    -      -      -        3880     128
---,--- ----- ----- ----- ----- -----  -----  -----   -----           ------,--
          0     2      4    8     10     20     40      80             14336
                      -----   Hex Contents   -----


Notes on the table:

1.  Blank areas ("-") of the table are not used on the standard TRS-80.
2.  The control key at location 14464 is used by the ELECTRIC PENCIL.
3.  The break key can not be used in BASIC programs, but can be checked in
machine language programs.
4.  In BASIC use  -  variable = PEEK(address)
      ie:    IF PEEK(14400)=8 THEN SET(X+1,Y)  ' up arrow key was pressed
5.  In machine language you can use- LD A,(3840H) ;08H = up arrow
6.  If two or more keys are pressed at the same time you will get the sum of
the keys.
7.  You can also combine more than one address.  Note the right-hand column
of numbers.  If you total this number with other row numbers you want to
address, and add 14436, you will get the final decimal address to PEEK.
8   In BASIC a better way to use this table, than described in 4 above, might
be to
    PEEK(address) AND (value to check)  -  This will recognize a key as being
pressed
    even when other keys are being held down.



Try running this small program and hold down more than one ARROW key at the
same time.


                 5 DEFINT A
                10 A = PEEK(14400)
                20 IF (A AND 8 ) THEN PRINT "UP ":
                30 IF (A AND 16) THEN PRINT "DOWN ";
                40 IF (A AND 32) THEN PRINT "LEFT ";
                50 IF (A AND 64) THEN PRINT "RIGHT ";
                60 IF (A AND 255)THEN PRINT
                70 GOTO 10
						

DISK SPEEDUP CHART

----------I-------------------------------
          I       Delay in miliseconds
Command   I     40      20      10      05
----------I-----------------,,------------
RESTORE   I     0B      0A      09      08
----------I-------------------------------
SEEK      I     1B      1A      19      08
----------I-------------------------------



Program   I     DOS     Trk. Sec.  Byte  Org.  Ndw   Command
----------I-------------------------------------------,-----
BOOT/SYS  I     ALL*    0    0     B9    361B  3618  SEEK    (except NEWDOS 80)
          I     NEWDOS  0    0     6A    361B  3618  SEEK    (only   NEWDOS 80)
          I     80.1    0    0     A5    360B  3608  RESTORE  "       "     "
------,--------------------------------------------,--------
          I     TRSDOS  0    7     51    3E1B  3E18  SEEK
          I     (ALL)   0    7     C4    3E0B  3E08  RESTORE
          I     ----------,---------------------------------
          I     NEWDOS  0    7     0E    3E0B  3E08  RESTORE
SYS0/SYS  I      2.1    0    9     0E    3E1B  3E18  SEEK
          H     -------------------------------------,------
          I     NEWDOS  0    8     CC    3E0B  3E08  RESTORE
          I     80.1    0    8     FD    3E1B  3E18  SEEK
          I     --,-----------------------------------------
          I     VTOS    0    7     15    3E1B  3E18  SEEK
          I      3.0    0    7     90    3E0B  3E08  RESTORE
----------I----------------------------------,---------,----

Note:   The values under the "new" column are for 5 milisecond operation.
        For 20 ms. change 18 to 1A, 08 to 0A.

        - older Shugarts & some newer ones use 40 ms.
        - some newer Shugarts can use 40 or 20 ms.
        - Micropolis uses 40 ms.
        - Pertecs can use 40 or 20 ms.
        - MPIs and Siemens can use 40, 20, 10, or 5 ms.
						

SYSTEM TAPE FORMAT

TAPE LEADER             256 zeroes followed by a A5 (sync byte)
55                      header byte indicating system format
xx xx xx xx xx xx       6 character file name in ASCII

        3C              data header
        xx              length of data 01-FFH, 00=256 bytes
        lsb,msb         load address
        xx ... xx       data (your program)
        xx              checksum of your data & load address

        .               repeat from 3C through checksum
        .
        .
78                      end of file marker
lsb,msb                 entry point address
						

EDITOR/ASSEMBLER SOURCE TAPE FORMAT

TAPE LEADER             256 zeroes followed by a A5 (sync byte)
D3                      header byte indicating source format
xx xx xx xx xx xx       6 character file name in ASCII

        xx xx xx xx xx  line # in ASCII with bit 7 set in each byte
        20              data header
        xx ... xx       source line (128 byte maximum)
        0D              end of line marker

        .
        .
        .

1A                      end of file marker
						

BASIC TAPE FORMAT

LEADER                  256 zeroes followed by an A5 (sync byte)
D3 D3 D3                BASIC header bytes
xx                      1 character file name in ASCII

        lsb,msb         address pointer to next line
        lsb,msb         line #
        xx ... xx       BASIC line (compressed)
        00              end of line marker

        .
        .
        .

00 00                   end of file markers
						

VIDTEX ESCAPE SEQUENCES - Neil Morrison
VIDTEX lets the host computer perform screen control functions through escape sequences. Remember that these are remote functions executed by the host and cannot be performed from the keyboard. The following table summarizes the screen control sequences and the functions they perform. Note the difference between lower and uppercase.
Escape Control Sequence Summary:
Sequence           Function
{ESC}{ESC}O Open RAM buffer
{ESC}{ESC}C Close RAM buffer
{ESC}{ESC}Z Zero RAM buffer
{ESC}A Cursor up
{ESC}B Cursor down
{ESC}C Cursor right
(ESC)D Cursor left
{ESC}G4 Semi-graphics 4 mode
{ESC}GN Text mode
{ESC}H Home cursor
{ESC}J Clear to end of page
{ESC}K Clear to end of line
{ESC}Y line col Position cursor
{ESC}b Lock keyboard
{ESC}c Unlock keyboard
(ESC}e Disable display
{ESC}f Enable display
{ESC}g Restart VIDTEX
{ESC}j Clear Page
{ESC}l Normal character width
{ESC}m Wide character width
{DC1} XON
{DC2} Printer on
{DC3} XOFF
{DC4} Printer off
Graphics Mode:
An {ESC}G4 is used by the host to specify semi-graphics 2 x 2 mode. These codes are used internally by the Videotex Plus software and cannot be generated from the keyboard. In this mode the parity bit is used to distinguish between graphic and ASCII characters. If the parity bit is zero, the character is a standard ASCII character. If the parity bit is one, the character is a graphics character.
Model II Videotex Plus does not support graphics or color. When graphics mode is required by the host. similar Model II graphics characters are substituted for the graphics codes. These are not true representations of Videotex’s standard graphics.

Cassette Recorder Levels - Neil Morrison
Recorder Model User-Generated Tapes Pre-Recorded
Radio Shack Tapes
Model I Model III Model I Model III
Level I Level II Level I Level II
CTR-40 Yellow Line Red Line Yellow Line Red Line
CTR-41 6-8 4-6 6.5-8.5 5-7
CTR-80 4.5-6.5 3-5 5-7 5.5-7.5 2.5-5 4-6
CTR-80A 4.5-6.5 3-5 5-7 5.5-7.5 2.5-5 4-6
CTR-81 4.5-6.5 3-5 5-7 5.5-7.5 2.5-5 4-6

Entry points to various Level II BASIC ROM routines
Entry points to various Level II BASIC ROM routines which may be accessed by user programs.

Keyboard routines

KBD1       2BH         INKEY$ CALL
KBD2       358H        SAVE DE REGS, THEN CALL 2B
KBWT1      49H         KBD INPUT WITH WAIT
KBWT2      384H        KBD INPUT WITH WAIT, DE SAVED
LINP1      5D9H        LINE INPUT ROUTINE
                        ENTER WITH:
                           HL => STORAGE ADDRESS
                           B  => MAX LENGTH TO INPUT
LINP2      361H        LINE INPUT ROUTINE 2
INPUT      1BB3H       SAME AS LINP2, BUT WITH "?"
LBUFF      40A7H       STORAGE BUFFER ADDRESS FOR LINP2

Display routines

DSP1       33H         Display byte at cursor pos
CLS        1C9H        Clear screen
BLINK      22CH        Blink "*" in right upper corner
DSP2       33AH        SAVES DE AND CALLS DSP1
DSTR       28A7H       DISPL STRING POINTED TO IN HL
SETRES     150H        ENTRY TO SET/RESET ROUTINES
CURSOR     4020H       CURSOR POSITION

Miscellaneous routines & addresses

BASIC      1A19H       RETURN POINT FOR BASIC
DOS        402DH       RETURN POINT FOR DOS
DOSERR     4030H       RETURN TO DOS WITH ERROR
CHLDE      1C90H       COMPARE HL WITH DE
FETCH      1D78        FETCH NEXT NON-BLANK CHARACTER
                        FOLLOWING THAT IN HL
DECBIN     1E5AH       DECIMAL # => BINARY
        RST 10H         INCREMENTS HL, LOADS (HL)=> A,
                        & SETS CARRY FLAG
WLDR       284H        WRITES LEADER ON CASSETTE TAPE
WBYTE      264H        WRITES ONE BYTE TO TAPE
COFF       1F8H        TURNS OFF CASSETTE MOTOR
RLDR       293H        READS SYNC BYTE FROM CASSETTE
RBYTE      235H        READS ONE BYTE FROM TAPE

Floating-point arithmetic routines

TYPE FLAG IS 40AFH; VALUES AS FOLLOWS:
        2 - INTEGER
        3 - STRING
        4 - SINGLE PRECISION FLOATING POINT
        8 - DOUBLE PRECISION FLOATING POINT

FLOATING POINT ACCUMULATORS (FPACC) AS FOLLOWS:
        INTEGER: 4121H - 4122H
        STRING:  4121H - 4122H HOLDS DESCRIPTOR ADDRESS
SINGLE PRECISION: 4121H - 4124H (4124 IS EXPONENT)
DOUBLE PRECISION: 411DH - 4124H (4124 IS EXPONENT)

OPERAND LOCATIONS AS FOLLOWS:
         INTEGER:  REGISTER PAIRS DE & HL
SINGLE PRECISION:  REGISTER PAIRS DE & HL
DOUBLE PRECISION:  4127H - 412EH

TSTYP      25D9H       TEST TYPE FLAG AT 40AF
DSTOR       9B4H        STORE SNG-PRC VAL IN DE:BC IN
                        FPACC
SLOAD       9C2H        LOAD SNG-PRC INTO DE:BC FROM
                        ADDRESS IN HL
SCOPY       9B1H        COPY SNG-PRC FROM HL ADDR TO
                        FPACC
SGET      9BFH        LOAD FPACC INTO DE:BC
SSTAK     9A4H        PUSH FPACC INTO STACK (DE BC)
ISTOR      0A9AH       STORE INT IN FPACC & SET TYPE
ASTOR      0E6CH       STORE NUMERIC STRING IN FPACC
NEDIT      0FBDH       NON-FORMATTED NUMERIC EDIT
FEDIT      0FBEH       FORMATTED NUMERIC EDIT
CSVEC      2865H       CREATE STRING VECTOR
FPACC      4121H       FLOATING POINT ACCUMULATOR
DFPACC     411DH       DOUBLE-PRECISION FPACC
DOPER      4127        DOUBLE-PRECISION OPERAND REGS

Arithmetic function routines

IADD       0BD2H       INTEGER ADD DE+HL =>FPACC
ISUB       0BC7H       INTEGER SUBTRACT DE-HL=>FPACC
IMUL       0BF2H       INTEGER MULTIPLY DE*HL=>FPACC
IDIV       2490H       INTEGER DIVIDE DE/HL =>FPACC
SADD       716H        SNGPRC ADD OPER+FPACC=>FPACC
SSUB       713H        SNG SUBTRACT OPER-FPACC=>FPACC
SMUL       847H        SNG MULTIPLY OPER*FPACC
SDIV       8A2H        SNG DIVIDE OPER/FPACC
DADD       0C77H       DBL PREC OPER+FPACC
DSUB       0C70H       DBL PREC SUBTRACT OPER-FPACC
DMUL       0DA1H       DBL PREC OPER*FPACC
DDIV       0DE5        DBL PREC OPER/FPACC
SGN        98AH        FPACC = SGN(FPACC)
INT        0B37H       FPACC = INT(FPACC)
ABS        977H        FPACC = ABS(FPACC)
SQRT       13E7H       FPACC = SQRT(FPACC)
RNDM       14C9        FPACC = RND(FPACC)
LOG        809H        FPACC = LOG(FPACC)
EXP        1439H       FPACC = EXP(FPACC)
COSN       1541H       FPACC = COS(FPACC)
SINE       1547H       FPACC = SIN(FPACC)
TAN        15A8H       FPACC = TAN(FPACC)
ATAN       15BDH       FPACC = ATAN(FPACC)
CINT       0A7FH       FPACC = CINT(FPACC)
CSNG       0AB1H       FPACC = CSNG(FPACC)
CDBL       0ADBH       FPACC = CDBL(FPACC)
FIX        0B26H       FPACC = FIX(FPACC)

DEC ADDR       HEX ADDR        FUNCTION
  14305           37E1          0, FOR BETTER DISK SAVES
  16405           4015          1 =KEYBOARD ON
                                2 =KEYBOARD OFF
  16413           401D          1 =DISPLAY OFF
                                7 =DISPLAY ON
  16414           401E          141 =DISPLAY TO PRINTER
                                88 =RESTORE DISPLAY
  16415           401F          5, 4 =???
  16449           4041          CLOCK REGISTER, SECONDS
  16450           4042          CLOCK REGISTER, MINUTES
  16451           4043          CLOCK REGISTER, HOURS
  16452           4044          CLOCK REGISTER, YEAR
  16453           4045          CLOCK REGISTER, DAY
  16454           4046          CLOCK REGISTER, MONTH
  16553           404F          255 =DATA READ AFTER CASS INP

  14312           37E8        >127 =LINEPRINTER NOT READY
  15339           3BFF         CHECK IF KEY HELD DOWN
  16457           4049  TOP-OF-MEMORY (DOS MAIN SYSTEM)
                              DISK BASIC HOLDS VALUE-1 IN
                               40B1.
                40A0-40A1 IS THE POINTER TO THE
                STRING STORAGE AREA (IE., IF YOU
                "CLEAR 50" THESE ADDRESSES WILL
                HOLD THE VALUE IN 40B1-40B2 MINUS
                50). ALWAYS STORED LSB/MSB.

KEYBOARD VALUES
                                VALUES
ADDR    1     2     4     8     16    32    64    128
15105    @     A     B     C      D     E     F     G
15106    H     I     J     K      L     M     N     O
15108    P     Q     R     S      T     U     V     W
15112    X     Y     Z
15120    0     1     2     3      4     5     6     7
15136    8     9     :     ;      ,     -          /
15168   ENTER  CLS   BRK    LF     LA     RA     SPACE
15232   SHIFT

 LF = LINEFEED   LA = LEFT ARROW   RA = RIGHT ARROW
 CLS = CLEAR KEY   BRK = BREAK
						

Model 4P boot mode key selection
Model 4P boot mode key selection (hold key till completed):

no keys pressed - boots in III mode if MODELA/III on disk 0
F1      pressed - boots from hard disk
F2      pressed - boots from floppy disk
F3      pressed - boots in III mode if MODELA/III on disk
L       pressed - re-load ROM image (in case of damage)
N       pressed - boots TRSDOS 6.x (not III's 1.3)
P       pressed - prompts to switch disks after loading III ROM
        (press  to run III Basic or  to load & run a DOS
V       pressed - prints ROM version on screen
.       pressed - performs dynamic RAM test until  is presed
  - boots from RS232. Acts like Network III Boot ROM
						

Model 4P Modem Commands
Commands:
      * Opens modem for programming.
      A Switches modem to the answer mode.
      @ Stand by to receive a new Abort code.
      C Clears (resets) modem memory.
      D Clears current telephone number from memory. Must precede any new telephone number.
      E Toggle the Echo enable switch.
      F Fast Rotary or Tone dialing (20 pps.)
      G Toggle forced carrier detect switch.
      L Transmits (displays) current contents of modem memory to the computer (terminal).
      M Toggles the Manual/Automatic switch.
      O Switches the modem to the Originate mode.
      P Inserts a 3 second pause in dialing sequence.
      Q Puts modem into LOCal Test Mode.
      R Rotary dialing (default value).
      S Slow Rotary or Tone dialing (10 pps.) (default value).
      T Tone dialing (10 digits per second).
      X Executes current program (dials phone number in memory, goes into Self-Test mode, waits for telephone to ring while in answer mode).
      BKSP   Erase the last code entered when programming dialing information.
      , Insert a user space when programming dialing information.
Examples
      To see the menu (or list) of the modem you type: *L in the terminal program such as COMM/CMD, XT4/CMD, etc.
To program it in order to call 555-3595, you would do the following on one line:
**C**MOGFDR652-3595;
     C clears modem
     M changes to automatic
     O is for originate
     G disables forced carrier detect
     F is for Fast dialing
     D is for dialing
     R is for Rotary
Now if you typed the modem will respond with:
     MODE=A
     TYPE=O
     F CD=N
     TEST=N
     NUMB=R652-3595
     RATE=F
     EXIT=14
then you would type to execute the above commands and dial the number.

Ports (Model I)

EBH:  Serial Port
     IN                            OUT
     (Input Data)                  (Output Data)
B7:  Data-7                        Data-7
B6:  Data-6                        Data-6
B5:  Data-5                        Data-5
B4:  Data-4                        Data-4
B3:  Data-3                        Data-3
B2:  Data-2                        Data-2
B1:  Data-1                        Data-1
B0:  Data-0                        Data-0


EAH:  Serial Port
     IN                            OUT
     (Uart Status bits)            (Uart parameters set)
B7:  1=Data Available              1=Even Parity
B6:  0=Data sent (TBMT)            WD Lngth 00=5 01=7
B5:  1=Overrun Error               WD Lngth 10=6 11=8
B4:  1=Framing Error               0=1-Stop bit
B3:  1=Parity Error                1=No Parity
B2:  unused                        1=Transmit Enable
B1:  unused                        0=DTR on
B0:  unused                        0=RTS on


E9H:  Serial Port
     IN                            OUT
     (DIP Switches??)              (Set speeds)
B7:  Parity 0=Odd                   Set Baud rate (all bits)
B6:  Wd Length 00=5 01=7            110 = 22H   150 = 44H
B5:            10=6 11=8            300 = 55H   600 = 66H
B4:  Stop bits 0=1 1=2             1200 = 77H  2400 = AAH
B3:  Parity 0=enable               4800 = 66H  9600 = EEH
B2:  unused                        Bits 0-3 = Receive Speed
B1:  unused                        Bits 4-7 = Transmit Speed
B0:  unused


E8H:  Serial Port
     IN                            OUT
     (Signals Input)               (Reset Uart)
B7:  CTS                           Any value will reset the
B6:  DSR                           Uart
B5:  0=Carrier Detected
B4:  1?=Ring Indicate
B3:  unused
B2:  unused
B1:  unused
B0:  Serial data input
						

Ports (Model III)

FF: Cassette unit.       I/O
F8: Printer.             I/O


F4H: Disk Drive register port.
     IN                            OUT
B7:
B6:
B5:
B4:
B3:
B2:
B1:
B0:


F3: Disk Controller DATA register.
     Same specs as for WD1791 DDEN Disk Controller.
F2: Disk SECTOR register.
     For WD1791.
F1: Disk TRACK  register.
     For WD1791.
F0: Disk COMMAND/STATUS register.
     For WD1791.



C8-CF: Hard disk controller port addresses.
   Ports C8 to CF correspond to Winchester Disk controller
chip WD1010 registers 0 through 7. Port C8 in particular
is the port used to read/write data.
   See Western Digital manual for specs.

C1: ??
C0: ??


EC: ?                    I/O

EBH:  RS-232 data in/out port
     IN                            OUT
     (Data read from line)         (Data sent to line)
B7:  Data-7                        Data-7
B6:  Data-6                        Data-6
B5:  Data-5                        Data-5
B4:  Data-4                        Data-4
B3:  Data-3                        Data-3
B2:  Data-2                        Data-2
B1:  Data-1                        Data-1
B0:  Data-0                        Data-0


EAH: RS-232 status/control
     IN                            OUT
     (Uart Status & signals)       (Set UART parameters)
B7:  1=Data Available (input)      1=Even Parity, 0=Odd
B6:  1=Data Sent (output)          : Word length 00=5 01=7
B5:  1=Overrun Error               : Word length 10=6 11=8
B4:  1=Framing Error               0=1-Stop bit, 1=2.
B3:  1=Parity Error                0=Enable parity, 1=Disable
B2:  unused                        1?=Send BREAK signal
B1:  unused                        1=DTR off
B0:  unused                        1=RTS off


E9: RS-232 software switches and speed select
     IN                            OUT
     (DIP Switches)                (Baud rate select)
B7:  Parity 0=odd 1=even           ) Xmit baud rate B4-B7
B6:  Word length 00=5 01=7         )
B5:  Word length 10=6 11=8         )
B4:  Stop bits 0=1 1=2             )
B3:  Parity 0=enable 1=disable     ) Recv baud rate B0-B3
B2:  Baud rate select #2           )
B1:  Baud rate select #1           )
B0:  Baud rate select #0           )


E8: RS-232 Signals and reset
     IN                            OUT
     (Input signals)               (Reset)
B7:  CTS                           Any value will reset the
B6:  DSR                           interface.
B5:  Carrier Detect
B4:  Ring Indicate
B3:  unused
B2:  unused
B1:  Copy of serial input pin UART
B0:    (May be bit 0 instead)

E4: ?                    I/O
E0: ?                    I/O
9C: ? (4p only?)         O
						

Undocumented Z-80 Opcodes - Developed from the article by Daniel Lunsford in TAS, V1. N6. pp53-55
In these opcodes, HX and LX represent the high- and low-order bytes of the IX register. HY and LY are analogous for the IY register. The timing for these new IX and IY instructions is 4 T-states longer than the equivalent H and L instructions..
Also, SLS means Shift Left and Set. This shifts the register left just as an SLA would, and then the LSB is set. The MSB goes into the Carry flag, and sign and parity are adjusted as expected.

New Opcode      Hex             Assembler Realization


SLS   A         CB 37           DEFW    37CBH
SLS   B         CB 30           DEFW    30CBH
SLS   C         CB 31           DEFW    31CBH
SLS   D         CB 32           DEFW    32CBH
SLS   E         CB 33           DEFW    33CBH
SLS   H         CB 34           DEFW    34CBH
SLS   L         CB 35           DEFW    35CBH
SLS   (HL)      CB 36           DEFW    36CBH

SLS   (IX+d)    DD CB dd 36     RLC (IX+d)
                                ORG $-1
                                DEFB 36H

SLS   (IY+d)    FD CB dd 36     RLC (IY+d)
                                ORG $-1
                                DEFB 36H

ADC   A,HX      DD 8C           DEFW    8CDDH
ADC   A,LX      DD 8D           DEFW    8DDDH
ADC   A,HY      FD 8C           DEFW    8CFDH
ADC   A,LY      FD 8D           DEFW    8DFDH

ADD   A,HX      DD 84           DEFW    84DDH
ADD   A,LX      DD 85           DEFW    85DDH
ADD   A,HY      FD 84           DEFW    84FDH
ADD   A,LY      FD 85           DEFW    85FDH

AND   HX        DD A4           DEFW    0A4DDH
AND   LX        DD A5           DEFW    0A5DDH
AND   HY        FD A4           DEFW    0A4FDH
AND   LY        FD A5           DEFW    0A5FDH

CP    HX        DD BC           DEFW    0BCDDH
CP    LX        DD BD           DEFW    0BDDDH
CP    HY        FD BC           DEFW    0BCFDH
CP    LY        FD BD           DEFW    0BDFDH

DEC   HX        DD 25           DEFW    25DDH
DEC   LX        DD 2D           DEFW    2DDDH
DEC   HY        FD 25           DEFW    25FDH
DEC   LY        FD 2D           DEFW    2DFDH

INC   HX        DD 24           DEFW    24DDH
INC   LX        DD 2C           DEFW    2CDDH
INC   HY        FD 24           DEFW    24FDH
INC   LY        FD 2C           DEFW    2CFDH

OR    HX        DD B4           DEFW    0B4DDH
OR    LX        DD B5           DEFW    0B5DDH
OR    HY        FD B4           DEFW    0B4FDH
OR    LY        FD B5           DEFW    0B5FDH

SBC   A,HX      DD 9C           DEFW    9CDDH
SBC   A,LX      DD 9D           DEFW    9DDDH
SBC   A,HY      FD 9C           DEFW    9CFDH
SBC   A,LY      FD 9D           DEFW    9DFDH

SUB   HX        DD 94           DEFW    94DDH
SUB   LX        DD 95           DEFW    95DDH
SUB   HY        FD 94           DEFW    94FDH
SUB   LY        FD 95           DEFW    95FDH

XOR   HX        DD AC           DEFW    0ACDDH
XOR   LX        DD AD           DEFW    0ADDDH
XOR   HY        FD AC           DEFW    0ACFDH
XOR   LY        FD AD           DEFW    0ADFDH

LD   HX,A       DD 67           DEFW    67DDH
LD   LX,A       DD 6F           DEFW    6FDDH
LD   HY,A       FD 67           DEFW    67FDH
LD   LY,A       FD 6F           DEFW    6FFDH

LD   HX,B       DD 60           DEFW    60DDH
LD   LX,B       DD 68           DEFW    68DDH
LD   HY,B       FD 60           DEFW    60FDH
LD   LY,B       FD 68           DEFW    68FDH

LD   HX,C       DD 61           DEFW    61DDH
LD   LX,C       DD 69           DEFW    69DDH
LD   HY,C       FD 61           DEFW    61FDH
LD   LY,C       FD 69           DEFW    69FDH

LD   HX,D       DD 62           DEFW    62DDH
LD   LX,D       DD 6A           DEFW    6ADDH
LD   HY,D       FD 62           DEFW    62FDH
LD   LY,D       FD 6A           DEFW    6AFDH

LD   HX,E       DD 63           DEFW    63DDH
LD   LX,E       DD 6B           DEFW    6BDDH
LD   HY,E       FD 63           DEFW    63FDH
LD   LY,E       FD 6B           DEFW    6BFDH

LD   HX,n       DD 26 n         DEFB    0DDH,26H,n
                             or DEFB    221,38,n

LD   LX,n       DD 2E n         DEFB    0DDH,2EH,n
                             or DEFB    221,46,n

LD   HY,n       FD 26 n         DEFB    0FDH,26H,n
                             or DEFB    253,38,n

LD   LY,n       FD 2E n         DEFB    0FDH,2EH,n
                             or DEFB    253,46,n

LD   HX,LX      DD 65           DEFW    65DDH
LD   LX,HX      DD 6C           DEFW    6CDDH
LD   HY,LY      FD 65           DEFW    65FDH
LD   LY,HY      FD 6C           DEFW    6CFDH

LD   A,HX       DD 7C           DEFW    7CDDH
LD   A,LX       DD 7D           DEFW    7DDDH
LD   A,HY       FD 7C           DEFW    7CFDH
LD   A,LY       FD 7D           DEFW    7DFDH

LD   B,HX       DD 44           DEFW    44DDH
LD   B,LX       DD 45           DEFW    45DDH
LD   B,HY       FD 44           DEFW    44FDH
LD   B,LY       FD 45           DEFW    45FDH

LD   C,HX       DD 4C           DEFW    4CDDH
LD   C,LX       DD 4D           DEFW    4DDDH
LD   C,HY       FD 4C           DEFW    4CFDH
LD   C,LY       FD 4D           DEFW    4DFDH

LD   D,HX       DD 54           DEFW    54DDH
LD   D,LX       DD 55           DEFW    55DDH
LD   D,HY       FD 54           DEFW    54FDH
LD   D,LY       FD 55           DEFW    55FDH

LD   E,HX       DD 5C           DEFW    5CDDH
LD   E,LX       DD 5D           DEFW    5DDDH
LD   E,HY       FD 5C           DEFW    5CFDH
LD   E,LY       FD 5D           DEFW    5DFDH