[Model I]      [Model III] ROM / RAM / PORTS / CALLS / TOKENS (The inside stuff     [Model 4]      [Model 4P]



Menu
CPU/ROM
ROM Addresses - Here
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 - Here
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 - Here
UART Bits
Model 1/3 TRS-80 Keyboard PEEK Table
 
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

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
3C0015360This is the beginning of video ram or VIDRAM. It ends at 3FFFH or 16383.
16333-16334End of BASIC Program Pointer (LSB,MSB)
400016384RST 08 Compare value pointed to by HL to that immediately following RST instruction.
400316387RST 10 Examine next symbol pointed to by HL.
400616390RST 18 Compare DE and HL.
400916393RST 20 Test the type of current varible.
400C16396RST 28 3 byte break key vector (cass. Basic & TRSDOS 1.3) and normal Dos function call.
400F16399RST 30 Reserved for Dos - normally for invoking Debug.
401216402RST 38 Maskable interupt vector.
401516405Beggining of Keyboard DCB. One byte device type. = 1
4016-401716406-16407Two 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
					
401816408Right SHIFT toggle.
401916409Caps lock switch (Not 0 = Caps only)
401A16410Cursor blink count
401B16411Cursor blink status. (0=blinks)
401C16412Cursor blink switch (0 = blink)
401D16413Beggining of Video DCB. One byte device type. = 7.
401E16414Two byte video driver vector.
402016416Two byte cursor position.
4022164180 = Cursor on, Not 0 = character replaced by cursor.
402316419Cursor Character (in ascii).
402416420FLAG : 0 = Space compression; Not 0 = special character.
402516421Beggining of Printer DCB. One byte device type. = 6.
402616422Two byte printer driver vector.
402816424Maximum lines printed per page +1. Default = 67.
402916425Number of lines printed +1.
402A16426Character counter + 1.
402B16427Line printer maximum line length less two.
402C16428"R"
402D16429Return to Dos exit. (Disk systems only).
403016432For all doses except TRSDOS, is abnormal return to DOS ready.
403616438Keyboard buffer (7 bytes).
403D16445Cassette port and print size flag (bit 3) copy (For Model 3, see 4210). L3: location of routine to add task to interupt chain.
403E16446For Model I DOSPLUS, hold DOS version in DCB format.
404016448For L1 & M1, 25 ms heartbeat counter. For L3, used to remove task from interrupt chain.
404116449Beginning of Time and Date bytes. (seconds, min., hours, year, day, month) Ends at 4046H or 16454. L1, D1, and M1
404316451L3, change address of interupt task.
404416452L1, D1, & M1. Contains date in binary format.
404616454L3. Remove task from interupt chain.
404716455L1. Current day in coded form.
404916457For the Model III disk is non maskable interupt vector, for Model I disk is highest available memory location (Model III = 4411H)
404B16459L1. Contains image of interrupt latch.
408E16526Address of USR routine (two bytes)
409916537INKEY$ storage. Most recent keyboard character.
409A16538Error code is at this address (for BASIC only)
409C16540OUTSEL. On Model I, is a one byte output device flag. -1 (or 129) for cass, 0 for video, 1 for printer.
40A016544Clear address pointer. Beggining of CLEARed area for string variable storage
40A016544LSB of Lower Limit for String Variable Storage Space
40A116545MSB of Lower Limit for String Variable Storage Space
40A2-40A316546-16547Last executed line number/Program Line Counter (LSB-MSB).
40A4-40A5  16548-16549 Pointer to beggining of Basic program (LSB-MSB).
40A616550Cursor's current column number.
40A716551Input buffer pointer.
40A916553???.
40AA165543 byte random seed number.
40AB16555This byte is changed by RANDOM.
40AF16559SAFLAG. Contains typeflag of software accumulator.
40B1-40B216561-16562Two byte End (Upper Limit) of String Storage - LSB & MSB.
40B1-40B216561-16562Two byte MEMTOP (for BASIC) - LSB & MSB.
40D316585Saves length ASCII representation of binary integer.
40D416586Two byte address. Points to buffer where ASCII decimal representation written.
40D616598String pointer. Keeps track within CLEARed area as to where last string data was put.
40D816600-16601Two byte location of where Basic is currently reading program/Present BYTE Counter (LSB & MSB).
40DF16607-16608Default entry point for SYSTEM tapes (LSB & MSB).
40E116609Auto flag.
40E216610Current auto line number.
40E416612Auto increment.
40E616614Pointer to terminator (end of line 00H byte or ":") of the last executed Basic statement is at this address.
40E816616Beggining of Basic's stack.
40EA16618Two byte address. Contains line number with error.
40EC16621Two byte address. "." line number.
40EE16622Pointer to I/O buffer.
40F016624Pointer to line of BASIC error handling.
40F216626Error flag.
40F516629Current line number.
40F916633End of basic program/ start of simple variable list pointer.
40FB16635Start of arrays variables pointer.
40FD16637-16638End of arrays variables/ start of free memory pointer (LSB,MSB).
40FF16639-16640Two byte address. Current location of Basic's DATA pointer (LSB,MSB).
410116641Beginning of variable type table.
411A16666End of variable type table.
411B16667Trace flag.
411D16669First byte of SA.
412416673Last byte of SA.
412716679First byte of SA1.
412E16686Last byte of SA1.
415216722CVI 3 byte vector.
415516725FN 3 byte vector.
415816728CVS 3 byte vector.
415B16731DEF 3 byte vector.
415E16734CVD 3 byte vector.
416116737EOF 3 byte vector.
416416740LOC 3 byte vector.
416716743LOF 3 byte vector.
416A16746MKI$ 3 byte vector.
416D16749MKS$ 3 byte vector.
417016752MKD$ 3 byte vector.
417316755CMD 3 byte vector.
417916761OPEN 3 byte vector.
417C16764FIELD 3 byte vector.
417F16767GET 3 byte vector.
418216770PUT 3 byte vector.
418516773CLOSE 3 byte vector.
418816776LOAD 3 byte vector.
418B16779MERGE 3 byte vector.
418E16782NAME 3 byte vector.
419116785KILL 3 byte vector.
419416788& function 3 byte vector.
419716791LSET 3 byte vector.
419A16794RSET 3 byte vector.
419D16797INSTR 3 byte vector.
41A016800SAVE 3 byte vector.
41A316803LINE 3 byte vector.
41A616806ERROR 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
41A916809USR 3 byter vector.
41AC16812Ready prompt
41AF16815Called from 0368H to input line from keyboard to I/O buffer.
41B216818Called from 1AA1H immediately after BASIC line is tokenized. HL points to tokenized line.
41B516821Called 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
41BB16827Called from 1B8CH and 1DB0H during NEW and END processing to allow Disk Basic to close any open files.
41BE16830PRINT# processing called from 2174H
41C116833Byte output to any device. Called from 032CH so output to disk can be handled as to other devices.
41C416836ROM KB scan (0358H) calls this exit. BASIC processes INKEY$ here and also after each command when system searches for break or shift @.
41C716839Called from 1EA6H when RUN is followed by filename or line number
41CA16842Related to 41BEH above. Called at beggining of print processing from 206FH to check for possible disk output.
41CD16845Called 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.
41D016848Called from 2103H (from PRINT routine after code that send CR.) Could be used for screen wrap-around.
41D316851Called 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.
41D616854INPUT# processing. Called from 219EH to check for INPUT# command and to provide input from disk.
41D916857Left side of MID$ processing. Only DOS exit BASIC jumps to instead of calls. Used to allow MID$ on left side of equals sign.
41DC16860Variables assignment. During processing of READ & INPUT statements, after computer recieves value and before assigned to variable, BASIC calls this exit from 222DH.
41DF16863Called 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.
41E216866SYSTEM 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.
41E816872$RSRCV input buffer (1 byte)
41F016880$RSTX output buffer (1 byte)
41F816888$RSINIT baud rate code. TX code = most sig. nibble, RCV code = least sig. nib.
41F916889$RSINIT parity/word/length stop-bit code
41FA16890$RSINIT wait switch (0 = wait, Not 0 = wait)
420916905L3. Checks for drive and mounted disk.
421016912Various controls: See port EC
421116913Cassette baud rate switch (0 = 500 baud, Not 0 = 1500 baud)
421416916Video display scroll protect (range = 0 - 7)
421716919Model 3 time. Contains time in binary format.
421A16922Model 3 date. Contains date in binary format.
422016928$ROUTE destination device (two bytes)
422216930$ROUTE source device (two bytes)
422516933T3, L3, D3. Dos command buffer.
428817032L3. 33.33 ms heartbeat counter.
428A17034L3. Send message to Job Log and CRT.
428D17037T3, D3. Find drive and file number for open file. For L3, send message to Job Log.
429017040T3, L3, D3. Copy directory to RAM buffer.
429317043Get file name from directory.
429617046L3. Execute Dos command and return to DOS ready.
429917049T3. Do DOS command and return to DOS ready. L3: returns to caller is @EXIT and @ABORT vectors change to jump to return address.
429C17052T3. Do DOS command and return to caller.
42AD17069D3. Contains address of break key routine.
431217170D1. Contains address of break key routine (195=Off, 201=On).
431817176T1, L1, D1. DOS command buffer.
439617302L1. Read directory into memory.
440017408L1, D1, D3, N1, N3, M1, M3. Same as 402D: return to DOS ready.
440217410Send text to file or device.
440517413L1, D1, D3, N1, N3, M1, M3. Do DOS command and return to DOS ready.
440917417Display error message on CRT.
440D17421L1, L3, D1, D3, N1, N3, M1, M3. Enter Debug.
441017424L1, D1, N1, M1. Add task to interrupt chain.
441117425Address of highest available memory location (Mod III disk only - Mod 1 disk = 4049H)
441317427L1, D1, N1, N3, M1. Remove task from interrupt chain. For D3, add task to interrup chain.
441517429T3 (undocumented) Second copy of high memory address. Copied to 4411H in case of I/O error during DO processing.
441617430L1, M1. Change entry address of task in interrupt chain. D3: Remove task from interrupt chain. N1, N3: Keep drives rotating and reselect current drive.
441717431L3. Contains current day in coded format.
441917433T3, L3. Write disk directory to screen or buffer. N1, N3: Execute DOS command and return to caller.
441C17436T3, L1, L3, D1, D3, N1, N3, M1, M3. Move filespec to FCB.
442017440All. Open or create a file.
442417444All. Open existing file.
442817448All. Close a file.
442C17452All. Remove file from directory.
443017456All. (undocumented in T1) Load file (m.l. program) into memory.
443317459All. (undocumented in T1) Load and run m.l. program.
443617462All. Read logical record into memory.
443917465All. Write logical record to disk.
443C17468All. Write record and verify.
443F17471T3, L1, L3, D1, D3, N1, N3, M1, M3. Point to first record in file.
444217474All. Position file to specified record.
444517477T3, L1, L3, D1, D3, N1, N3, M1, M3. Backspace file one record.
444817480T3, L1, L3, D1, D3, N1, N3, M1, M3. Position to end of file.
444B17483T3, 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.
444E17486T3, 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.
445117489T3, 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.
445417492L1 Read current sector. L3, D3, M3: Parse parameters in command line. D1: Find drive and file number of a file.
445717495L1 Rewrite current sector. D3: Check for end of file. D1: Read directory to user buffer.
445817496L3. Check for end of file.
445A17498L1. Calculate current logical record number. D1, D3: Display directory on CRT.
445B17499L3. Update directory with current record as end of file. N1, N3: Select and power up specified drive.
445D17501L1. Calculate EOF record number.
445E17502L3. Reread current sector. N1, N3: Test drive and disk.
446017504L1. Skip next logical record.
446117505L3. Rewrite current sector. N1, N3: Add user routine to DOS library chain.
446217506D1, D3. Send text to printer.
446317507L1. Read directory to buffer or CRT.
446417508L3. Skip next logical record. N1, N3: Remove user routine from DOS library chain.
446717511L1, L3, D1, D3, N1, N3, M1, M3. Display text on CRT.
446A17514L1, L3, N1, N3, M1, M3. Send text to printer.
446D17517T1, L1, D1, D3, N1, N3, M1. Get time in ASCII format. L3: Calculate current logical record number.
447017520L3. Calculate end of file record number.
447317523L3. Holds image of interrupt latch. T1, L1, D1, D3, N1, N3, M1, M3: Add default extension to filespec in FCB. (See also 444BH)
447617526L1, D1, M1, M3: Parse parameters in command line.
447817528NewDOS/80 v2.0 for Model 3 Break Vector (195=Off, 201=On).
477917529L1. Send text to file or device. D1, D3: Scan and evaluate command line.
447B17531L1. Send text to job log and CRT. N3: Add task interrupt chain.
447C17532D1, D3. Compare filespec to wildcard mask.
447E17534L1. Send text to joblog.
447F17535D1, D3. Get device number for file or I/O device.
448217538D1, D3. Sort block of memory.
448517541D1. 10 disk I/O functions depending on value in A.
448817544D3. 10 disk I/O functions depending on value in A. D1: Locate device control block for any device.
448B17547D1. Locate drive control table for any drive.
44A017568D3. Locate device control block for any device.
44A317571D3. Locate drive control table for any drive.
44B817592L1. Check drive and disk.
44BB17595L1. Get file name from directory.
44C117601L1. Multiply 16 bit by 8 bit integer.
44C417604L1. Divide 16 bit by 8 bit integer.
44D217618M3. Add task to interrupt chain.
44D517621M3. Remove task from interrupt chain.
44D817624M3. Change execution address of task in interrupt chain.
44DB17627M3. Set task pointer to default of RET.
44DE17630M1, M3. Verify a sector without reading to RAM.
44E117633M1, M3. Read sector.
44E417636M1, M3. Write sector.
44E817640M1, M3. Read directory sector.
44EB17643M1, M3. Write directory sector.
44EE17646M1, M3. Read director.
44F117649M1, M3. Write directory.
44F417652M1, M3. User function.
44F717655M1, M3. Get directory track number.
46DD18141RDSECT. 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.
46E618150WTSECT. On Model I, allows you to write a disk sector. Same conditions as RDSECT at 46DDH.
475418260L1, L3. Select drive.
475918265L1, L3. Continually reselect drive until it is ready.
475E18270L1, L3. Seek specified cylinder (track).
476318275L1, L3. Write sector to disk.
476818280L1, L3. Write system (directory) sector.
476D18285L1, L3. Write track to disk (used for formatting).
477218290L1, L3. Verify sector without transfering data to memory.
477718295L1, L3. Read sector to buffer.
478F18319L1, L3. Get address of drive code table for specifed drive.
479C18332L1, L3. Get byte field from drive code table.
4B1019216L1, L3. Read directory sector with specified entry code.
4B1F19231L1, L3. Write system buffer to specified directory sector.
4B4519269L1, L3. Read directory sector to user buffer.
4B6419300L3. Get cylinder (track) number of directory.
4B6519301L1. Get cylinder (track) number of directory.
4B6B19307L3. Multiply 8 bit by 8 bit integers.
4B6C19308L1. Multiply 8 bit by 8 bit integers.
4B7A19322L3. Divide 8 bit by 8 bit integers.
4B7B19323L1. 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
PortDescription
80HInput: Reserved. Output: Graphics board register.
81HInput: Graphics board RAM read. Output: Graphics board RAM write.
82HInput: Reserved. Output: Graphics board Y register.
83HInput: Reserved. Output: Graphics board X register.
84HMod 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.
88HCRT controller control register.
89HCRT controller control register.
8AHCRT controller control register.
8BHCRT controller data register.
8CH - 8FH.Graphics board select 2.
90HModel 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.
C0HInput: Hard disk write protect. Output: Reserved.
C1HHard disk control register.
C2H - C3H.Input: Hard disk device ID register. Output: Reserved.
C4HHard disk CTC channel 0.
C5HHard disk CTC channel 1.
C6HHard disk CTC channel 2.
C7HHard disk CTC channel 3.
C8HHard disk data register.
C9HHard disk error register.
E0HMaskable interupt
E4HSelect NMI options/read NMI status
E8H--
E9H------ RS-232
EAH------ ports
EBH--
ECHWrite = 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) **
F0HRead 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
F1HFDC track register
F2HFDC sector register
F3HFDC data register
F4HSelect drive and options
F8HLine printer addres port
80H Busy.
40H Out of paper
20H Unit select
10H Fault
FFHCassette port
FDC commands via port F0 (Model III only)
00Hrestore
80Hread sector
A0Hwrite normal sector
A1Hwrite read protect sector
C0Hread address
D0Hreset; puts FDC in mode 1
E0Hread track
F0Hwrite track
Table 1
     Bits
1 0
Model III
ROMs Enabled
Video and
Keyboard Status.
     00Yes Model III.
     01No Model III.
     10No Model 4. (In)
     11No Model 4. (Out)
Table 2
     Bits
6 5 4     
Lower 32k     
RAM
Upper 32K
RAM
     0 0 0Bank 0Bank 1
     0 1 0Bank 0Bank 2
     0 1 1Bank 0Bank 3
     1 1 0Bank 2Bank 1
     1 1 1Bank 3Bank 1

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

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)
MODELADDRESSESFUNCTION



30 TO 14335ROM - LOW MEMORY - BASIC INTERPRETER
30 (0000H)$RESET SOFTWARE SYSTEM RESET
343 (002BH)$KBCHAR SCAN KEYBOARD FOR A CHARACTER
351 (0033H)$VDCHAR DISPLAY A CHARACTER ON THE SCREEN
359 (003BH)$PRCHAR PRINT A CHARACTER ON THE PRINTER
364 (0040H)$KBLINE GET A LINE FROM THE KEYBOARD
373 (0049H)$KBWAIT WAIT FOR A KEYBOARD CHARACTER
380 (0050H)$RSRCV RECEIVE A CHARACTER FROM RS-232-C
1/384UNOFFICIAL PEEK POINT (SEE 293) 1=M1 ELSE=M3
385 (0055H)$RSTX SEND A CHARACTER TO RS-232-C
390 (005AH)$RSINIT INITIALIZE THE RS-232-C
396 (0060H)$DELAY DELAY FOR A SPECIFIED TIME
3105 (0069H)$INITIO INITIALIZE I/O DRIVERS
3108 (006CH)$ROUTE ROUTE I/O DEVICES
1/3293OFFICIAL RADIO SHACK PEEK POINT 73=M3 ELSE=M1
3457 (01C9H)$VDCLS CLEAR THE SCREEN
3473 (01D9H)$PRSCN PRINT THE SCREEN ON THE PRINTER
3504 (01F8H)$CSOFF TURN OFF THE CASSETTE
3539 (021BH)$VDLINE DISPLAY A LINE TO THE SCREEN
3565 (0235H)$CSIN INPUT A BYTE FROM THE CASSETTE
3612 (0264H)$CSOUT OUTPUT A BYTE TO THE CASSETTE
3647 (0287H)$CSHWR WRITE THE CASSETTE HEADER
3653 (028DH)$KBBRK QUICK SCAN FOR BREAK KEY ONLY
3662 (0296H)$CSHIN SEARCH FOR HEADER ON CASSETTE
3664 (0298H)$CLKON TURN ON THE CLOCK DISPLAY
3673 (02A1H)$CLKOFF TURN OFF THE CLOCK DISPLAY
36681 (1A19H)$READY BASIC READY ENTRY ADDRESS
312339 (3033H)$DATE GET THE SYSTEM DATE
312342 (3036H)$TIME GET THE SYSTEM TIME
312354 (3042H)$SETCAS SELECT CASSETTE BAUD RATE
114305DISK DRIVE SELECT
114308Values: 0-1
SELECT TAPE DRIVE: 0=#1 1=#2
314312 (37E8H)$PRSTAT PRINTER STATUS BYTE
1/314312PRINTER ON=63 OFF=143 (NOT DEPENDABLE)
114316DISK COMMAND/STATUS --
114317DISK TRACK SELECT
114318DISK SECTOR SELECT
114319DISK DATA
1/314336 TO 14400KEYBOARD ADDRESS MATRIX
1/314337SEE 15105
1/314338SEE 15106
1/314340SEE 15108
1/314352SEE 15120
1/314368SEE 15136
1/314400SEE 15168
1/314464SEE 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/315105Values: 1,2,4,...128
PEEK KEYBOARD RESPECTIVELY: A,B,C,D,E,F,G
1/315106Values: 1,2,4,...128
PEEK KEYBOARD RESPECTIVELY: H,I,J,K,L,M,N,O
1/315108Values: 1,2,4,...128
PEEK KEYBOARD RESPECTIVELY: P,Q,R,S,T,U,V,W
1/315112Values: 1,2,4
PEEK KEYBOARD RESPECTIVELY: X,Y,Z
1/315120Values: 1,2,4,...128
PEEK KEYBOARD RESPECTIVELY: 0,1,2,3,4,5,6,7
1/315136Values: 1,2,4,...128
PEEK KEYBOARD RESPECTIVELY: 8 9 : ; , - . /
1/315168Values: 1,2,4,...128
PEEK: ENTER, CLR,BREAK,UP-ARW,DN-ARW,L-ARW,R-ARW,SPACE
1/315232PEEK KEYBD RT/LT SHIFT
115360Value: 1/65
1:RADIO SHACK LC MOD 65=NOT RS MOD OR L/C DRIVER INSTALLED
1/315360 TO 16383RAM - VIDEO DISPLAY (BEGINS UPPER RIGHT CORNER)
316383 (3FFFH)END OF VIDEO MEMORY
1/316387 TO 16389RST 10H TRANSFER ADDRESS
1/316396Value: 201
RE-ENABLE BREAK KEY
116396Value: 23/221
IN LEVEL II: 23=DISABLES BREAK 221=ENABLES BREAK
316396Value: 175
1ST OF TWO TO DISABLE BREAK (RS RECOMMENDS)
316396 (400CH)BREAK KEY JUMP VECTOR
316396Value: 195
1ST OF 3 COMBINED TO DISABLE BREAK
316397Value: 154
2ND OF 3 COMBINED TO DISABLE BREAK
316397Value: 201
2ND OF TWO TO DISABLE BREAK (RS RECOMMENDS)
316398Value: 10
3RD OF 3 COMBINED TO DISABLE BREAK
1/316402 TO 16405RST 38H TRANSFER ADDRESS
1/316405 TO 16412KEYBOARD CONTROL BLOCK
316409Value: 0/1
0=INPUT LEFT U/L CASE 1=INPUT CONVERTED TO U CASE (UNLESS FOREIGN DRIVER - DOS+)
1/316412Value: 0/1
CURSOR BLINK=0 NO BLINK=1
1/316413 TO 16420VIDEO CONTROL BLOCK
1/316414Value: 141/194
1ST OF 2 TO SEND PRINT TO LPRINT (M1=141 M3=194)
1/316415Value: 5/6
2ND OF 2 TO SEND PRINT TO LPRINT (M1=5 M3=3)
1/316414Value: 88/115
1ST OF 2 TO RESTORE PRINT (VIDEO) (M1=88 M3=115)
1/316415Value: 4
2ND OF 2 TO RESTORE PRINT (VIDEO) (M1 & M3)
1/316416 & 16417CURSOR ADDRESS 2 BYTES LSB/MSB
1/316418 or 16419Value: 32-255
CURSOR CHARACTER IN ASCII (NORMAL CURSOR=171)
316420CHARACTER SET: 1=ALTERNATE 0=REG
1/316421 TO 16428PRINTER CONTROL BLOCK
1/316422Value: 88/15
1ST OF 2 TO SEND LPRINT TO VIDEO (M1=88 M3=115)
1/316423Value: 4
2ND OF 2 TO SEND LPRINT TO VIDEO (M1 & M3)
1/316422Value: 141/194
1ST OF 2 TO RESTORE LPRINT (PRINTER) (M1=141 M3=194)
1/316423Value: 5/3
2ND OF 2 TO RESTORE LPRINT (PRINTER) (M1=5 M3=3)
1/316424 (4028H)MAX PRINTER LINES PER PAGE PLUS 1
1/316425Value: 1
RESETS LINE COUNT
1/316425Value: 1 TO ?
PEEKS # LINES PRINTED+1 -- POKE N,1: RESETS LINE COUNT
1/316427MAX CHAR PER LPRINT LINE LESS 2 (255=NO MAX)
116445CASSETTE PORT AND PRINT-SIZE FLAG (BIT 3) COPY
116445Value: 0/8
0=CHR$( 28 ):64 CHAR LINE. 8=CHR$(23):32 CHAR LINE
116449 TO 16454TIME/DATE (SEC,MIN,HRS,YR,DA,MO) (SEE 16919/924)
116457 & 16458DOS MEMORY SIZE
116526 & 16527POINTER TO USR ROUTINE - LEVEL II ONLY
316526NUMBER CHAR PRINTED PER LINE PLUS 1
1/316537INKEY$ STORAGE (IN ASCII)
1/316538ERROR CODE
1/316539e.g.:LPRINT STRING$(N-PEEK(16539),32) . . .
1/316539TO LPRINT TAB(N) WHEN N>63 (SEE NOTE)
1/316540OUTPUT FLAG (-1=KBD 0=VIDEO 1=PRINTER)
1/316544 & 16545STRING SPACE START ADDRESS
1/316546 & 16547CURRENT LINE NUMBER IN BASIC PROGRAM
1/316548 & 16549POINTER TO BEGIN BASIC PROGRAM (SEE NOTE)
1/316548TO APPEND: POKE 16548,PEEK(16633)-2:POKE16549,PEEK(16634)
1/316548TO CLOAD: POKE16548,233:POKE16549,66
1/316551 & 16552WHEN IN BASIC - POINTS TO ADDR OF BASIC KBD BUFFER
116553Value: 255
FOR OLD M1'S -POKE AFTER "INPUT#" FOR A "READ" TO FUNCTION
1/316554 TO 16556SEED FOR RND
1/316555THIS BYTE CHANGED BY 'RANDOM'
1/316559VARIABLE-TYPE FLAG FOR THE SOFTWARE ACCUMULATOR
1/316561 & 16562LAST BYTE OF MEMORY AVAILABLE FOR BASIC
1/316598 & 16599NEXT USABLE BYTE IN STRING SPACE
1/316607 & 16608ENTRY POINT OF SYSTEM TAPE
1/316614 & 16615POINTS AT TERMINATOR OF THE LAST EXECUTED BASIC STATEMENT
1/316618 & 16619LINE # WITH ERROR (IF 65535 : COMMAND MODE)
116633 & 16634POINTER TO END OF BASIC PROG - SEE 16548
1/316633 & 16634STARTING ADDRESS OF SIMPLE VARIABLE TABLE
1/316635 & 16636STARTING ADDRESS OF ARRAY VARIABLE TABLE
1/316637 & 166381ST BYTE OF FREE MEMORY AFTER ARRAY TABLE
1/316639 & 16640'DATA' POINTER - TELLS YOU WHERE YOU'RE GOING TO RECORD
1/316641 TO 16666VARIABLE-TYPE TABLE
1/316669 TO 16676SOFTWARE ACCUMULATOR (SA)
1/316679 TO 16686ALTERNATE SOFTWARE ACCUMULATOR (SA)
1/316722 TO 16815DISK BASIC INTERFACE
1/316806 TO 16868DOS INTERFACE AREA
1/316872 (41E8H)$RSRCV INPUT BUFFER
416875, 16876 & 16883M4 IN M3 MODE: ASCII VALUES OF F1,2,3 KEYS
1/316880 (41F0H)$RSTX OUTPUT BUFFER
1/316884 (41F4H)Value 103
1st of 2 to Change LINE keyword to act as LPRINT
1/316885 (41F5H)Value 32
2nd of 2 to Change LINE keyword to act as LPRINT
1/316888 (41F8H)$RSINIT BAUD RATE CODE
1/316889 (41F9H)$RSINIT PARITY/WD LEN/STOP CODE
1/316890 (41FAH)$RSINIT WAIT SWITCH (0=DON'T WAIT)
316912Value: 0/8
0=CHR$( 28 ):64 CHAR LINE. 8=CHR$(23):32 CHAR LINE
4/316912Value: 64,0
SPEEDUP IN III MODE, 0=RETURN TO 2MHZ
316913CASSETTE BAUD RATE: 0=500 NON-0=1500
316916Value: 0-7
VIDEO DISPLAY SCROLL PROTECT 1-7 LINES
316919Value: 00-59
SECONDS
316920Value: 00-59
MINUTES
316921Value: 00-23
HOURS
316922Value: 00-99
YEARS
316923Value: 01-31
DAYS
316924Value: 01-12
MONTHS
1/316928 (4220H)$ROUTE DESTINATION (1ST) BYTE
1/316929 (4221H)$ROUTE DESTINATION (2ND) BYTE
1/316930 (4222H)$ROUTE SOURCE (1ST) BYTE
117129BEGINNING OF BASIC PROGRAMS IN LEVEL II BASIC
117170MODEL 1 NEWDOS/80 V2.0 BREAK VECTOR
195=OFF, 201=ON
317385 TO --RAM - BASIC PROGRAM IN A CASSETTE SYSTEM
317425 & 17426MEMORY SIZE M3 DISK BASIC
117528MODEL 3 NEWDOS/80 V2.0 BREAK VECTOR
195=OFF, 201=ON
1/319631 (4223H)$ROUTE SOURCE (2ND) BYTE
326841 TO --RAM - BASIC PROGRAM IN TRS-DOS 1.3
1/332767 (7FFFH)16K SYSTEM TOP OF PHYSICAL MEMORY
349151 (BFFFH)TOP OF MEMORY 32K SYSTEM
365535 (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:
E8HOutputting 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.
E9HWriting 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.
EAHWriting 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.
EBHWriting 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
         !     !     !     !     !     !     !     !     !
========='====='====='====='====='====='====='====='====='
					

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
AddressCommand
4152CVI
4155FN*
4158CVS
415BDEF
415ECVD
4161EOF
4164LOC
4167LOF
416AMKI$
416DMKS$
4170MKD$
4173CMD
4176TIME$*
4179OPEN
417CFIELD
417FGET
4182PUT
4185CLOSE
4188LOAD
418BMERGE
418ENAME
4191KILL
4194&*
4197LSET
419ARSET
419DINSTR*
41A0SAVE
41A3LINE
* 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}OOpen RAM buffer
{ESC}{ESC}CClose RAM buffer
{ESC}{ESC}ZZero RAM buffer
{ESC}ACursor up
{ESC}BCursor down
{ESC}CCursor right
(ESC)DCursor left
{ESC}G4Semi-graphics 4 mode
{ESC}GNText mode
{ESC}HHome cursor
{ESC}JClear to end of page
{ESC}KClear to end of line
{ESC}Y line colPosition cursor
{ESC}bLock keyboard
{ESC}cUnlock keyboard
(ESC}eDisable display
{ESC}fEnable display
{ESC}gRestart VIDTEX
{ESC}jClear Page
{ESC}lNormal character width
{ESC}mWide 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
						

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