Ira Goldklang's TRS-80 Revived Site

ROM / RAM / PORTS / CALLS / TOKENS (The inside stuff)

       




         Page Menu
CPU/ROM
  • ROM Addresses
  • ROM Calls
  • ROM RST Vectors
  • ROM Routines (I/O & Misc.)
  • ROM Routines (Integer Math)
  • Entry Points to Level II BASIC ROM
  • Z-80 Instruction Set
    Cassette
  • System Tape Format
  • EDAS Tape Format
  • BASIC Tape Format
  • Cassette Volume Settings
     
     
     
    I/O
  • Port Addresses (Model I)
  • Port Addresses (Model III)
  • Memory Mapped I/O Devices
  • Port Addresses (Model III/IV)
  • Model III RS-232 Ports
  • Model III WD1793 Disk Controller Ports
  • Radio Shack 5/15 Meg HD Port Assignments
  • UART Bits
  • Model 1/3 TRS-80 Keyboard PEEK Table
  • Model 4 TRS-80 Keyboard PEEK Table
  • Directly Access Model 4 Video
  • Model 4P Modem Controls
  • Model 4 Graphics Board - Undocumented Ports
  • Model 4 Video Locations
     
    Other
  • DOS Routines
  • Level II/DOS RAM Map
  • Disk Basic Command Vectors
  • Disk Speed-Up Chart
  • RAM Addresses
  • Tokenized BASIC
  • Pokes and Peeks
  • Vidtex Escape Sequences
  • Model 4P Boot Mode Select
  • Programming the Model 4 Function Keys
  • Changing the Model 4 Speed (4MHZ Model 3/2MHZ Model 4)
  • Controlling the Model 4 Sound Card
  • Interesting Model 4 BASIC Commands



             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-40A516548-16549Pointer 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.

    Top of Page




             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

    Top of Page




             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

    Top of Page




             ROM Addresses
    The following Z80 registers and register pairs apply: A,F,B,C,D,E,H,L,AF,BC,DE,HL,IX,IY. Any of these proceeded by a "'" refers to the alternate set.
    Miscellaneous:
         SA - Software accumulator
         SA1 - Alternate software accumulator
         RA - Register accumulator (E,D,C,B).
    HexDecLabelTypeDescription
    00000DOSCLDJp"In cassette systems, reset computer; in disk systems, cold boot of DOS. Could also be done via RST 00H."
    00088SYNTAXRSTChecks for syntax. HL points to byte to be checked and proper byte follows RST 08H instruction.
    000B11WHERECall"Vector used to resolve relocation address of calling routine. On exit, HL points to address following Call instruction."
    001319GETCallThis routine gets a byte from a logical device or a file that is open. Entry: DE points at FCB. Exit: A = byte.
    001824CP16RstCompare DE and HL as 16 bit unsigned intergers.
    001B27PUTCallOutputs a byte to a logical device or FCB. DE = FCB and A = byte. Don't confuse with CTL at 0023.
    002335CTLCallOutputs a control byte to a logical device or FCB. DE = FCB and A = control byte.
    002840RstPressing Break key RST's here and then jumps to location 400CH. Also normal DOS function vector.
    002B43KBDSCNCallScan keyboard and return with accumulator containing result. DE is used.
    003351VDCHARCallDisplays a character at current cursor location.
    003B59PRCHARCall"Waits until printer is ready then prints charatcter. A = ASCII character. If BREAK is pressed, a return to caller is made."
    004064KBLINECallCall Input a line from the keyboard. B = max length of line. HL points at buffer. Buffer should be the length of B plus 1. To terminate, hit BREAK or ENTER. On exit, HL points at buffer and B = number of characters entered. Carry will be set if BREAK was pressed.
    004973KBWAITCall"Scans the keyboard until a key is pressed. If BREAK is pressed, it is returned like other keys."
    005080RSRCVCall"Recieve a character from RS-232. No entry conditions. On exit, memory location 16872 contains character recieved. DE is altered. This routine honors wait status."
    005585RSTXCall"Transmit character to RS-232. On entry, Accumulator or memory location 16880 contains character. On exit, 16880 = 0 if no character sent. Wait status honored."
    005A90RSINITCallCall Initialize RS-232 interface. On entry, memory location 16888 = send/recieve baud rate code, location 16890 = wait/don't wait switch, location 16889 = RS-232 characteristics switch. On exit, DE is altered. For more detail, consult Model 3 reference manual.
    006096DELAYCall"Load BC with how many times to loop, then call."
    0069105INITIOCall"Initialize all I/O drivers to their ROM routines. No entry conditions. On exit, all registers changed."
    006C108ROUTECall"On entry, location 4222H = two byte source device ASCII abbreviation and location 4220H = two byte destination ASCII abbreviation. On exit, DE is altered."
    0072114An alternative for entering Basic. See also 1A19H.
    00B1177Type in SYSTEM (even from DISK BASIC) and reply to the "*?" prompt with /177. The computer will then ask you for memory size. Upon return, you'll still be in DISK BASIC, but your program will be gone. Also, it doesn't get along with any high memory routines present.
    00FA250Call this routine from BASIC and your computer will brag about it having Level II or Model III BASIC.
    0132306POINTBasic's POINT routine.
    0135309SETBasic's SET routine.
    0138312RESETBasic's RESET routine.
    0150336GRAPHJpThis is the routine that is Basic's SET, RESET, and POINT functions. Here's how to use it. Load HL with return address and push. Load register A with one of the following: 00H = POINT, 01H = RESET, and 80H = SET. Push AF onto stack. Load A with X coordinate and push onto stack. Load A with Y coordianate and JP GRAPH.
    018C396Call"Checks for syntax of "")"" via RST 08H."
    01C9457CLSCallClear screen.
    01D3467RANDOMCallRandomize.
    01F8504CSOFFCallThis routine turns off the cassette drive.
    0212530DEFCASCallA register contains a 0 or 1 which is the cassette number. This routine defines cassette number and turns on cassette. Model I only.
    022C556?????????
    0235565CSINCallInputs data one byte at a time from cassette after you use CSHIN. A = the data byte.
    0264612CSOUTCallOutputs data one byte at a time to cassette after you use CSHWR. A = the output byte.
    0287647CSHWRCallTurns on the cassette and writes the header.
    0296662CSHINCallFinds the cassette header info at the beggining of cassette file.
    02B2690SYSTEMBasic's SYSTEM routine.
    0314788?????????
    032A810OUTCHRCallOuput character in register A; OUTSEL (409CH) selects device. See OUTSEL for device values.
    033A826DISPACallDisplays character in A on screen at next print position. Uses AF.
    0358856Calls keyboard scan routine.
    035B859CallSame as 002BH.
    0361865KIBUFFCallReads keyboard into buffer until a carriage return is entered. 40A7H contains the address of the buffer.
    03C2962Line printer driver for Model I.
    03E3995Keyboard driver for Model I. Model III = 3024H.
    04581112Video driver for Model I.
    04731139Video driver for Model III.
    05061286CURCON"Start of cursor control table. Model I. 80 Microcomputing, Sept. 1980, p. 187."
    05401344End of cursor control table.
    058D1421Line printer driver for Model I.
    05D91497KLINECallSame as KBLINE. See 0040.
    06CC1740An alternative for entering Basic. See also 1A19H.
    06D21746Start of Model 1 interrupts relocated to RAM on boot up.
    06E61766End of Model 1 interrupts relocated to RAM on boot up.
    06E71767Start of Model 1 keyboard DCB.
    06EE1774End of Model 1 keyboard DCB.
    06EF1775Start of Model 1 Video DCB.
    06F61782End of Model 1 Video DCB.
    06F71783Start of Model 1 Printer DCB.
    06FE1790End of Model 1 Printer DCB.
    07131811SUBSPCallSubtract SA from RA; result in SA.
    07161814ADDSPCallAdd RA and SA; result in SA.
    07781912RSETSACall"If SA contains a 00H, RND generates a number between 0 and 1. Use this call to place a 00H in SA."
    08092057LOGCallBasic's LOG function.
    08472119MLTSPCallMultiply RA and SA; result in SA.
    08A22210DIVSPCallDivide RA by SA; result in SA.
    09772423ABSCallBasic's ABS function.
    09822434MVVARCallMove number of bytes shown by typeflag from area pointed to by DE to area pointed to by HL.
    098A2442SGNCallBasic's SGN function.
    09A42468LDSTSACallLoad SA into stack.
    09B12481LDSAHLCallLoad single precision number pointed to by HL into SA.
    09B42484LDSARACallLoad RA into SA.
    09BF2495LDRASACallLoad SA into RA.
    09C22498LDRAHLCallLoad single precision number pointed to by HL into RA.
    09CB2507LDHLSACallLoad SA into area pointed to by HL.
    09D22514LDDEHLCallLoad single precision number pointed to by HL into area pointed to by DE; needs FLAGSP.
    09D32515LDHLDECallLoad single precision number pointed to by DE into area pointed to by HL; needs FLAGSP.
    09D62518MOVEACall"Move data; DE = source, HL = destination, A = how much to move."
    09D72519MOVEBCall"Same as above, except B contains the count."
    09F72551MVSAHLCallMove number pointed to by HL into SA; needs FLAGDP.
    09FC2556MVALTCallMove SA into SA1.
    0A0C2572CPSPCallCompare RA and SA1.
    0A392617CPINTCallCompare DE and HL.
    0A782680CPDPCallCompare SA and SA1.
    0A7F2687GETPARCallLoad parameter in USR(x) into HL; this must be first instruction of USR call. Also used for CINT function.
    0A9A2714BSCPARJpReturn to Basic program with parameter.
    0A9D2717FLAGINCallSet typeflag of SA to interger.
    0AB12737CSASPCallConvert SA to single precision. Also Basic's CSNG routine.
    0ACC2764CHGISCallValue in workspace/accumulator is changed from integer to single precision.
    0ADB2779CSADPCallConvert SA to double precision. Also Basic's CDBL routine.
    0AEC2796FLAGDPCallSet typeflag for SA to double precision.
    0AEF2799FLAGSPCallSet typeflag for SA to single presision.
    0B262854FIXCallBasic's FIX function.
    0B372871INTCallBasic's INT function.
    0BC73015SUBINTCallSubtract HL from DE; result in HL and SA if no overflow (flag = 2); result in SA only if overflow (flag = 4).
    0BD23026ADDINTCallAdd DE and HL; result in HL and in SA if no overflow.
    0BF23058MLTINTCall"Multiply DE and HL; result in HL and SA if no overflow (flag=2), result in SA only if overflow (flag=4)"
    0C703184SUBDPCallSubtract SA1 from SA; result in SA.
    0C773191ADDDPCallAdd SA and SA1; result in SA.
    0DA13489MLTDPCallMultiply SA and SA1; result in SA.
    0DE53557DIVDPCallDivided SA by SA1; result in SA.
    0FAF4015Display integer number in HL in ASCII decimal. The ASCII number will also be in memory at 4131H - 4135H.
    0FBD4029CSAASCCallConvert SA (set typeflag) to ASCII. Result (in dec) is placed in buffer starting at 4130H and terminated by a 00H byte and HL = 4130H.
    13E75095SQRCallBasic's SQR function.
    13F75111POWERCallRaise RA to the power SA; result in SA.
    14395177EXPCallBasic's EXP function.
    14C95321RNDCallBasic's RND function.
    14CC5324???
    15415441COSCallBasic's COSine function.
    15475447SINCallBasic's SIN function.
    15A85544TANCallBasic's TAN function.
    15BD5565ATNCallBasic's ATN function
    16085640"Beginning of jump table for Basic's functions. For Basic's jump statement table, see 1822H."
    164F5711End of jump table for Basic's functions.
    16505712Beginning of table of names of Basic's reserved words.
    181F6175End of table of names of Basic's reserved words.
    18226178"Beginning of jump table for Basic's statements. For Basic's jump funtion table, see 1608H."
    18996297End of jump table for Basic's statements.
    18C96345"Start of BASIC error messages. Ie: NF, OM, etc."
    18F66390End of BASIC error messages.
    196C6508Check for enough RAM for stack operation.
    19976551SN ERROR routine.
    19A26562ERROR routine.
    1A196681BASICJp"Return to Basic and display Basic READY prompt (if you have difficulty with 1A19, try 06CCH or 0072H instead)"
    1AF86904Writes line pointers beginning from start of Basic program.
    1AFC6908Writes line pointers beginning with line pointed to by DE.
    1B2C6956FNDLIN"To use: Load DE with line number, call and this location. Upon exit, BC will contain location. 80 Micro, Feb. 1981, p. 148."
    1B496985NEWBasic's NEW routine.
    1B4D6989"Reset Basic pointers? 80 Microcomputing, Nov 81, p. 386."
    1B5D6705Basic initialization routines (RUN).
    1BC07104TOKENBasic's tokenizing routine. Point register pair HL to the start of the string to be tokenized terminated by a 0 byte and call 1BC0H. Upon exit, HL will point to one byte below the tokenized string which will be terminated by a 0 byte.
    1CA17329FORBasic's FOR routine.
    1D1E7454RUNSTMJp"HL points at "":"" or 00H terminating a Basic statement or line; execution will proceed from next statement."
    1D917569RESTOREBasic's RESTORE routine.
    1D9B7579Scan for shift @ and BREAK.
    1DA97593STOPBasic's STOP routine.
    1DAE7598ENDBasic's END routine.
    1DE47652CONTBasic's CONT routine.
    1DF77671TRONBasic's TRON routine.
    1DF87672TROFFBasic's TROFF routine.
    1E007680DEFSTRBasic's DEFSTR routine.
    1E037683DEFINTBasic's DEFINT routine.
    1E067686DEFSNGBasic's DEFSNG routine.
    1E097689DEFDBLBasic's DEFDBL routine.
    1E4A7754FCERRCall"Prints ""FC Error""."
    1E5A7770VALCall"Convert a string representing a decimal number and terminated by a 00H byte to a binary number. HL points at first character, DE contains result after call."
    1E7A7802CLEARBasic's CLEAR routine.
    1EA37843RUNBasic's RUN routine.
    1EB17857GOSUBBasic's GOSUB routine.
    1EC27874GOTOBasic's GOTO routine.
    1EDE7902RETURNBasic's RETURN routine.
    1F057941DATABasic's DATA routine.
    1F077943REM/ELSEBasic's REM and/or ELSE routine.
    1F217969EVALUCallCall Evaluate expression. Useful for doing complicated math functions in machine language. HL must point to a portion of memory that is in tokenized BASIC and terminated by a 00H byte or a ":" byte. Also known as Basic's LET routine.
    1F6C8044ONBasic's ON routine.
    1FAF8111RESUMEBasic's RESUME routine.
    1FF48180ERRORBasic's ERROR routine.
    20088200AUTOBasic's AUTO routine.
    20398249IFBasic's IF routine.
    20678295LPRINTBasic's LPRINT routine.
    206F8303PRINTBasic's PRINT routine.
    219A8602INPUTBasic's INPUT routine.
    21E38675MVSTRCallMove string into space; HL points at first byte of buffer and BC points at variable name.
    21EF8687READBasic's READ routine.
    22B68886NEXTBasic's NEXT routine.
    23379015"Gets a general (string, integer, single, or double precision) parameter in the accumulator and sets the type flag (40AFH) accordingly."
    24909360DIVINTCallCall Divide DE by HL; result in SA in single precision format. 2540 9536 LDVAWS Call Loads value of variable into workspace/ accumulator. On entry, HL points to first character of variable name. On exit, HL points to first character following variable name.
    25A19633CPSTRCall"Compare two strings. HL and BC point at strings, D and E contain lengths."
    26089736DIMBasic's DIM statement.
    260D9741VARPTRCall"Get variable address in DE, HL points at variable name."
    27D410196FREBasic's FRE routine.
    27F510229POSBasic's POS routine.
    283610294STR$Basic's STR$ routine.
    28A710407OUTSTRCall"Output string terminated by a 00H byte or 22H ("") byte.; HL points at first character, OUTSEL (409CH) selects device. See OUTSEL for device numbers."
    2A0310755LENBasic's LEN routine.
    2A0F10767ASCBasic's ASC routine.
    2A1F10783CHR$Basic's CHR$ routine.
    2A6110849LEFT$Basic's LEFT$ routine.
    2A9110897RIGHT$Basic's RIGHT$ routine.
    2A9A10906MID$Basic's MID$ routine.
    2AEF10991INPBasic's INP routine.
    2A2F10799STRING$Basic's STRING$ routine.
    2AC510949VALBasic's VAL routine.
    2AFB11003OUTBasic's OUT routine.
    2B0211010Gets a two byte integer in DE.
    2B1711031"Evaluate expression? 80 Microcomputing, Nov 81, p. 386"
    2B1C11036Gets a one byte integer in A.
    2B2911049LLISTBasic's LLIST routine.
    2B2E11054LISTBasic's LIST routine.
    2B7511125OSTRCall"Output string to current device. On entry, HL points to first character in string which ends in a 00 byte."
    2B7E11134"Write line of Basic in buffer, change tokens to words."
    2BC611206DELETEBasic's DELETE routine.
    2BF511253CSAVEBasic's CSAVE routine.
    2C1F11295CLOADBasic's CLOAD routine.
    2C7711383"Initialize for Basic. 80 Micro, Sep. 1980, p. 72."
    2CAA11434PEEKBasic's PEEK routine.
    2CB111441POKEBasic's POKE routine.
    2E6011872EDITBasic's EDIT routine.
    2E6611878EDITOR"Load HL with line number to edit and use this routine. 80 Micro, Feb. 1981, p. 148."
    302412324Video driver for Model III.
    303312339GETDATCall"Get date in ASCII format. Mod III TRSDOS, LDOS, & MULTIDOS."
    303612342GETTIMCall"Get time in ASCII format. Mod III TRSDOS, LDOS, & MULTIDOS."
    304212354?????????
    37E014304Port"Model I interrupt address port. Bit 7 set for clock, bit 6 set for disk."
    37E114305PortModel I disk drive select.
    37E414308PortModel I cassette 1 or 2 select (0 or 1).
    37E814312PortLineprinter address port.
    37EC14316PortModel I disk command/status.
    37ED14317PortModel I disk track select.
    37EE14318PortModel I disk sector select.
    37EF14319PortModel I disk data.
    380014336PortsBeginning of model I & III keyboard address ports.
    38401440PortsEnd of model I & III keyboard address ports.

    Top of Page




             Radio Shack 5/15 Meg HD Port Assignments - Bob Haynes, 10/15/87
    This chart provides reference on the Western Digital Hard Disk Controller board WD1000-TB1, based on the WD1010 controller chip and WD1100 support chip. This board is used in later (white) versions of the Radio Shack 15 Meg Hard Disk (26-4155).
    Earlier versions of the 15M, the 5M, and 12M hard disk systems all use a larger controller board based on the 8X300 controller chip. I've heard the R/S 8M hard disk also uses the 8X300 board, but that's unconfirmed.
    I have little information on the 8X300 board, but since both 15 and 5 Meg systems are known to work with the same driver/format software from at least three sources (Tandy/MISOSYS/PowerSOFT), it is assumed most of this chart also applies to the earlier 8X300 board. (one difference is noted above)
    Although Radio Shack has mapped the HD access ports from C0-CFH as a standard configuration, both boards can re-map the ports to 50-5FH, 60-6FH, or 70-7FH simply by changing some jumpers. (If interested, drop a line for details.)
    Special thanks to Adam Rubin, who reviewed the information to help confirm its accuracy. Comments, corrections and updates are welcome!
                     Radio Shack 5/15 Meg HD Port Assignments
    .--------------------------------------------------------------------------.
    |PORT C0H - READ ONLY                |PORT C1H - R/W - HD Control Register |
    |Bits 2-3 unused                     |Bits 0-2, 5-7 unused (see note 4)    |
    |     0-INTRQ-Interrupt request      |     3    If set, enables controller |
    |     1-HWPL-If set, at least one HD |     4    If set, resets controller  |
    |            is write protected      |-------------------------------------|
    |     4-WPD4-drive 4 write protected |PORT C2-C3H - READ - HD Dev. ID Reg. |
    |     5-WPD3-drive 3 write protected |     C4-C7H - HD CTC Channels 0-3    |
    |     6-WPD2-drive 2 write protected |     See note 1                      |
    |     7-WPD1-drive 1 write protected |-------------------------------------|
    |------------------------------------|PORT C8H - R/W - HD Data Register    |
    |PORT C9H - READ - Error Register    |-------------------------------------|
    |Bits 3,5 all reserved (zero)        |PORT C9H - WRITE - Wrt Pre-Comp Cyl. |
    |     0-DAM not found (see note 2)   |The value stored here multiplied x4  |
    |     1-Track 0 Error (restore cmnd) |is the RWC start cylinder number.    |
    |     2-Aborted Command              |-------------------------------------|
    |     4-ID Not Found Error           |PORT CAH - R/W - Sector Count        |
    |     6-CRC Data Field Error         |Used only for multiple sector access |
    |     7-Bad Block Detected           |don't care w/ single sector commands,|
    |------------------------------------|internally decrements when used.     |
    |PORT CBH - R/W - Sector number      |-------------------------------------|
    |------------------------------------| PORT CDH - R/W - Cylinder MSB       |
    |PORT CCH - R/W - Cylinder LSB       |   (bits 0-1 only; max cyls = 1024)  |
    |--------------------------------------------------------------------------|
    |PORT CEH - R/W - SDH - Sector size/Drive #/Head #                         |
    |Bits 0-2  Head number  (0-7)                                              |
    |     3-4  Drive number (00-11 reference DSEL1-DSEL4 respectively)         |
    |     5-6  Sector size  (00=256, 01=512, 10=1024, 11=128)                  |
    |     7    EXTension:   if set, ECC (Error Checking and Correction) codes  |
    |                       are in use, R/W data (sector length+7 bytes) do    |
    |                       not check/generate CRC.                            |
    |--------------------------------------------------------------------------|
    |PORT CFH - READ - Error Status Register                                   |
    |Bit 0  Error (OR of bits 1-7)       Bit 4  Seek complete                  |
    |    1  Command in progress              5  Write fault                    |
    |    2  Reserved (0)                     6  Drive ready                    |
    |    3  Data request                     7  Busy                           |
    |--------------------------------------------------------------------------|
    |PORT CFH - WRITE - Command Register Instruction Set - see note 3          |
    |          Bits: 7 6 5 4 3 2 1 0    |            Bits: 7 6 5 4 3 2 1 0     |
    |  Restore     | 0 0 0 1 d c b a    |  Read Sector   | 0 0 1 0 i m 0 0     |
    |  Seek        | 0 1 1 1 d c b a    |  Write Sector  | 0 0 1 1 0 m 0 0     |
    |  Scan ID     | 0 1 0 0 0 0 0 0    |  Write Format  | 0 1 0 1 0 0 0 0     |
    |                                   |                                      |
    | "dcba" defines step rate field:   | "i" defines interrupt enable status: |
    |      0000 =  35 us.               |   0 = interrupt when data request    |
    | 0001-1111 =  0.5-7.5 ms in        |       line (DRQ*) is enabled         |
    |               0.5 ms steps        |   1 = interrupt at end of command    |
    |                                                                          |
    | "m" defines multiple sector flag: 0 = one sector, 1 = multiple sectors   |
    `--------------------------------------------------------------------------'
    
    Notes:
    1.  Ports C2-C7 are applicable to the Model II configuration with interface
        board and 8X300 controller board only.  (no further information was
        available, sorry!)
    
    2.  Port C9, bit 0, READ: R/S 15M HD Service Manual indicates this bit is
        reserved (forced zero), but WD1010-00 spec sheet indicates it is used to
        indicate a "DAM not found" error.
    
    3.  Port CF, WRITE: The 4P ROM is known to send three commands to this port:
        16H-restore, 20H-read one sector, 70H-seek. Draw your own conclusions re
        the step rate and interrupt values.
    
    4.  Although there is no formal documentation of this, according to the
        schematics, port C1H bit 2 seems to be used to enable wait state support
        on the 8X300 controller board.  I cannot absolutely confirm this, neither
        can I say whether the later WD-1000-TB1 board implements this function.
    

    Top of Page




             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.

    Top of Page

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

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

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

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

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

    Top of Page

             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$, "'"
    

    Top of Page




             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)
    

    Top of Page




             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

    Top of Page




             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 tra