This is a transcript of the main parts of the handbook. The quality of the original scans, combined with lots of tables, was the reason not to attempt a mechanical OCR. It is not complete, and certainly not without typos. While fixing those, sometimes errors in the original are fixed too. Fred Jan Kraan, fjkraan@xs4all.nl, 2012-12-23 --------------------------------------------------------------------------------- TRS-80 HACKER'S HANDBOOK FOR NEWDOS/80 BY KEVIN O'HARE TRADEMARK ACKNOWLEDGEMENTS :- TRS-80 is the Trademark of the Tandy Corp. NEWDOS/80 is the Trademark of Apparat Inc. LDOS is the Trademark of Logical Systems Corp. DOSPLUS is the Trademark of Micro-Systems Software Inc. All trademarks, trade names and copyrights not listed above are unknown to the Author. Copyright (C) 1983 by Kevin O'Hare First Edition First Printing August 1984 Published by COMPUTEREASE 55 Elizabeth Street, Brisbane 4000 AUSTRALIA Printed by Graphic Service Co. 21 Gipps Street, Fortitude Valley Brisbane 4006 All rights reserved. Every reasonable effort has been maade to ensure the accuracy of this publication. But neither the author nor the publisher can assume responsability for any misadventure arising from it's use or application whether they be caused by errors or ommisions, and no liability will be assumed for any misfortune or damage resulting. ii FOREWORD This is an explanation of the different parts of Memory in the TRS-80. There is a wealth of information about the Home Microcomputer that has been documented, particular about the Tandy models. The author has tried to collect this from various sources and construct an easy reference guide to the most useful aspects for the programmer. The DOS Addresses are those for NEWDOS/80 Version 2. There are instances of addresses given which might vary according to the date the DOS purchased but these are exceptional and should not worry most users. However, the overall usefulness of this information will not be impaired by these occurrances. The old ROM was used for the Model I as the quantity sold gives it predominance over the later version. Where the text refers to Model I only, the same information applies to the computers PCM80, Video Genie and System 80. Where there is no mention od model I or Model III, the code or address is common to all the computers. There is a presumption because the conciseness of the text that the user has some knowledgeof the facets of information given. There are over 10 Books published by the IJG Company which explain nearly all functions and much more in great and lucid detail. This work started originally as a Memory Reference but commonly sought information about other aspects of the computer were eventually included to give the book a wider application. I must express my indeptness to Len Browne and Alf West, without whose encouragement and assistence this work would never have eventuated, Thanks you Len and Alf, and may life be kind to you. iii C O N T E N T S Contents in order ................. iv Contents by Memory ................ vi PART 1 THE MEMORY REFERENCE Chapter 1 ......................................... R O M Macroview ......................... 1 ROM Break-up ...................... 2 Extra ROM III ..................... 3 Keyboard Memory ................... 4 Video Memory ...................... 6 Chapter 2 ......................................... R A M Restarts .......................... 7 Device Control Blocks ............. 14 Data Storage Areas ................ 16 Accumulators ...................... 20 Model III RS-232C Control Blocks ... 21 Model III Extra Addresses ......... 22 Chapter 3 .......................................... D O S DOS RAM Usage ..................... 23 Disk Basic Reserved Word Jumps .... 24 ROM Call DOS Exits & Buffers ...... 25 C O N T E N T S NEWDOS/80 DOS Modules ............. 26 Disk I/O FCB's & Buffers .......... 27 NEWDOS/80 DOS & ROM Routines ...... 28 TRSDOS DOS Calls .................. 29 Ports - Model I ................... 30 Port, FDC & Printer Info - Mod II.. 31 iv C O N T E N T S PART 2 TRS-80 INFORMATION Chapter 4 ............................... INITIALISATION IPL in Level II ................ 33 Model I DOS Initialisation ..... 40 Model III DOS Initialisation ... 48 Chapter 5 ...................................... VARIOUS Character Sets for the Model I .. 54 ASCII Codes ..................... 56 Variable Storage ................ 60 Error Messages .................. 62 NEWDOS/80 SYSTEM Options ........ 64 NEWDOS/80 PDRIVE Parameters ..... 65 Directory Entries ............... 66 GAT Sector ...................... 67 HIT Sector ...................... 68 Hard Drives ..................... 69 Chapter 6 ..........................Z-80 INSTRUCTION SET Mnemonics ....................... 73 Flags ........................... 74 Numeric Listings ---------------- 77 Alphabetic ...................... 86 Bit Mapped ...................... 92 Code Action Explained .......... 106 Appendix Extra uses for "&" Function ...... 124 Enhanced SYSTEM Option Print ..... 126 About NEWDOS/80 PDRIVES .......... 130 About COPY ....................... 134 List of Abbreviations ............ 140 Index ............................ 142 CONTENTS BY MEMORY MODEL I IN LEVEL II :- 0000H - 2FFFH ROM .................................. Page 2 3000H - 37DBH Unused by the Model I ................ Page 2 402DH - 407FH Storage or not used .................. Page 16 4080H - 411CH BASIC pointers etc ........... Pages 18 and 19 411DH - 4151H The Accumulators etc ................. Page 20 4152H - 41A8H Reserves Word Jumps .................. Page 24 41A9H - 41E4H ROM Call DOS Exits .................. Page 25 41E5H - 42E7H BASIC Input Buffer .................. Page 29 42E8H - BASIC Program etc. UNDER NEWDOS/80 :- 0000H - 2FFFH ROM .................................. Page 2 3000H - 37DBH Unused by the Model II ............... Page 2 37DCH - 37FFH I/O Addresses ........................ Page 2 3800H - 3BFFH Keyboard Memory ...................... Page 4 3C00H - 3FFFH Screen Memory ........................ Page 6 4000H - 4014H Restarts (RST) ................. Pages 7 to 13 4015H - 402CH Keyboard Video & Printer DCBs .. Pages 14 & 15 402DH - 407FH DOS pointers & parameters ............ Page 16 4080H - 411CH BASIC pointers etc ............. Pages 18 & 19 411DH - 4151H The Accumulators etc ................. Page 20 4152H - 41ABH Reserved Word Jumps .................. Page 24 41A9H - 41E4H ROM Call DOS Exits .................. Page 25 41E5H - 41FFH Storage .............................. Page 23 4200H - 42FFH DOS Sector Buffer .................... Page 23 4300H - 43FFH DOS Storage & Parameters ............. Page 23 4318H - 4367H DOS Command Buffer ................... Page 23 4400H - 4CFFH Main DOS Module (SYS0/SYS) ........... Page 26 4D00H - 51FFH DOS Overlay area ..................... Page 26 5200H - 56FFH BASIC Overlay area ................... Page 26 5700H - 649FH BASIC Main Module .................... Page 26 64A0H - 659FH BASIC Input Buffer ................... Page 23 65A0H - 66B7H Storage .............................. Page 23 66B8H - 6A44H File I/O area (3) .................... Page 27 6A46H - BASIC Programs etc. vi CONTENTS BY MEMORY MODEL III IN LEVEL II :- 0000H - 2FFFH ROM .................................. Page 2 3000H - 37FFH Extra ROM ............................ Page 3 3800H - 3BFFH Keyboard Memory ...................... Page 4 3C00H - 3FFFH Screen Memory ........................ Page 6 4000H - 4014H Restart (RST) Jumps ........... Pages 7 to 13 4015H - 402CH Keyboard, Video & Printer DCB's ..... Page 14 402DH - 407FH Interrupt & storage ................. Page 17 4080H - 411CH BASIC pointers etc ............ Pages 18 & 19 411DH - 4151H The Accumulators etc ................ Page 20 4152H - 41A8H Reserved Word Jumps ................. Page 24 41A9H - 41E4H ROM Call DOS Exits ................. Page 25 41E5H - 4224H RS-232 DCB's & Storage ........ Pages 19 & 20 4225H - 42E4H Storage or not used ................. Page 22 42E5H - 43E7H BASIC Input Buffer .................. Page 22 43E9H - BASIC Programs etc. UNDER NEWDOS/80 :- 0000H - 2FFFH ROM .................................. Page 2 3000H - 37FFH Extra ROM ............................ Page 3 3800H - 3BFFH Keyboard Memory ...................... Page 4 3C00H - 3FFFH Screen Memory ........................ Page 6 4000H - 4014H Restart (RST) Jumps ........... Pages 7 to 13 4015H - 402CH Keyboard, Video & Printer DCB's ..... Page 14 402DH - 407FH Interrupt & storage ................. Page 17 4080H - 411CH BASIC pointers etc ............ Pages 18 & 19 411DH - 4151H The Accumulators etc ................ Page 20 4152H - 41A8H Reserved Word Jumps ................. Page 24 41A9H - 41E4H ROM Call DOS Exits ................. Page 25 41E5H - 4224H RS-232 DCB's & Storage ........ Pages 19 & 20 4225H - 4274H DOS Command Buffer .................. Page 23 4275H - 427FH SYSTEM Storage ...................... Page 23 4280H - 42FFH PDRIVE Storage etc .................. Page 23 4300H - 43FFH DOS Input Buffer .................... Page 23 4400H - 4CFFH Main DOS Module (SYS0/SYS) .......... Page 26 4D00H - 51FFH DOS /SYS Program Overlay area ....... Page 26 5200H - 56FFH BASIC Overlay area .................. Page 25 5700H - 649FH BASIC Main Module ................... Page 26 64A0H - 6592H BASIC Input Buffer .................. Page 23 6593H - 66B8H BASIC extra Storage and Code ........ Page 23 66B8H - 6A44H File I/O area (3) ................... Page 27 6A46H - BASIC Programs etc. vii PART 1 THE MEMORY REFERENCE CHAPTER 1 THE MEMORY REFERENCE ROM MACROVIEW The lay-out of Memory is obviously varied out some of the areas used is given by the char below. The Basic pointers on the left contain the address whether it be Level II Basic or Disk BASIC. Pointed 0000H ( 0) ------------------ to by | | ROM Read only Memory | ROM | | | 3000H (12238) ------------------ | Extra ROM | 3800H (14336) ------------------ | Keyboard | 3C00H (15360) ------------------ | Video Memory | 4000H (16384) ------------------ | Communications | 4CA4H (16548) Start of BASIC Program ------------------ | BASIC Program | 40F9H (16633) End of BASIC Program ------------------ 40F9H (16633) Start of Simple Variables |Simple Variables| 40FBH (16635) Start of Array Variables |Array Variables | |ROM's Variables | 40FDH (16637) Free Space Pointer | | | | | | | Free Space | | | | | 40E8H (16616) Stack Pointer |----------------| | Stack | 40A0H (16544) Start of String Space |----------------| | String Space | 40B1H (16561) Top of Protected Memory |----------------| | Reserved Memory| 16K - 7FFFH (32767): 48K - FFFFH (65535) |----------------| Chapter 1 R O M Page 1 R O M 0000H - 2FFFH = 0 - 12287 :- 12288 Bytes This Area contains the READ ONLY Memory ( ROM ). The following is an attempt to classify areas :- 0000H to 0700H (18C0) :- Device Handling 0700H to 1600H (5600) :- Mathematics 1600H to 1AC0H (6700) :- Tables and References 1A00H to 1C00H (7100) :- Monitoring 1C00H to 2B00H (11000) :- BASIC Interpreter 2B00H to 2FFFH (12000) :- Utilities MODEL I ONLY 3000H - 37DBH = 12288 to 14299 :- 2012 Bytes The Model I Computer has no memory for these addresses. This area haas been set aside by the makers of the TRS-80 for use by the devices which need direct Memory access e.g. 3000H - 377FH = 1288 to 14207 :- 1920 Bytes. This area is used by the EXATRON STRINGY FLOPPY for the utilities, or the extra ROM for some models of PMC-80 Video Genie and System 80. As with the ROM and memory installed here is generally READ ONLY Memory , i.e. it cannot be changed by the user. 37DCH - 37FFH = 14300 to 14335 :- 36 Bytes This area is used by the INPUT/OUTPUT Devices and can be classed as Communication Addresses. 37DCH - 37DFH = 14300 to 14303 :- DOS Status Addresses 37E0H = 14304 :- Interrupt Latch Address 37E1H = 14305 :- DOS - Drive Select & Drive 0 Latch Address 37E2H = 14306 :- Cassette Latch Address 37E3H = 14307 :- DOS - Drive 1 Latch Address 37E4H = 14308 :- Cassette Select Address 37E5H = 14309 :- DOS - Drive 2 Latch Address 37E7H = 14311 :- DOS - Drive 3 Latch Address 37E8H = 14312 :- Line Printer 37EBH = 14315 :- ???? Address 37ECH = 14316 :- DOS - Command/Status Register 37EDH = 14317 :- DOS - Track Register 37EEH = 14318 :- DOS - Sector Register 37EFH = 14319 :- DOS - Data Register Page 2 R O M Chapter 1 MODEL III - EXTRA ROM ROUTINES 3000H - 37FFH = 12288 to 14335 :- 2048 Bytes This area in the Model III is taken up by extra Routines generally handling Cassette and RS-232C functions. ------------------------------------------------------------------------------------------------ Addr. Contents Routine Function ------------------------------------------------------------------------------------------------ 3000H C3 5E 32 325EH Cass - 500 Baud - Write leader & sync byte 3003H C3 9B 32 329BH Cass - 1500 Baud - Write leader & sync byte 3006H C3 74 32 3274H Cass - 500 Baud - Read leader till sync 3009H C3 DA 32 32DAH Cass - 1500 Baud - Read leader till sync 300CH C3 C0 31 31C0H Cass - Turn Cassette off 300FH C3 D1 31 31D1H Cass - Turn Cassette on & wait full speed 3012H C3 AB 34 34ABH Disk - Test if Drive ready, then Reset 3015H C3 55 34 3455H Initialisation - (IPL) Reset entry 3018H C3 FB 35 35C2H Interrupt - Service Routine 301BH C3 FB 35 35FBH RS-232C - Initialise 301EH C3 5A 36 365AH RS-232C - Input Routine 3021H C3 80 36 3680H RS-232C - Output Routine 3024H C3 8E 33 338EH Keyboard - Input Routine 3027H C3 39 37 3739H I/O - Change Device Routing 302AH C3 F7 31 31F7H BASIC - "#" processing (e.g.Print#) 302DH C3 7B 37 377BH BASIC line print processing 3030H C3 99 37 3790H BASIC line print processing 3033H C3 BB 35 35BBH Get Today's Date 3036H C3 A0 35 30A0H Get current Time 3039H DB E4 CB 8F C3 1C 35 - Reset processing (is Reset pressed?) 3040H 18 D3 = JR 3015H - Reset processing 3042H C3 B5 37 37B5H Cassette - Set Baud rate 3045H - 31A4H ? lots of ASCII codes (some code between each) 31A5H - 37FFH Extra Model III routines The extra ROM involved in the listing of BASIC program lines allows the listing of the extra Model III symbols and Characters. The PRINT# extra ROM allows different uses for the '#' symbol. Chapter 1 R O M Page 3 KEYBOARD MEMORY 3800H - 3BFFH = 14336 to 15359 :- 1024 Bytes The Keyboard uses a buffer (see Page 18) at 4038H to 403CH in both Mods I & III. Each Row on the Keyboard Diagram uses a Byte of this Buffer for storage excepting tle last Row (the shift key row). In the Diagram the location of the Buffer for each Row is listed on the right and the address of each rowon the left. The Keyboard is memory mapped and uses this area as follows :- ---------------------------------------------------------------- | BITS | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |BUFFER| ---------------------------------------------------------------- |1 3801H| G g | F f | E e | D d | C c | B b | A a | @ ` |4036H | | 14337| | | | | | | | |16438 | | | | | | | | | | | | |2 3802H| O o | N n | M m | L l | K k | J j | I i | H h |4037H | | 14338| | | | | | | | |16439 | | | | | | | | | | | | |3 3804H| W w | V v | U u | T t | S s | R r | Q q | P p |4038H | | 14340| | | | | | | | |16440 | | | | | | | | | | | | |4 3808H| | | | | | Z z | Y y | X x |4039H | | 14344| | | | | | | | |16441 | | | | | | | | | | | | |5 3810H| 7 ' | 6 & | 5 % | 4 $ | 3 # | 2 * | 1 ! | 0 |403AH | | 14352| | | | | | | | |16442 | | | | | | | | | | | | |6 3820H| / ? | . > | - = | , < | ; + | : * | 9 ) | 8 ( |403BH | | 14368| | | | | | | | |16443 | | | | | | | | | | | | |7 3840H|Space|RghtA|LftA |DownA| UpA | Brk | Cls |Enter|403CH | | 14454| | | | | | | | |16443 | | | | | | | | | | | | |8 3880H| | | | | | |*Rght|Left | | | | | | | | | |Shift|Shift| | ---------------------------------------------------------------- |VALUE 80H=128|40H=64|20H=32|10H=16|8H=8|4H=4|2H=2|1H=1 | | ---------------------------------------------------------------- *Model III only The pattern in 3800H to 38FFH is echoed in each of the other 256 Byte areas making up the keyboard memory i.e. 3900H to 39FFH, 3A00H to 3AFFH, and 3B00H to 3BFFH. The CPU scans the Keyboard Memory. When a key is pressed the value thus created is XOR'ed with the Row Buffer location so that on the first scan the Buffer receives the value of the key pressed. On the second scan if the key is still pressed, it is rendered ineffective since it is XOR'ed with it's own value. Page 4 R O M Chapter 1 KEYBOARD MEMORY The ROM reads each row of the keyboard memory. To obtain the address of the next row in the Keyboard map the LSB of the current address is shifted left ( doubled ). The Bytes in the area from 3800H - 38FFH are affected in the following way :- 1st row - Keys @ABCDEFG Values 40H(64) to 47H(71) Shifted `abcdefg 60H(96) to 67H(103) In the top 1 of every 2 bytes, the bit is set corresponding to the column value in the bottom line of the table on the previous page, i.e. the bit is set in 3801H,3803H,3805H,3807H,3809H, etc right up to 3BFFH. 2nd row - Keys HIJKLMNO Values 48H(72) to 4FH(79) Shifted hijklmno 68H(104) to 6FH(111) In this case the bit of the top 2 of every 4 bytes is set according to the column value, i.e. the bit is set in 3802H,3803H,3806H,3807H,etc. 3rd row - Keys PQRSTUVW Values 50H(80) to 57H(87) Shifted pqrstuvw 70H(112) to 77H(119) The top 4 of every 8 Bytes for this row are set. Notice the number of bytes affected is the Bit value of the row number, (3804H-3807H,etc). 4th roow - Keys XYZ Values 58H(88) to 5AH(90) Shifted xyz 78H(120) to 7AH(122) The top 8 of every 16 Bytes is affected. There are no keys for values 5BH(91) to 5FH(95) as the four arrow symbols that these values give with PRINT CHR$ are used for control codes, i.e. 3808H-280FH, etc. N.B. Some models of the PCM-80, Video Genie and System 80 use 4 of these spaces as special function keys. 5th row - Keys 01234567 Values 30H(48) to 37H(55) Shifted !"=$%&' 20H(32) to 27H(39) In this case the bit of the top 16 of every 32 bytees is set according to the column value, i.e. 3800H-381FH,3820H-383FH,etc. 6th row - Keys 89:;<=>? Values 38H(56) to 3FH(63) Keys ()"+,-./ 28H(40) to 2FH(47) In this case the bit of the top 32 of every 64 bytes is set according to the column value, i.e. 3820H-383FH,3840H-385FH,etc. 7th row - Enter = (0DH) CLS = (1H) Break = (01H) Up Arrow = (??H) Down Arrow =(0AH) Left Arrow (08H) Right Arrow = (09H) Space Bar = (20H) In the top 64 of every 128 Bytes the Bit is set corresponding to the Bit Column on the Keyboard Diagram, i.e. 3840H-387FH,38C8H-38FFH,etc. 8th row - The only value here is the 01H of the Shift Key In the top 128 of every 256 Bytes the VAlue 01H is ORed (3880H-38FFH) Chapter 1 R O M Page 6 VIDEO MEMORY 3C00H - 3FFFH = 15360 to 16383 :- 1024 Bytes This is the Memory that the Screen uses. The Video is also Memory mapped and is available to the Programmer through PRINT, PRINT@, POKE&PEEK, and other Functions. Each line on the screen is 64 Bytes long and there are 16 Lines. Total Bytes used on the Screen is 16*64=1024, 1 byte per screen position. A particular position on the Screen can be accessed using PRINT@ by (Line No.-1) * 64 + TAB(POS). This means that by POKEing (15360+(Line No.-1)*64+TAB),X or PRINT CHR$(X) the Screen can be filled with :- A Control Code Value 00H - 1FH ( 0 to 31 ) A Character Value 20H - 7FH ( 32 to 127 ) A Graphics Symbol Value 80H - BFH ( 128 to 191 ) A Space Compression Code Value C0H - FFH ( 192 to 255 ) In actual fact the only way to place a Byte in the bottom right hand corner of the screen is by POKEing as PRINTing causes an automatic line feed and the top line of the screen is overwritten by the second line. A very good way to save memory for a heading or a Graphics design or a fancy Screen format is to make a String with as many Bytes as you may need. You can construct a String with any values you like from 00 to 255 from a Monitor or else from BASIC using :- A = PEEK (VARPTR(STRING)+1) + PEEK (VARPTR(STRING)+2*256 then POKE A + BYTE NO-1,X An example of this is when you want to have a Graphics symbol in a Screen Diagram. The BASIC line is entered with a "*" in the place where a "CHR$(170)" was wanted. Then from DEBUG in the DOS or from BASIC by PEEKing and POKEing, the Value can be changed (2AH(42) to AAH = CHR$(170) to give the result you want. When listed the line shows "KILL" in that spot. See ASCII codes for all reserved word values. The Space Compression Codes can be veryy usefully employed in this forrmat to save code when spaces are needed. Note :- The Space Compression Codes do not mean PRINT TAB(X) but PRINT X Spaces where X is the number (0-63) of the value above C0H (192), (C0H(192)-FFH(255)). Page 6 R O M Chapter 1 CHAPTER 2 THE MEMORY REFERENCE RAM THE COMMUNICATIONS REGION In this Chapter we look at the first part of the Communications Region and examine the following areas :- Restarts ....................... Page 7 Device Control Blocks .......... Page 14 DOS Storage Area ............... Page 16 Basic Data Storage Area ........ Page 18 The Accumulators ............... Page 20 Model III Extra Addresses ...... Page 21 RESTARTS In the TRS-80 there are eight of these RESTARTS. When a Restart instr- uction is given, the Program Counter is set to the location in ROM formed by prefixing "00" to the RET value. For example RST 08H jumps to 0008H or RST 30H to 0030H. At each of these addresses except 0000H, there is a Jump to the Communications Area. The contents at the Target addresses in the Communications Area differ according to wheather the Computer was initialised by Level II or Disk. ------------------------------------------------------------------------- | RST Code Addr. Restart Jumps at Target Address | | Address Mod I Mod III | | Contains Lev2 DOS Lev2 DOS | |-----------------------------------------------------------------------| | RST 00H C7H 0000H Start of ROM = IPL | | RST 08H CFH 0008H JP 4000H 1C96H 1C96H 1C96H 1C96H | | RST 10H D7H 0010H JP 4003H 1D78H 1D78H 1D78H 1D78H | | RST 18H DFH 0018H JP 4006H 1C90H 1C90H 1C90H 1C90H | | RST 20H E7H 0020H JP 4009H 25D9H 25D9H 25D9H 25D9H | | RST 28H EFH 0028H JP 400CH Return 4BC2H Return 4B67H | | RST 30H F7H 0030H JP 400FH Return 4609H Return 45D4H | | RST 38H FFH 0038h JP 4012H EI+Ret 45F2H 3018H 3018H | ------------------------------------------------------------------------- Chapter 2 R A M Page 7 RESTARTS RST 00H Code C7H The RESET Restart The first RST, has the code C7H and sends the Computer to Address 0000H i.e. it resets or reboots. ::::::::::::::::::: RST 08H Code CFH The Compare Byte Restart 0008H contains Jump to 4000H. 4000H contains :- Both Level II & DOS - Mods I & III : JP 1C96H (C3 96 1C) At 1C96H is the ROM routine that compares the byte pointed to by the HL Register with the Byte in Memory immediately following the RST 08H call. This Restart should only be used when Basic has been initialized since if the bytes do not match the syntax error code will be accesses and, with Basic not initialised, the neccessary communications region pointers will not have been initialized to correct values. The return address on the stack is incremented past the compare byte and if the bytes match, control passes to the RST 10H code to access the next valid character before returning to the caller. A typical use of this Restart is to test for the correct syntax within a Basic program statement. As an example to POKE statement requires comma between the address and the value and the RST 10H is used to ascertain if this separation is present. The code at 1C96H is as follows :- 1C96H 7E LD A,(HL) ; Get value to be compared 1C97H E3 EX (SP),HL ; Save return Address 1C98H BE CP (HL) ; Compare with Byte following 1C99H 23 INC HL ; Bump return address 1C9AH E3 EX (SP),HL ; Restore return Address 1C9BH CA 78 10 JP Z,1078H ; Go to RST 10 if correct 1C9EH .3 97 19 JP 1997H ; Signal Error if incorrect Page 8 R A M Chapter 2 RESTARTS RST 10H Code D7H The numeric test Restart 0010H contains Jump to 4003H - 4003H contains Both Level II & DOS - Mods I & III : JP 1D78H (C3 78 1D) The purpose of the RST 10H code is to extract the next chaaracter from the code pointed to by the HL register pair. The HL Register pair is used by the interpreter to point to the current code being executed under Basic. Thee RST 10H code is used extensively by Basic to test for end of statement and wheather or not the next valid character is numeric. This Address is changed by ESF initialisation to 3082H (C3 82 30). This is the way the ESF intercepts Basic Commands to execute the "@" Functions. The routine at 3082H interprets and passes control to the code involved. The valid character extraction is accomplished by INCrementing HL, skipping irrelevant characters (Spaces, 09H or 0AH) and returning with the next character in the 'A' Register. The Zero flag is set if the character is a 00H or 3AH (:)both characters signifying end of statement. If the character is numeric the Carry flag is set. A RST 10H is performed prior to Basic interbreting any Basic state- ment whether from a Basic program or the Command mode. This is the reason that, for the most part, the interpreter will ignore any spaces or CHR$(10) (line feeds) it encounters in a statement. The code at 1D78H is as follows :- 1D78H 23 INC HL ; Bump to next character 1D79H 7E LD A,(HL) ; Get next character 1D7AH FE 3A CP 3AH ; Compare with colon 1D7CH DD RET NC ; Return if >-3A (alhpabetic) 1D7DH FE 2C CP 20H ; Else test for a space 1D7FH CA 78 10 JP Z,1C78H ; If so get next character 1D82H FE 08 CP 08H ; Compare with vertical Tab 1084H 3D 05 JR NC,1D.. ; Go if 0B-39 control, numeric 1D86H FE 09 CP 09H ; Test for horizontal Tab or LF 1D88H D2 78 10 JP NC,1D72H ; If not get next character 1D8BH FE 33 CP 33H ; Compare with ASCII "0" 1D8DH 3F CCF ; Set Carry flag if numeric 1D8EH 3C INC A ; Check for zero byte so as 1D8EH 30 DEC A ; not to affect Carry flag 1D90H C9 RET ; Return to caller Chapter 2 R A M Page 9 RESTARTS RST 18H Code DFH The Compare HL/DE Restart 0018H contains Jump to 4006H. - 4006H contains :- Both Level II & DOS - Mods I & III : JP 1C90H (C3 90 1C) This again is a compare, but in this caseit is a comparison of the contents of the HL and DE Registers and the result is Signed by both the CARRY and ZERO Flags as follows :- ------------------------------------------------------ | HL < DE : C : CARRY FLAG SET IF LESS | | HL > DE : NC : NO CARRY IF MORE | | HL <> DE : NZ : ZERO FLAG RESET IF UNEQUAL | | HL = DE : Z : ZERO FLAG SET IF EQUAL | ------------------------------------------------------ The ROM code at 1C90H is as follows :- 1C9CH 7C LD A,H ; Get Value of H in A 1C91H 92 SUB D ; Subtract D 1C92H C0 RET NZ ; Go back if unequal 1C93H 7D LD A,L ; Get Value of L in A 1C94H 93 SUB E ; Subtract E 1C95H C9 RET ; Return This code willl not work for signed Integers (unless positive). It also destroys the previous contents of "A". An example of use of the RST 18H, it is assumed that the numeric input must be within pre-determined maximum and minimum values. In this example, we use the ROM call to 1E5AH to convert the input from ASCII to Binary - the result being returned in the DE Register pair. 8000H 21 xx XX LD HL,Input ; After Input 8003H 2B DEC HL ; Decrement for RST 10H 8004H 07 RST 10H ; to ensure it is numeric 8005H D2 yy YY JP NC,Error ; If not then error message 8008H CD 5A 1E CALL 1E5AH ; Get binary of input 800BH 21 mm MM LD HL,Max ; Upper limit value 800EH DF RST 18H ; Compare with Input value 800FH 0A yy YY JP C,Error ; Carry if > Maximum 8013H 21 nn NN LD HL,Min ; Lower limit value 8016H DF RST 18H ; Compare with Input value 8017H D2 yy YY JP NC,Error ; No Carry if < Minimum 801AH ....... Process value in the DE Register from 1E5AH Call Page 10 R A M Chapter 2 RESTARTS RST 20H Code E7H The Date Type Test Restart 0020H contains Jump to 4009H - 4009H contains Both Level II & DOS - Mods I & III : JP 25D9H (C3 D9 25) This tests the Data Type Flag (40AFH) and returns a value in the "A" Register as well as the Flags as follows :- -------------------------------------------------------------------------- | 40AFH Value Flags Set Number Returned in "A" | -------------------------------------------------------------------------- | 02 = INTEGER NZ , C , M , E -1 | | 03 = STRING Z , C , P , E 0 | | 04 = SINGLE NZ , C , P , O 1 | | 08 = DOUBLE NZ , NC , P , E 5 | -------------------------------------------------------------------------- N.B.- The Programmer changing the Number-Type Flag or the Accumulator creates the possibility of them being out of phase. The code at 25D9H is at follows :- 25D9H 3A AF 4D LD A,(4DAFH) ; Load data type flag 25DCH FE D8 CP D9H ; Is it double precision 25DEH 30 08 JP NC,25E8H ; If so then jump 25E0H 06 03 SUB 03H ; Not double precision 25E2H B7 OR A ; then reset status flags 25E3H 37 SCF ; and exit with 25E4H C9 RET ; Carry flag set 25E5H D6 03 SUB 03H ; For double precision rest 25E7H B7 OR A ; status flags & exit with 25E8H C9 RET ; Carry flag reset. As an example of the use of RST 20H, assume we test the result of the addition of two Integer values to see if the result is still an Integer (If overflow occurrs it wuld be single precision.) The example uses the ROM call 0B2DH with the result in both the Accumulator and HL. 8C00H 3E 02 LD A,2 ; Integer Code 8002H 32 AF 40 LD (40AFH),A ; Set Integer Flag 8005H ED 4B D2 98 LD BC,(VALUE1) ; First Value 8009H 2A 02 9C LD HL,(VALUE2) ; Second Value 800CH CD 20 0B CALL 0B2CH ; Integer Add 800FH E7 RST 20H ; Overflow ? 8010H F2 yy YY JP A,TOO LARGE ; Not an Integer 8013H 22 D4 90 LD (RESULT),HL ; Save Result 8016H ............ Process the stored result Chapter 2 R A M Page 11 RESTARTS RST 28H Code 28H The DOS Function Call Restart 0023H contains Jump to 400CH 400CH contains Level II : Return (C9) DOS Model I : JP 43C2H (C3 C2 4B) DOS Model III : JP 4367H (C3 67 43) In Level II if there is no action here. But in the DOS, this Address is used by more than 30 Sequences. Thus it is called the DOS Function Call Restart. Action taken depends on the Value of Register "A". The major use by the DOS of the RST 28H routine is in loading System modules to perform DOS or Basic /SYS functions. The /SYS file Directory entries all have fixed positions relative to the Directory. The /SYS module is not accessed through the HIT (hashed name storage) sector but is found using the contents of the 'A' register, the lower bits of which contain the relative sector (-2) in the Directory and the position in that sector. Thus the name of the /SYS file is not hashed for a match in the IT sector as user files are, but the Directory entry is accessed directly. The top 3 bits of 'A' are used to differentiate between sub-functions. Sometimes other registers contain parameters for use by the module. The RST28H code is one of the most practial and thus the most often used function of NEWDOS/80. Some of the uses of an RST 28H: pre loading a /SYS module or a program file, executing a DOS command, open a file, close a file, kill a file, create a Directory entry and many others, even enter a user interrupt routine into the Interrupt chain. All these functions require ................ set for use by the routine. e.g. .....ting to ASCII storage of file ..... .. ........ to the FCB, etc. The first two Bytes at 4BC2H (or 4D67H in Model III ..........) .... remove the previous Stack contents (the only RST to do this). After processing, control is returned to the previous Address .. ........ This means that pushing the required return address onto the stack ......... if the RST 28H will return control to the operating program. In the process of executing some modules, .. perform part of the function, load other /SYS modules. The possibilities are almost endless. Examples include :- Loading SYS1/SYS which is the DOS command interpreter and is accessed to return to the DOS Ready prompt. This module naturally has the Library of commands resident in it ......... command does not load any other module Debug (SYS5/SYS) is (started) with a value of 27H in 'A' and an RST 28H. Error conditions are handled by SYS4/SYS for DOS and SYS13/SYS for Basic both loaded on the RST 28H function call. Accessing the routine in the DOS which executes a USR routine is also handled by this function as well as many other routines. Page 12 R A M Chapter 2 RESTARTS RST 30H Code F7H The DEBUG Restart 0030H contains Jump to 400FH - 400FH contains :- Level II : Return (C9) Model I DOS : JP 4609H (C3 09 46) Model III DOS : JP 45D4H (C3 D4 45) As you see there is again no action in Level II. But in DOS this is the DEBUG load Restart, the Code being : 4609H F6 RST30H PUSH AF ; Dummy to retain the ; proper Return Address 460AH 3E 27 LD A,77H ; Key for DEBUG Code 460CH EF RST 28H ; Go to DEUG. 460DH ..................................... ; Program continues ::::::::::::::::::::::: RST 38H Code FFH The Interrupt Restart 0038H contains Jump to 4012H - 4012H contains :- Model I Lev II : Enable Interrupts & Return (FB C9) Model I DOS : JP 45F2H = Interrupt Service Routine Mod III Lev2 + DOS : JP 301BH = Interrupt Service Routine This is the System Entry point for all interrupts. The TRS80 uses only 1M 1 (Interrupt Mode 1). In Level II it executes a "EI" (FBH - ENABLE INTERRUPTS and a (C9H = RETURN) and immediately returns to the caller. The byte at 4012H in the Model I has been documented as being an F3H which is Disable Interrupts. However, in reality, it is an FBH, the opposite, Enable Interrupts. This code hasd the unfortunate effect of causing the CPU to hang if the interrupts are already enabled when an Expansion interface connected. In the DOS it is a JUMP to the INTERRUPT PROCESSOR. The reason for the Interrupt is determined and the next item from the Interrupt Service Routine is executed (mostly a Clock Interrupt). After this is completed control returns to the point of Interrupt and the Progarm continues. Chapter 2 R A M Page 13 DEVICE CONTROL BLOCKS KEYBOARD CONTROL BLOCK 4015H - 401CH :- This area has the Keyboard Information Model I - 4015H (16405) - The DCB Type Value ( 01 ) 4016H (16406) - Driver Address - least significant byte 4017H (16407) - Driver Address - most significant byte In Level II = 03E3H : In DOS = 4516H : With ESF : 375CH 4018H (16408) to 401AH (16410) - Not used 401BH (16411) - Holds first of the Keyboard 2 Letter codes "K" 401CH (16412) - Contains second letter "I". Model III - 4015H (16405) - The DCB Type Value ( C1 ) 4016H (16406) - Driver Address - least significant byte 4017H (16407) - Driver Address - most significant byte Il Level II = 3024H : In DOS = 44EBH 4018H (16408) - Right Shift Key status byte 4019H (16409) - Upper/Lower case toggle (0=U/C: Non zero=L/C) 401AH (16410) - Count interrupts per cursor char change (2) 401BH (16411) - Flag byte for cursor change 0=space 1=curs.char 401CH (16412) - Cursor blink toggle (0=Blink:Non zero=no blink) VIDEO DISPLAY CONTROL BLOCK 401DH - 4024H :- This area has the Video Information Model I - 401DH (16413) - DCB Type Value ( 07 ) 401EH (16414) - Driver Address - least significant byte 401FH (16415) - Driver Address - most significant byte In Level II = 0468H : In DOS = 4505H : with ESF = 0458H 4020H (16416) - Cursor Position - least significant byte 4021H (16417) - Cursor Position - most significant byte 4022H (16418) - Character under Cursor storage 4023H (16419) - Key Letter - first letter ( D ) 4024H (16420) - Key Letter - second letter ( O ) Model III - 401DH (16413) - DCB Type Value ( 07 ) 401EH (16414) - Driver Address - least significant byte 401FH (16415) - Driver Address - most significant byte In Level II = 0473H : In DOS = 0473H 4020H (16416) - Cursor Position - least significant byte 4021H (16417) - Cursor Position - most significant byte 4022H (16418) - Character under Cursor (0 = Blink Inactive) 4023H (16419) - Cursor Character ( 0 if default BoH(176)) 4024H (16420) - Control Byte - Character sets exchange Page 14 R A M Chapter 2 DEVICE CONTROL BLOCKS LINE PRINTER CONTROL BLOCK 4025H TO 402CH :- This area has the Printer DCB Information Model I - 4025H (16421) THE DCB Type Value ( 06 ) 4026H (16422) Driver Address - least significant byte 4027H (16423) Driver Address - most significant byte In Level II & DOS & ESF = 058DH 4028H (16424) Max.Lines per Page + 1 : in IPL 43H(67) 4029H (16425) No. of Lines Printed + 1 on the page so far 402AH (16426) Contains 0 402BH (16427) First Letter of Key Letters ( P ) 402CH (16428) Second Letter ( R ) Model III - 4025H (16421) THE DCB Type Value ( 06 ) 4026H (16422) Driver Address - least significant byte 4027H (16423) Driver Address - most significant byte In Level II & DOS = 058DH 4028H (16424) Max.Lines per Page + 1 : in IPL 43H(67) 4029H (16425) No. of Lines Printed + 1 on the page so far 402AH (16426) Current Printer Tab position 402BH (16327) WIDTH parameter - Set by FORMS (SYS15/SYS) = Maximum Line length - 2 402CH (16328) Default Maximum Characters per Line - 2 .................................... Device Control Blocks - Type Values Bit 1 : If set Device is capable of being used for Output Bit 0 : If set Device is capable of being used for Input The ROM I/O routine handling DCBs checks each Device to see if it has the required capability. The ROUTE command causes the DCB type value to be set to C0H if routed elsewhere. Address 4033H is used by the DOS to vector to the routine handling the ROUTE logic. If a ROUTE Command is not current to contents of 4033H can be used as a Jump to a user routine by loading the keyboard DCB type value with 0. That is all the Control Blocks in the Model I. The additional Control Blocks for the Model III are explained on Pages 21 and 22. These involve RS-232C and ROUTE Control Blocks. Chapter 2 R A M page 15 THE DATA STORAGE AREA 402DH - 407FH :- 16429 - 16511 : 83 Bytes This area is used mainly by DOS. There is a Keyboard Work area which is common to Model I & model III both Level II and DOS. Other than this the area is used for DOS storage and the Interrupts. MODEL I IN LEVEL II :- 402DH (16429) contains Jump to 5000H (could contain whatever) 403CH (16432) contains RESTART 08H or RESET 4031H - 4032H contains C0 00 4033H (16435) contains .. 00 C9 = Load A with 0 and RETurn 4036H - 403CH is a Work area for the Keyboard Driver 403DH - 405CH is initialized by the IPL to zeroes. 405DH - 407DH (16477-16607) Used by Stack during IPL could be used for User's USR routines. 407EH - 407FH Storage or not used UNDER NEWDOS/80 :- 402DH (16429) DCB entry point - Jump to 440CH 4030H (16432) Error already displayed exit to DOS This is the address DOS jumps to at DOS READY to load the command interpreter (SYS1/SYS). 4033H (16435) Call Device driver in the DOS (Jump 4ADBH) 4036H (16438) Work area for SYS0/SYS and Keyboard Driver 403DH (16445) Control Byte for 64/32 char. screen (see Port FFH) 4040H (16448) Used by Interrupts - Cyclic Counter 4041H - 4046H (16449) Storage - Secs Mins Hrs Year Day Mth order 4047H (16455) Storage - Load address for DOS System Modules (5200H) 4049H (16457) Contains Memory Size as shown in the HIMEM value 404BH (16459) Current Interrupt Status Bytes Level 2 (DOS = 5DH) 404DH - 405CH (16461-16476) Interrupt Sub-routine Vectors 405DH - 4062H Storage or not used 4063H - 407BH (16403) Temporary DOS routine (Converts DE to ASCII) 407CH - 407EH (16508) Storage Parameters for Time Checking OTHER DOS STORAGE :- 4312H is the control byte for the Break key 4427H contains the 82H referring to NEWDOS/80 Version 2 442BH contains 01 for Model I 4410H - 4411H is the vector to insert an interrupt routine Page 16 R A M Chapter 2 DOS DATA STORAGE AREA MODEL III 402DH - 407FH ;- 16429 - 16511 - 83 Bytes IN LEVEL II :- 402DH (16429) Contains Jump to 0000H 4030H (16432) Contains 07H = RESTART 00H = Reset 4131H - 4132H contain 00 00 4133H - 4034H (16435-16436) contains AF C9 = XOR A(A=0) and Return 4036H - 403CH (16438-16444) Work area for Keyboard Driver 403DH (16445) Interrupt Jump for I/O (35FBH:35FAH if inactive) 4040H (16448) Interrupt Jump for RS-232C Error (365AH) 4043H (16451) Interrupt Jump for Undefined Interrupt (3680H) 4046H (16454) Interrupt Jump for Time Clock (3529H) 4049H (16457) contains C7H = RESTART 00H = Reset 404AH - 404BH contain 00 00 404CH - 407CH (16450-16508) Used by Staack during IPL 407DH - 407FH (16509-16511) Storage or not used UNDER NEWDOS/80 :- 402DH (16429) DOS entry point - Jump to 4400H 4030H (16432) Error already displayed exit to DOS 4033H (16435) Call Device driver in the DOS (Jump 4A80H) 4036H - 403CH (16438-16444) Work area of the Keybrd Driver & SYS0/SYS 403DH (16445) Interrupt Jump for I/On(35FBH:35FAH if inactive) 4040H (16448) Interrupt Jump for RS-232C Error (365AH) 4043H (16451) Interrupt Jump for Undefined Interrupt (3680H) 4046H (16454) Interrupt Jump for Time Clock (4551H) 4049H (16457) Interrupt Jump for I/O during IPL (43A2H) Return from Non-maskable Interrupt after IPL. 404BH - 4057H (16459) 13 byte work area for Utilities & DOS 4058H - 407FH (16466-16511) Storage or not used OTHER DOS STORAGE :- 441FH is the cyclic counter for Model III 4411H - 4412H contains the HIMEM value in Model III 4478H is the control byte for the Break key in Model III 4427H contaains the 82H referring to NEWDOS/80 Version 2 4428H contains 03 signifying Model III 447BH - 447CH is the Vector to insert an interrupt routine in Model III Chapter 2 R A M Page 17 THE BASIC STORAGE AREA Common to Models I & III 4080H - 411CH :- 16512 - 16668 : 157 Bytes All of this area is used by Basic in both the Moldels I and III and in both Level II and Disk basic. It is used entirely for Basic program parameters, routines and addresses. The Basic interpreter relies on this area to find the parameters for any action it takes and uses bytes here for condition storage, addresses and values. For example the 3 bytes at 40A2-3H telll the interpreter the current line number being executed and if the byte at 40DCH contains a 1 the interpreter knows that a FOR/NEXT loop is in progress. 4080H - 408DH (16512-16525) Division Support Routine This whole area from 1080 too 10A5H is moved from 18F2 to 1904H by the IPLl for use by Basic. 408EH (16526) Address of USR Routine - Level II - contains 1E4AH (Illegal function call) if inactive. 4090H - 4092H (16528-16530) Random number seed (3 bytes) 4093H - 4098H (16531-16536) Port handling 4099H (16537) Contains last character typed before Break 409AH (16538) Current ERR error code stored here 409BH (16539) Number of characters in current printer line 409CH (16540) Output Device code: -1=Cassette,0=Video,1=Printer 409DH (16541) Maximum width of video dislpay line (works ONLY if expression processed by ROM numeric evaluator) 409EH (16542) Size of video line after whch " PRINT , " causes a Line Feed to occur. 409FH (16543) Flag byte for LIST print: 1=inside quotes: 0=outside (If inside quotes Mod III will print Symbols- not SCCś) 40A0H (16544) Address of String area lower boundary 40A2H (16546) Basic line number being executed (FFFFH if inactive) 40A4H (16548) Address of start of Basic Program 40A6H (16550) Cursor TAB position (POS value) 40A7H (16551) Points to Address of Keyboard Buffer + 2 40A9H (16553) Input flag - 0 = Cassette , else non-zero 40AAH (16554) Random number seed ) 4 byte 40ABH (16555) Value from Refresh Register ) Random Number 40ACH (16556) Last 2 byte Random number ) storage 40AEH (16558) Flag byte - 0 = location named variable , 1 = Create 40AFH (16559) Type byte - Accumulator variable type - 2=% Integer, J=$ String, 4=! Single Prec.& 8=# Double Prec. 40B1H (16561) Top of Memory Pointer Page 18 R A M Chapter 2 BASIC DATA STORAGE AREA Basic storage common to Models I & III 40B3H - 40D7H - String work area including :- 40B3H (16563) - Address of next available location in String area 405BH (16565) - 40D2H Contains the String Work Area 40D3H (16595) - Contains length of current String 40D4H (16596) - Points to Address of current String 40D6H (16598) - Address of next available unused String space 40D8H (16600) 2 Functions - last byte executed in current Statement or - edit flag during Print Using 40DAH (16602) Line Number of last Data statement read 40DCH (16604) FOR/NEXT flag - 0 = not in progress, 1 = in progress 40DDH (16605) Flag byte - 1= Input of BASIC Statements, 0= inactive 40DEH (16606) Read flag - 0= READ active, 1= Input statement active 40DFH (16607) Execution Address for System Tape or VARPTR of current variable 40E1H (16609) Flag - 0= Inactive, 1 - Auto mode active 40E2H (16610) Current line number (used by INPUT or AUTO) 40E4H (16612) Auto line increment 40E6H (16614) Address of Statement being currently executed 40E8H (16616) Contains current Stack Address 40EAH (16618) Line number in which Error occurred 40ECH (16620) Current Line number - used by "," edit or "." list. 40EEH (16622) Address of byte after Error ( used by RESUME ) 40F0H (16624) Addr of target Line = in IN ERROR OTO Statament. 40F2H (16626) Flag byte - FFH if Error ( cleared by RESUME ) 40F3H (16627) Addr of last byte succesfully executed also the Address of the Decimal Point in the Print Buffer 40F5H (16629) Last Line number to be executed. Used by STOP,END,BREAK 40F7H (16631) Addr of next byte to be executed. Used by CONT. 40F9H (16633) Address of simple variables & End Basic Program 40FBH (16635) Address of dimensioned variables 40FDH (16637) Address of start of free Memory 40FFH (16639) Points to byte after last char read (READ Statement) 4101H - 411AH Variable type declaration list. The 26 Bytes here are (16641) - loaded with 04H by a routine at 1B64H. This routine (16666) is called during IPL initialisation, on NEW or the DOS command CLEAR, or after completion of EDITing a Basic Program line. 411BH (16667) Flag byte - 1 = Trace active, 0 = not active 411CH (16668) Temporary storage for floating point number Chapter 2 R A M page 19 THE ACCUMULATORS 411DH = 4124H - 16669 - 16676 : The Main Accumulator (ACC or WRA1) -------------------------------------------------------------------------------------- | Address Integer Single Precision Double Precision | |------------------------------------------------------------------------------------| | 411DH (16669) Least sign. byte | | 411EH (16670) Next Byte | | 411FH (16671) Next byte | | 4120H (16672) Next byte | | 4121H (16673) LSB Least sign. byte Next byte | | 4122H (16674) MSB Next byte Next byte | | 4123H (16675) Most sign. byte Most sign. byte | | 4124H (16676) Exponent Exponent | -------------------------------------------------------------------------------------- 4125H (16677) : Holds signn of result of operants 4126H (16678) : Bit bucket used during Double precision addition 4127H - 412EH : 16679 - 16686 : Auxiliary Accumulator (AACC or WRA2) -------------------------------------------------------------------------------------- | Address Integer Single Precision Double Precision | |------------------------------------------------------------------------------------| | 4127H (16679) LSB Least sign. byte Least sign. byte | | 4128H (16680) MSB Next byte Next byte | | 4129H (16681) Next byte Next byte | | 412AH (16682) Most sign. byte Next byte | | 412BH (16683) Exponent Next byte | | 412CH (16684) Next byte | | 412DH (16685) Most sign. byte | | 412EH (16686) Exponent | -------------------------------------------------------------------------------------- 4130H (16688) - 4149H (16713) : Print buffer 414AH (16714) - 4151H (16721) : Double Precision division storage 4152H (16722) - 41A5H (16808) : Disk Basic Reserved Word jumps Level II : loaded with jump to L3 Error by IPL 41A6H (16809) - 41E4H (16868) : ROM Call DOS Exits Level II : loaded with RETURNs by IPL Model II Level II :- 41E5H (16869) - 42E7H (17127) : Basic Input Buffer 42E9H (17129) : Start of Basic Program. Model III :- 41E5H (16869) : RS-232C Device Control Blocks (next Page). Page 20 R A M Chapter 2 Mod III RS-232C CONTROL BLOCKS 41E5H - 41ECH : 16869 - 16876 : The RS-232C Input DCB 41E5H (16869) : Recognition Code (01) 41E6H (16870) : Driver Address (301EH) 41E8H (16872) : Input Byte Buffer 41E9H (16873) - 41EAH (16874) : Control Bytes 41EBH (16875) - 41ECH (16876) :"RI" - Recognition letters 41EDH - 41FAH : 16877 - 16884 : The RS-232C Output DCB 41EDH (16877) : Recocnition Code Byte (02) 41EEH (16878) : Driver Address (3021H) 41F0H (16880) : Output 1 Byte Buffer 41F1H (16881) - 41F2H (16882) : Control Bytes 41F3H (16683) - 41F4H (16684) : "RO" - Recognition letters 41F5H - 41FCH : 16885 - 16892 : The RS-232C Initialisation DCB 41F5H (16885) : Recognition Code Byte (02) 41F6H (16886) : Initialisation Driver Address (301H) 41F8H (16888) : Baud Rate : Send = Bits 7-4 : Receive = Bits 3-0 --------------------------------------------------------------------------- | Rate Error Code | Rate Error Code | -------------------------------------|------------------------------------- | 50 0 0 | 1800 0 8 | | 75 0 1 | 2000 0.253 9 | | 110 0 2 | 2400 0 10 | | 134.5 0.016 3 | 3600 0 11 | | 150 0 4 | 4800 0 12 | | 300 0 5 | 7200 0 13 | | 600 0 6 | 9600 0 14 | | 1200 0 7 | 19200 3.123 15 | --------------------------------------------------------------------------- 41F9H (16889) : Parity/Word Length/Stop Bit Code Byte as follows :- ---------------------------------------------------------------------- | Bit 7 - 0 = Odd Parity 1 = Even Parity | | Bit 6&5 - 00 = 5 Bit Words 01 = 6 Bit Words | | 10 = 7 Bit Words 11 = 8 Bit Words | | Bit 4 - 0 = 1 Stop Bit 1 = 2 Stop Bits | | Bit 3 - 0 = Enable Parity 1 = Disable Parity | | Bit 2 - 0 = Disable Transmitter 1 = Enable Transmitter | | Bit 1 - 0 = Set Data Terminal Ready (DTR) Signal low (Ready) | | 1 = Set Data Terminal Ready (DTR) Signal high | | Bit 0 - 0 = Set Request to Send (RTS) Signal low (Data ready) | | 1 = Set Request to Send Signal high (No request active) | ---------------------------------------------------------------------- 41FAH (16890) - Control Byte for Wait for Serial I/O 0 = Do not wait : Non zero = Wait 41FBH (16891) - 41FCH (16892) : "RN" = Recognition letters N.B. :- After changing RAM Control Bytes, the RS-232C must be reinitialised to have the new parameters for execution. Chapter 2 R A M Page 21 MODEL III EXTRA RAM ADDRESSES 41FDH - 4202H (16893) : ROM 6 byte Keyboard Work Area 4203H (16899) : DOS - SYS1/SYS load Jump (JP 403CH) : Level II - JP 282EH = Disable Interrupts & Go to Basic 4206H (16902) : Interrupt Jump for RS-232C Output Register empty 4209H (16905) : Interrupt Jump for RS-232C Input EOT signal 4210H (16912) : Control Byte for Port EC (see Page 32). 4211H (16913) : Cassette Baud Rate Toggle (0=500, NonZero=1500) 4212H (16914) : Cassette Counter Byte (Tape load - flashes "*") 4213H (16915) : Control Byte for Port E0H (Interrupt Byte) 4214H (16916) : Video scroll protect count of lines (0-7) 4216H (16919) : Count interrupts per Time/Date opdate (25/30) 4217H (16919) to 421CH (16924) - Time and Date storage 421DH - 4224H : 16925 - 16932 = 8 Bytes : ROUTE Control Block 421DH (16925) : Recognition Code (02) 421EH (16926) : Driver Routine Address (3739H) 4220H (16928) : "ROUTE" Command Destination Letters (See below) 4222H (16930) : "ROUTE" Command Source Letters (See below) KI = Keyboard: DO = Video: PR = Printer: MM = Main Memory: NL = Null RI = RS-232C Input : RO = RS-232C Output : RN = RS-232C Initialise 4224H (16932) : ...... byte for CONTROL (ShftDwnArr) FFH=inactive Model III Level II :- 4225H - 42E4H : Storage or not used by Level II. 42E5H - 42E7H : Level II Basic Input Buffer 42E9H : Basic program etc. Model III NEWDOS/80 :- 4225H - 4274H : DOS Command Buffer 4275H - 427FH : SYSTEM Parameter Storage 4280H - 42B8H : PDRIVE Storage including :- 4291H - 429AH = Drive 0 : 429BH - 42A4H = Drive 1 42A5H - 42AEH = Drive 2 : 42AFH - 42B8H = Drive 3 4300H - 43FFH : DOS Sector Buffer as well as 5100H - 51FFH 4400H - on : DOS main SYS0/SYS Module :::::::::::::::::::::::: Note :- Control is implemented on the Model III by simultaneously pressing the LEFT SHIFT key + the DOWN ARROW key + the key involved. The left SHIFT key must be used. This function is used in some Tandy Software e.g. Press the SHIFT key + DOWN ARROW key + the asterisk (the multiply key). This is the standard Model III way to get the screen .... ..." function of NEWDOS/80. The routine is in ROM at 01D9H. Note also that the Model I Basic Entry point at 06CCH is not available in the Model III. Use 1A19H. Page 22 R A M Chapter 2 THE MEMORY REFERENCE CHAPTER 3 DOS NEWDOS/80 RAM USAGE MODEL I 4152H - 41A8H : Disk Basic Reserved Word Jumps 41A9H - 41E4H : ROM Call DOS Exits 41E5H - 41FFH : DOS Storage 4200H - 42FFH : DOS Sector buffer (also 5100H - 51FFH) 4300H - 4317h : Storage including PDRIVE & SYSTEM specs 4318H - 4367H : DOS Command buffer 4368H - 4370H : SYSTEM Storage 4371H - 439AH : PDRIVE Storage 439BH - 43FFH : DOS Storage 4400H - 4CFFH : DOS Main resident module (SYS0/SYS) 4D00H - 51FFH : DOS Overlay area 5200H - 56FFH : BASIC Overlay area 5700H - 64C9H : Disk BASIC Resident module 64C7H - 65C9H : Disk BASIC Input Buffer 65CAH - 66BCH : Disk I/O File Buffer (J) 6A46H - : Start of BASIC Programs MODEL III 4152H - 41A8H : Disk Basic Reserved Word Jumps 41A9H - 41E4H : ROM Call DOS Exits 41E5H - 41FCH : RS-232C Device Control Blocks 41FDH - 4224H : Storage 4225H - 4274H : DOS Command Buffer 4275H - 427FH : SYSTEM Storage 4280H - 42B8H : PDRIVE Storage 42B9H - 42FFH : DOS Storage 4300H - 43FFH : DOS Sector Buffer 4400H - 4CFFH : DOS Main resident module (SYS0/SYS) 4D00H - 51FFH : DOS Overlay area 5200H - 56FFH : BASIC Overlay area 5700H - 64C6H : Disk BASIC Resident module 64A0H - 65A2H : Disk BASIC Input Buffer 65CAH - 66BCH : Disk BASIC Storage 66BEH - 6A44H : Diak I/O File Buffers (Default 3) 6A46H - : Start of BASIC Programs Chapter 3 D O S Page 23 DISK BASIC RESERVED WORD JUMPS 4152H - 41A5H : Contain Disk Basic reserved word vectors. 28 Vectors. In Level II the IPL loads a Jump to the L3 Error routine in each. The level II Basic Reserved Word Jump Addrs are on Pages 58 & 59. In Disk Basic they ate initialised to Jumps to Addresses where the particular Disk Basic system has the routines to handle them. These addresses change between DOSes as the routines are placed in areas suitable to the different DOSes. The Jumps given hera are those for NEWDOS/80 Version 2. ------------------------------------------------------------------------------------ | Address Reserved Word Function Routine Routine | | Hex Dec Mod I Mod III | |----------------------------------------------------------------------------------| | 4152H 16722 CVI Convert to Integer 58F5H 58CEH | | 4155H 16725 FN Function 577FH 577FH | | 4158H 16728 CVS Convert to Single Precision 58F2H 58CBH | | 415BH 16731 DEF Define Varialbe or Function 5852H 583FH | | 415EH 16734 CVD Convert to Double Precision 58EFH 58C8H | | 4161H 16737 EOF End of File 58C5H 589EH | | 4164H 16740 LOC Location in File 5ED1H 5EAAH | | 4167H 16743 LOF Length of File 5EC9H 5EA.H | | 416AH 16746 MKI$ Make an Integer a String 58DEH 5837H | | 416DH 16749 MKS$ Make Single Precision String 58DEH 58B4H | | 4170H 16752 MKD$ Make Double Precision String 58D8H 5851H | | 4173H 16755 CMD DOS Command 57FFH 57ECH | | 4176H 16758 TIME$ Retrieving Time 58C4H 3030H | | 4179H 16761 OPEN Open FCB on file 5795H 5795H | | 417CH 16764 FIELD Define size of var. 5363H 5E3CH | | 417FH 16767 GET Input file data 6126H 60FFH | | 4182H 16770 PUT Output file data 612.H 60F2H | | 4185H 16773 CLOSE Close a file 5FA1H 5F7AH | | 4188H 16776 LOAD Load File into Memory 574AH 572EH | | 418BH 16779 MERGE Merge File into Memory 572EH 57E2H | | 418EH 16782 NAME FC error 1E4AH 1E4AH | | 4191H 16785 KILL Remove File from DIR 643CH 6415H | | 4194H 16788 & Convert hex to dec. 5790H 5790H | | 4197H 16791 LSET Var to buffer pad right 5908H 58E1H | | 419AH 16794 RSET Var to buffer pad left 5909H 59E2H | | 419DH 16797 INSTR String search 5786H 5786H | | 41A0H 16800 SAVE Output to Disk 573BH 573BH | | 41A3H 16803 LINE Input function 579FH 579FH | ------------------------------------------------------------------------------------ Page 24 D O S Chapter 3 ROM CALL DISK BASIC EXITS 41A6H - 41E4H : 16806 - 16868 : 63 Bytes 21 Vectors In Level II the IPL loads the first Byte of these with a Return. The DOS will load the Addrs with Jumps appropriate to it's own System. These Addresses are called by ROM & are Disk Basic exits. The calls from these Routines are for Disk Basic to intercept the call from the function involved and give control to the Disk Basic routine. ------------------------------------------------------------------------------------------ | Address Called by Routine Routine Routine | | Model I Model III | |----------------------------------------------------------------------------------------| | 41A6H 16806 19ECH = DOS Basic Errors LD A,2FH + RST28H | | 41A9H 16809 27FEH = USR 5892H 587FH | | 41ACH 16812 1A1CH = Basic Re-entry 2169H 2169H | | 41AFH 16815 0388H = Keyboard Input 575DH 575DH | | 41B2H 16818 1AA1H = Basic Input 5756H 5756H | | 41B5H 16821 1ACCH = ( Basic Program line 63B3H 638CH | | 41B8H 16824 1AF2H = ( processing 63BCH 6395H | | 41BBH 16827 1B8CH = RUN, CLEAR & NEW 57B6H 6F8FH | | 41BEH 16830 2174H = PRINT 6438H 6438H | | 41C1H 16833 032CH = Output byte 6076H 604FH | | 41C4H 16836 03..H = Scan keyboard 63C0H 6399H | | 41C7H 16839 1EA6H = RUN 5746H 5746H | | 41CAH 16842 20C6H = PRINT 5F52H 5F2BH | | 41CDH 16845 20C6H = PRINT# 574BH 5F24H | | 41D0H 16848 2103H = End PRINT processing 5FA0H 5F79H | | 41D3H 16851 2108H = PRINT# Cassette write 3F3BH 5F14H | | 41D6H 16854 2AECH = MID$ = 578BH 578BH | | 41D9H 16857 222DH = Middle INPUT/READ 579AH 579AH | | 41DCH 16860 2276H = End INPUT/READ 5EB9H 5E92H | | 41E2H 16863 02B2H = System 5FA0H 5F79H | ------------------------------------------------------------------------------------------ --- NEWDOS/80 USR ROUTINE POINTER ADDRESSES --- USR No Model I Model III USR No Model I Model III 0 573AH 22330 589DH 22685 5 5744H 22340 58A7H 22695 1 573CH 22332 589FH 22687 6 5746H 22342 58A9H 22697 2 573EH 22334 58A1H 22689 7 5748H 22344 58ABH 22699 3 5740H 22336 58A3H 22691 8 574AH 22346 58ADH 22701 4 5742H 22338 58A5H 22693 9 574CH 22348 58AFH 22703 Chapter 3 D O S Page 25 NEWDOS/80 DOS MODULES In Disk IPL, SYS0/SYS loads some 160 Bytes into the Communications Area to set up pointers and paramaters for the DOS. This covers 3 main areas. First the restarts are revectored too suit the DOS. Then 2 storage areas for DATE, TIME, interrupts, the PDRIVE and relevant SYSTEM specifications and Device Control Blocks are initialised. The Maain Module of DOS (SYS0/SYS) is loaded to 4400H - 50E7H, but the area 4D00H to the end is only used at BOOT and is overlaid immediatly by SYS1/SYS which interprets the Input of DOS Commands. The only SYS module, either DOS or Basic, that is over 1 gran long is the DOS module SYS6/SYS which handles the FORMAT, COPY, and APPEND commands. This module uses 6 grans in an area starting at the DOS overlay area at 4D00H and ending at 6FFFH. This area is used for the Basic resident module as well as the Basic overlay area so it is not surprising that use cannot be made of this module from Basic. ----------------------------------------------------------------------------- | Module Grans Resides Under Function | |---------------------------------------------------------------------------| | SYS0/SYS 3 4400H-4CFFH DOS- Resident- Disk I/O, Interrupts etc | | SYS1/SYS 1 4D00H-51FFH DOS- Interprets DOS commands | | SYS2/SYS 1 4D00H-51FFH DOS- DCB handling & RENAME | | SYS3/SYS 1 4D00H-51FFH DOS- DCB handling,BLINK,BREAK, | | CLOCK,LC,VERIFY & PURGE | | SYS4/SYS 1 4D00H-51FFH DOS- DOS Error messages | | SYS5/SYS 1 4D00H-51FFH DOS- DEBUG | | SYS6/SYS 1 4D00H-6FFFH DOS- FORMAT, COPY & APPEND | | SYS7/SYS 1 4D00H-51FFH DOS- TIME,DATE,AUTO,ATTRIB, | | PROT,DUMP,HIMEM | | SYS8/SYS 1 4D00H-51FFH DOS- DIR & FREE | | SYS9/SYS 1 4D00H-51FFH DOS- BOOT,CHAIN,CHNON,MDCOPY,PAUSE,STMT | | BASIC/CMD 4 5700H-64BFH BASIC- Resident Module | | SYS10/SYS 1 4D00H-51FFH BASIC- GET & PUT | | SYS11/SYS 1 4D00H-51FFH BASIC- RENUM | | SYS12/SYS 1 4D00H-51FFH BASIC- REF | | SYS13/SYS 1 4D00H-51FFH BASIC- ERROR Messages & part RENUM | | SYS14/SYS 1 4D00H-51FFH DOS- CLEAR,CREATE,ERROR,LIST,PRINT,ROUTE | | SYS15/SYS 1 4D00H-51FFH DOS- FORMS & SETCOM | | SYS16/SYS 1 4D00H-51FFH DOS- PDRIVE | | SYS17/SYS 1 4D00H-51FFH DOS- WRDIRP & SYSTEM | | SYS18/SYS 1 5200H-56FFH BASIC- Interprets BASIC Commands | | SYS19/SYS 1 5200H-56FFH BASIC- LOAD,SAVE,RUN,MERGE,CMD"F" | | SYS20/SYS 1 5200H-56FFH BASIC- BASIC Program executor | | SYS21/SYS 1 4D00H-51FFH BASIC- CMD"O" | ----------------------------------------------------------------------------- Page 26 D O S Chapter 3 DISK BASIC I/O FILE CONTROL BLOCKS On entering Basic you are able to allocate space for Disk Input/Output by the number of File areas that you request. This number can be from 0 to 15 (Default = 3). The syntax is as follows :- From DOS enter the Command - BASIC,n Also you may enter the Command - BASIC,nV This action saves "n" file areas for use in the Basic program. The "V" appended to the number of files areas to be set aside doubles the 256 bytes of space allocated for each Buffer. At the beginning of each FCB record in memory there is a block of 13 bytes which contains control information, followed by the 32 bytes of information which in turn is followed by the Buffer allocation. The 32 bytes contain ;- Byte 0 - bit 7 = Active flag 8 - EOF final sector offset 1 - access flags 9 - Record length 2 - ASC, ASE & Update flags 5,10,11 - 3 byte RBA of next record 3 & 4 - Buffer Address 8,12,13 - 3 byte RBA of EOF 5 - next record offset 14-22 - File Extents 6 - Drive Number 22-23 - FXDE pointer 7 - Directory Entry code (DEC) 24-31 - FXDE Extents The number of file areas is stored in the Model I in 5F88H and in the Model III in 5F62H. Following is a list of Disk I/O FCB & Buffer memory useage for both Model I & Model III. ----------------------------------------------------------------------- | File Start Start Start Start Basic Start Basic | | Area Record DCB Buffer Program with "V" | |---------------------------------------------------------------------| | 0 - - - 66BFH = 26303 66BFH = 26303 | | 1 66BEH 66CBH 66EBH 67ECH = 26604 68ECH = 26860 | | 2 67EBH 67FBH 6818H 6919H = 26905 6819H = 27417 | | 3 6918H 6925H 6945H 6A46H = 27206 6D46H = 27974 | | 4 6A45H 6A52H 6A72H 6B73H = 27507 6F73H = 28531 | | 5 6B72H 6B7FH 6B9FH 6CA0H = 27808 71A0H = 29088 | | 6 6C9FH 6CACH 6CCCH 6DCDH = 28109 73CDH = 29645 | | 7 6DCCH 6DD9H 6DF9H 6EFAH = 28410 75FAH = 30202 | | 8 6EF9H 6F06H 6F26H 7027H = 28711 7827H = 30759 | | 9 7026H 7033H 7053H 7154H = 29012 7A54H = 31316 | | 10 7153H 7160H 7180H 7281H = 29313 7C81H = 31873 | | 11 7280H 728DH 72ADH 73AEH = 29614 7EAEH = 32430 | | 12 73ADH 73BAH 73DAH 74DBH = 29915 80DBH = 32987 | | 13 74DAH 74E7H 7507H 7608H = 30216 8308H = 33544 | | 14 7607H 7614H 7634H 7735H = 30517 8535H = 34101 | | 15 7734H 7741H 7761H 7862H = 30818 8762H = 34658 | ----------------------------------------------------------------------- Chapter 3 D O S Page 27 DOS ROUTINES The following is a list of NEWDOS/80 DOS Routines. The star conveys no TRSDOS equivalent. The first column is the Entry Address. The 2nd Column is the Jump at that Address OR a Restart 28H value. The Restart value is loaded into "A" to be interpreted by the routine at 4BC2H (Mod III = 4B67H) which is the RST 28H Code. ---------------------------------------------------------------------------- | Entry JP/(A) Mod3 Function | |--------------------------------------------------------------------------| | 402DH 4400H 4400H No error exit to DOS | | 4030H 43H 43H Error already displayed exit to DOS | | 4033H 4ADBH 4AB0H Jump to device driver in DOS | | 4400H 23H 23H This is where 402DH jumps to | | 4405H 63H 63H Enter DOS and Execute a Command | | 4409H 26H 26H DOS Error exit | | 440DH 4609H 45D4H DEBUG Entry point (A=27H - RST28H ) | | 4410H 55H 4473H Enqueue user timer interrupt routine | | 4413H 85H 85H Dequeue a user timer interrupt routine | | 4416H 4762H 4711H Keep the Drives rotating | | 4419H C3H C3H Execute a DOS Command and Return | | 441CH 83H 83H Extract a Filespec write Filespec in FCB) | | 4420H 44H 44H Open an FCB to a new or existing File | | 4424H 24H 24H Open an FCB to an existing File | | 4428H 25H 25H Close an FCB | | 442CH 45H 45H Kill a File associated with the FCB | | 4430H A4H A4H Load a Program File | | 4433H C4H C4H Load and execute a Program File | | 4436H 49FCH 49A1H Read Disk Sector/Move Rec-FCB to user Buff | | 4439H 4A36H 490BH Write Sector/Move Record-user Buff to FCB | | 443CH 4A32H 49D7H Same as 4439H and a Verify is done. | | 443FH 4B4CH 4AF1H Position FCB to start of File | | 4442H 4B73H 4B18H Position FCB to specified Record in File | | 4445H 4B62H 4B07H Position FCB back 1 Record | | 4448H 4854H 4AF9H Position FCB to EOF | |* 444BH 4809H 47AEH Allocate File Space | |* 444EH 4B47H 4AECH Position FCB to specified RBA | |* 4451H C5H C5H Write the EOF value from FCB to Directory | |* 445BH 4776H 4723H Select and power-up a specified Drive | |* 445EH 47ECH 4791H Test for a mounted Disk | |* 4461H 2BH 2BH Name routine Enqueue | |* 4464H 4BH 4BH Name routine Dequeue | | 4467H 4BA6H 4B4BH Send a Message to the Video display | | 446AH 4BBCH 4B61H Send a Message to the Printer | | 446DH 44A7H 3036H Convert the Time to HH:MM:SS format | | 4470H 44C2H 3033H Convert the Date to MM/DD/YY format | | 4473H A3H A3H Insert default Extension into Filespec | ---------------------------------------------------------------------------- Page 28 D O S Chapter 3 MODEL III TRSDOS CALLS & ADDRESSES -------------------------------------------------------------------------------- | NAME Address Funtion Model I | | Hex Dec Address | |------------------------------------------------------------------------------| | ~ SDATE 3033H 12339 Returns the Date | | ~ TIME 3036H 12342 Returns the Time | | $JP2DOS 402DH 16429 Transfers control to DOS | | x $DATLOC 421AH 16922 Date storage location (4044H) | | x $TIMLOC 4217H 16919 Time storage location (4041H) | | x $CMDTXT 4225H 16933 Location of DOS command Buffer (431BH) | | * $FILPTR 428DH 17037 Gets Info on any File open | | * $RAMDIR 4290H 17040 Loads Directory Info to RAM | | * $COMDOS 4299H 17049 Executes a DOS command & goes to DOS | | * $CMDDOS 429CH 17052 Executes a DOS command & returns | | $ERRDSP 4409H 17417 Displays DOS Error messages | | * $MEMEND 4411H 17425 Top of Memory storage | | * $DSPDIR 4419H 17433 Displays Directory of user Files | | $SYNTAX 441CH 17436 Move file data to FCB | | $INIT 4420H 17440 Open File FCB or creates it | | $OPEN 4424H 17444 Open existing File FCB | | $CLOSE 4428H 17448 Closes file last used | | $KILL 442CH 17452 Deletes Directory entry | | $READ 4436H 17462 Loads next Record | | $WRITE 4439H 17465 Writes Buffer to next Record No. | | $VERF 443CH 17468 Same and then Verifies | | $REWIND 443FH 17471 Positions to first Record | | $POSN 4442H 17474 Positions File to specified Record | | $BKSPC 4445H 17477 Positions to previous Record | | $POSEOF 4448H 17480 Positions to last Record in File | | x * $PUTEXT 444BH 17483 Adds Extension to File name (4473H) | | ~* $DMULT 444EH 17486 Multiplication Routine (16Bit) | | ~* $DIVIDE 4451H 17489 Division Routine (16Bit) | -------------------------------------------------------------------------------- * means these addresses are different in NEWDOS/80 (Page 28). ~ means these addresses do not exist in the Model I. x means that the address change for the Model I. Chapter 3 D O S Page 29 MOD I PORT FDC & PRINTER INFORMATION The only Port the Model I uses is Port FF. he Port has a control byte in memory at 403DH. For Write it has the following functions:- Bit 0 : 0 erases voltage on tape : 1 (1) writes Positive voltage Bit 1 : 0 depends on Bit 0 : 1 (2) writes negative voltage Bit 2 : 0 turns Cassette off : 1 (4) turns Cassette Motor on Bit 3 : 0 enables 64 Char Mode : 1 (8) enables 32 Char Mode Bit 4 to 7 have no function. The DC uses addresses between 37DCH and 37EFH as communication bytes, all the addresses are write only except 37ECH which uses 1 byte for both Reading Status and writing Command. The following is a list of the addresses and functions :- 37E1H = Drive 0 Select 37ECH = Command Status Register 37E3H = Drive 1 Select 37EDH = Track Register 37E5H = Drive 2 Select 37EEH = Sector Register 37E7H = Drive 3 Select 37EFH = Data Register The WRITE Commands for Command Register 37ECH are listed on Page 32 being the same as Port F0H in the Model III. The READ Command for Status Register 37ECH are dependent on the command type but in general are :- Bit 0 - If set Disk Controller BUSY : Bit 4 - If set Missing Record Bit 1 - If set Data Request active : Bit 5 - No function Bit 2 - If set Lost Data : Bit 6 - No function Bit 3 - If set CRC Error - Bit 7 - If set FDC Not Ready The Model I uses memory location 37E8H as Printer control byte. It has the same Read & Write functions as Port F8H in the Model III (PAge 33). ......................... PCM80 & VIDEO GENIE & SYSTEM 80 PORTS The System 80 has some differences in hardware to the TRS-80 including Port usage. Ports FF and FE are used for Cassette Operations while Port FD is used for Printer Operations. Port FF has exactly the same functions as in the Model I. With Port FE, the Cassette Number Select Bit is Bit 4. If set the Computer uses Cassette No. 2, If not set No. 1. In Port FD, Bit 7 returns the Status of the Printer when READ, and to WRITE a Byte to the Printer uses all 8 bits) send the ASCII to Port FD. Page 30 D O S Chapter 3 MODEL III PORT FDC & PRINTER INFO. The Model III depends on Ports for all Floppy Disk Controller FDC Printer, RS-232C, and Interrupts functions as well as Cassette switching, 32 Char Mode, Video waits and Char set control. Thus in the 37DCH to 37EFH area set aside for I/O in the Model I are not used in this way in the Model III excepting 37E8H, the Printer status byte (same as Model I.) Some Ports have specialised functions. For example, E0H is the Interrupt control Port. It is read by the Interrupt Service Routine to find which device is interrupting. E4H is the Interrupt request Port. E8H E9HEAH end EBH are device control. Note:- INTRO = Interrupt request: DRQ = Data request. ---PORT-----Bit---------READ-----------------------Bit--------WRITE--------------------- | | 0 | Cass 1500 BAUD Rising Edge Int | 0 | 0 = Disable: 1 = Enable | | E0 | 1 | Cass 1500 BAUD Falling Edge Int| 1 | 0 = Disable: 1 = Enable | | 224 | 2 | Real Time Clock Interrupt | 2 | 0 = Disable: 1 = Enable | | | 3 | External I/O Interrupt | 3 | 0 = Disable: 1 = Enable | | Control | 4 | RS232 Transmit Interrupt | 4 | No WRITE function | | Byte | 5 | RS232 Receive Interrupt | 5 | No WRITE function | | At | 6 | RS232 Error Interrupt | 6 |0=Disable: 1=Enable INTRO | | 4213H | 7 | No function | 7 |0=Disable: 1=Enable DRQ | |--PORT-----Bit---------READ-----------------------Bit--------WRITE--------------------| | | 0 | No READ function | 0 | Writing 00 | | E4 | 1 | No READ function | 1 | to Port E4 | | 228 | 2 | No READ function | 2 | disables | | | 3 | No READ function | 3 | Disk I/O | | | 4 | No READ function | 4 | non- | | Inter'pt| 5 | RESET is paused | 5 | maskable | | Request | 6 | Disk DATA Request active | 6 | interrupts | | Port | 7 | Disk INTERRUPT Request active | 7 | | |--PORT-----Bit---------READ-----------------------Bit--------WRITE--------------------| | | | | | E8 | MODEM Status | ... Reset | | 232 | | | |--PORT-----Bit---------READ-----------------------Bit--------WRITE--------------------| | | | | | E9 | BAUD Rate Status | BAUD Rate Register | | 233 | | | |--PORT-----Bit---------READ-----------------------Bit--------WRITE--------------------| | | | | | EA | UART Status | UART Control Register | | 234 | | | |--PORT-----Bit---------READ-----------------------Bit--------WRITE--------------------| | | | | | EB | UART Receive | UART Transmit | ---------------------------------------------------------------------------------------- Chapter 3 D O S Page 31 MODEL III PORT FDC & PRINTER INFORMATION Port ECH (like Port FFH) is a multi function Port. ECH has no function for Read other than an interrupt clear. FFH has no function for Write other than Cassette Bit saving. Port F0H is the FDC Status/Command Register as the byte at 37ECH is in the Model I. ---PORT-----Bit--------READ---------------------Bit--------WRITE----------------- | | 0 |No Read function | 0 | Clock Print on | | EC | 1 | except | 1 | Cassette Motor on | | 236 | 2 | That a Read | 2 | 32 Characher Mode | | | 3 | of this Port | 3 | Alternate Char. Set toggle | | Control | 4 | clears | 4 | External I/O Bus enabled | | Byte | 5 | the RTClock | 5 | Video Waits enabled | | At | 6 | Interrupts | 6 | Speed-up : Set = *2 | | 4210H | 7 | | 7 | No function | |--PORT-----Bit--------READ---------------------Bit--------WRITE----------------| | | 0 |If set Disk Controller BUSY | | | F0 | 1 |If set Data Request active | See the | | 240 | 2 | " " Lost Data | Chars | | | 3 | " " CRC Error | following | | FDC | 4 | " " Missing Record | for | | Command | 5 | No function | details | | /Status | 6 | " " | | | Port | |If set FDController Not Ready | | --------------------------------------------------------------------------------- Write values to Port F0H (240) in Model III or 37ECH in Model I :- ------------------------------------------------------------------------------------------ | FUNCTION 7,6,5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0 | |----------------------------------------------------------------------------------------| | Restore 000 | = 0 ) ) ) Track stepping rate | | Seek 000 | = 1 ) = No ) Not used ) 0 = 5ms ) 0 = 10 ms | | Step Head 001 ) 0= Track ) Verify ) ) 1=10or20 ) 1 = 20 ms | | Step Head In 010 ) Update ) 1= ) ) ) | | Step Head Out 011 ) 1= No Update ) Verify ) ) ) | | Read Data 100 ) 0= 1 Sector ) 0 =NonIBM )0=NoHdSettle | = 0 | = 0 | | Write Data 101 ) 1 = MultSect ) 1=IBM Fmt )1=10msHdSetl | = Address Mark | | ReadAddrField 110 | = 0 | = 0 | = 1 | = 0 | = 0 | | ForceInterrupt 110 | = 1 | NoCondits |onIndexpulse |Not Ready |on Ready | | Read Track 111 | = | = 0 | = 1 | = 0 | = 0 | | Write Track 111 | = 1 | = 0 | = 1 | = 0 | = 0 | ------------------------------------------------------------------------------------------ Note:- ) denotes multiple application. Page 32 D O S Chapter 3 MOD III PORT FDC & PRINTER INFO. The Ports F1H, F2H, F3H and F4H are Floppy Disk Controller Registers. F1H has the same function as 37EFH in the Model I, F2H the same as 37EEH, and F3H the same as 37EFH. The first 4 bits of Port F4H select the Drive to be used. The top 4 Bits tell the FDC what Density, Side, Write Compensation or Wait state to use. ---PORT-----------------READ-------------------------------WRITE---------------------- | | | | | F1 | | Track Register | | 241 | | | |--PORT---|-------------READ-------------------|-----------WRITE---------------------| | | | | | F2 | | Sector Register | | 242 | | | |--PORT---|-------------READ-------------------|-----------WRITE---------------------| | | | | | F3 | Data Register | | | 243 | | | |--PORT---|-Bit---------READ-------------------|-Bit-------WRITE---------------------| | | 0 | No Read function | 0 | Select Drive 0 | | F4 | 1 | No Read function | 1 | Select Drive 1 | | 244 | 2 | No Read function | 2 | Select Drive 2 | | | 3 | No Read function | 3 | Select Drive 3 | | Select | 4 | No Read function | 4 | 0=Select Front Side,1=Back | | Port | 5 | No Read function | 5 | Write Compansation Enabled | | | 6 | No Read function | 6 | Wait States Enabled | | | 7 | No Read function | 7 | 0=SingleDensity,1= Double | |--PORT---|-Bit-|-------READ-------------------|-Bit-|-----WRITE---------------------| | | 0 | No Read function | 0 | | | F8 | 1 | No Read function | 1 | ASCII | | 248 | 2 | No Read function | 2 | (7Bits) | | | 3 | No Read function | 3 | to | | Printer | 4 |If set Printer has Fault | 4 | Printer | | Port | 5 |If set Printer is Selected | 5 | | | | 6 |If set Printer has no Paper | 6 | | | | 7 |If set Printer is Busy | 7 | No Used | |--PORT---|-Bit-|-------READ-------------------|-Bit-|-----WRITE---------------------| | | 0 |If set 1500 Baud Rate enabled | 0 |If set Positive Voltage toTape | | FF | 1 |If set Cassette Motor On | 1 |If set Negative Voltage toTape | | 255 | 2 |If set 32 Char Mode enabled | 2 | No Write function | | | 3 |If set Symbol Chars enabled | 3 | No Write function | | | 4 |If set Ext I/O Bus enabled | 4 | No Write function | | | 5 |If set Video Waits enabled | 5 | No Write function | | | 6 | No Read function | 6 | No Write function | | | 7 |If set 500 Baud Rate enabled | 7 | No Write function | -------------------------------------------------------------------------------------- Chapter 3 D O S Page 33 PART 2 TRS - 80 INFORMATION TRS-80 INFORMATION CHAPTER 4 INITIALISATION INITIAL PROGRAM LOADER In this Chapter we examine what happens when the reset button is pressed. The Code here is called the Initialisation process and the code concerned is called the Initial Program Loader (IPL). For Level II initialisation the code is from the TRS80 Model I (the old ROM). From cold start the computer starts reading the ROM at 0000H. The code in the following pages explains what then happens. Firstly the Level II Initial Program Loader is explained and the code which is involved is disassembled with remarks. Then the operations involved with the IPL under Model I DOS are similary examined. The the Model III Boot Sector is disassembled. The code involved in the Model III from 4300H to 4348H is nearly an exact copy of the Model I code from 4200H to 4255H but from this point on the codes differ. Disk access in the Model III used Ports whereas in the Model I the controller is memory mapped. So it might help to read both explanations up to this point as they complement each other. The TRS-80 uses only IBM format for its disk storage. This entails the existance of a particular pattern of control information between the sectors on the diskette. This information is invisible to the user except with very sophisticated utility programs. The numbers to the left of the address in the disassemby denote how many times that address is referenced. The extra number immediatly following it ( e.g. 43A5H on Page 52 ) indicates that 54A5H is not referenced but that 43A6H is. Chapter 4 INITIALISATION Page 35 IPL - LEVEL II Addr. Code Instruction Function 0000H F3 DI ; Turn off Interrupts 0001H AF XOR A ; Clear A Reg and Flags 0002H C3 74 06 JP 0674H ; Go to start of IPL processing ; .......... to 0674H 1 0674H D3 FF OUT A,0FFH ; Load Cassette Port with 0 1 0676H 21 D2 06 LD HL,06D2H ; Addr. of sequence to be shifted 0679H 11 00 40 LD DE,4000H ; Start of Communications Region 067CH 01 36 00 LD BC,3336H ; No. Bytes = 54 067FH ED 80 LDIR ; Move 06D2-0707 to 4000-4035 0681H 30 DEC A ; 0 = 256 reduced by 2 0682H 30 DEC A ; till it is 0 0683H 20 F1 JR NZ,C676H ; Do it 126 times 0685H 06 27 LD B,27H ; Load 39 addresses 1 0687H 12 LD (DE),A ; (4036-4062) with "A" (=0) 0688H 13 INC DE ; Incr. destination Pointer 0689H 10 FC DJNZ 0687H ; Go back id B <> 0 068BH 3A 40 38 LD A,(3840H) ; Test for Break key pressed 068EH E6 04 AND 04H ; Eliminates all except Bit 2 0690H C2 75 00 JP NZ,0075H ; Go to Level II IPL 0693H 31 70 40 LD SP,4070H ; New Stack area 0696H 3A EC 37 LD A,(37ECH) ; Load Disk Status 0699H 3C INC A ; Test if Expansion Interface 069AH FE 02 CP 02 ; & Disks present 069CH DA 75 00 JP C,0075H ; Go if not Disk to Level II ; ................ And to on to 0075H ............................... The first of the Communications Area is set up with the proper addresses. It is remarkable that the ROM does this 128 times. The reason for this is to make absolutely sure that Restarts and Device Control Blocks are properly initialised (Memory power-up delay). The area 4036H to 4062H is zeroed, and a test is performed to see if the Break key is pressed. If so, there is a jump to Level II IPL. The stack is then set to 407DH. The stack overwrites most of the area between 405DH and 407CH in the IPL in Level II. This is the storage area in the DOS for a subroutine and the parameters for time checking and printing and is free for use in Level II by USR routines from Basic. The test for the presence of an Interface is then carries out. This is done by reading the value in 37ECH. If it is not present, the value returned will be FFH. The value is incremented to give a Carry when compared with 02H so that control passes to 0075H. Page 36 INITIALISATION Chapter 4 IPL - LEVEL II Addr. Code Instruction Function 2 0075H 11 80 40 LD DE,4080H ; Load into 4080H - 40A6H 0078H 21 F7 18 LD HL,18F7H ; from 18F7H - 191DH 007BH 01 27 00 LD BC,0027H ; 39 Bytes of Division 007EH ED B0 LDIR ; support routine, data etc. 0080H 21 E5 41 LD HL,41E5H ; More initialisation 0083H 36 3A LD (HL),3AH ; 41E5H = 3A Start of Buffer 0085H 23 INC HL ; Move on to 41E6H 0086H 70 LD (HL),08H ; 41E6H = 0 Buffer code 0087H 23 INC HL ; Move on to 41E7H 0088H 36 2C LD (HL),2CH ; 41E7H = 2C ir code 008AH 23 INC HL ; Move on to 41E8H 008BH 22 A7 40 LD (40A7H),HL ; Basic Input Buffer Pointer 008EH 11 2D 01 LD DE,012DH ; Address of L3 Error 0091H 06 1C LD B,1CH ; 4152H - 41A5H = 28i 0093H 21 52 41 LD HL,4152 ; Move on to 4152H & load 0096H 36 C3 LD (HL),C3 ; Jump instruction 0098H 23 INC HL ; Move on one Byte 0099H 73 LD (HL),E ; load 2DH 009AH 23 INC HL ; Move to MSB 009BH 72 LD (HL),D ; load 01H 009CH 23 INC HL ; Move to next C3H Address 009DH 10 F7 DJNZ 0096H ; 28 Times ( 84 locations ) 009FH 06 15 LD B,15H ; Loop count of DOS exits 1 00A1H 36 C9 LD (HL),C9H ; Load a Return 00A3H 23 INC HL ; every 3 Bytes 00A4H 23 INC HL ; changing DOS Exits 00A5H 23 INC HL ; from Jump to Return 00A6H 10 F9 DJNZ 00A1H ; Repeat 21 times .............................. Division support routine is loaded from ROM to its address 4080H. Address 41E5H is loaded with code that loads the register "A" with the contents of 2CH which in the Model I contains D3H (211). The Basic Input Buffer pointer (40A7H) is set to 41E8H. A jump to the L3 Error (Disk Basic reserved word jumps) routine is put at the address of the DOS Reserved Word Jumps. Then the ROM Call DOS Exits are plugged with a C9H (Return). Chapter 4 INITIALISATION Page 37 IPL - LEVEL II Addr. Code Instruction Function 00A8H 21 E8 42 LD HL,42E8H ; Store 0 in 42E8H, the byte 00ABH 70 LD (HL),B ; before start of Basic 00ACH 31 F8 41 LD SP,01C9H ; Stack address during IPL 00AFH CD 8F 18 CALL 188FH ; Initialise Basic pointers 00B2H CD C9 01 CALL 01C9H ; Clear Screen 2 00B5H 21 D5 01 LD HL,0105H ; ASCI pointer "Memory Size" 00B8H CD A7 28 CALL 28A7H ; Print Message 00BBH CD B3 1B CALL 1BB3H ; User Input of Memory Size 00BEH 38 F5 JR C,00B5H ; If Break go back 00C0H 07 RST 10H ; Examine response 00C1H 87 OR A ; Clear Flags 00C2H 20 12 JR NZ,00D6H ; Go past if Constant (val>0) 00C4H 21 4C 43 LD HL,434CH ; If val = 0 get TOPMEM 1 00C7H 23 INC HL ; by testing 00C8H 7C LD A,H ; until 00C9H 85 OR L ; HL = 0 00CAH 28 1B JR Z,00E7H ; If 0 then go & store 00CCH 7E LD A,(HL) ; Store original contents 00CDH 47 LD B,A ; in B for replacement 00CEH 2F CPL ; Complement (gives test byte) 00CFH 77 LD (HL),A ; Place test byte in Address 00D0H BE CP (HL) ; Compare test byte 00D1H 70 LD (HL),B ; Restore original 00D2H 28 FE JR Z,00C7H ; If OK keep going 00D4H 18 11 JR 00E7H ; Else Address is non-existent .............................. The byte at 42E8H is zeroed for start of Basic Programs. This situation is checked by the ROM when the start of Basic is reset or reinitialised. The Stack is set temporary at 41F8H. Basic Pointers are initialised in 1B8FH. The screen is cleared by a ROM call tto 01C9H. And the message "Memory Size" is printed at the top of the screen by another ROM call at 28A7H. THe computer then waits fo an Input (terminated by ) of the Memory Size value. If a value is entered, the computer jumps to 00D6H (the next page). If no value, the Memory is tested as to how much is present. In a 48K Computer, this accounts for the delay if no Memory Size is entered. Page 38 INITIALISATION Chapter 4 IPL - LEVEL II Addr. Code Instruction Function 1 00D6H CD 5A 1E CALL 1E5AH ; Get Binary Eqivalent 00D9H B7 OR A ; Clear flags 00DAH C2 97 19 JP NZ,1997H ; Syntax error if no value 00DDH E8 EX DE,HL ; TOPMEM plus 1 into HL 00DEH 2B DEC HL ; less 1 00DFH 3E 8F LD A,8FH ; Comparison value 00E1H 46 LD B,(HL) ; Store contents in B 00E2H 77 LD (HL),A ; Poke test pattern 00E3H BE CP (HL),A ; Compare test byte 00E4H 70 LD (HL),8 ; Restore original 00E5H 20 CE JP NZ,00B5H ; Memory not present go back 00E7H 28 DEC HL ; Amount Memory less 2 00E8H 11 14 44 LD DE,4414H ; DE = 17428 00EBH OF RST 18H ; Test for min amount of memory 00ECH 0A 7A 19 JP C,197AH ; Out of memory if carry 00EFH 11 CE FF LD DE,FFCEH ; = default String space 00F2H 22 B1 40 LD (40B1H),HL ; Store TOPMEM 00F5H 19 ADD HL,DE ; Subtract String space 00F6H 22 A0 40 LD (40AD),HL ; Store start of String space 00F9H CD 40 1B CALL 1B4DH ; Initialise Basic Var. Pointers 00FCH 21 11 01 LD HL,0111H ; ASCII "Radio Shack" 00FFH CD A7 28 CALL 28A7H ; Print message 0102H C3 19 1A JP 1A19H ; Go to Ready & Command mode 1 0105H 4D 45 40 4F 52 59 etc ; "Memory Size" + terminator 1 0111H 52 41 44 49 4F 20 etc ; "Radio Shack etc." +terminator .............................. The code at 00D6H calls a routine at 1E5AH that converts the HL value (HIMEM) to an Integer and returns the result in the DE with the A register holding the Error condition. If A<>0 an error occurs. If O.K. the value is transferred back to HL, decremented, tested, decremented again, tested for the minimum amount of Memory,and the value (HIMEM) stored at 40B1H. Default String space is set, the String boundary is set, and the other Basic pointers initialised. Radio Shack Level II ( or in later Models R/S etc ) is printed and control passes to the Command mode. Chapter 4 INITIALISATION Page 39 MODEL I - DOS INITIALISATION In this part we examine what happens when the reset button is pressed in DOS. On Page 36 tthe ROM was disassembled until ti brenched to the Level II IPL. The code starts from there. The Disk access by the IPL is handled in a different way to normal DOS I/O. The Boot sector is loaded directly into its execution address because of the absence of control information which is always present in DOS I/O. Later we will disassemble the Boot sector and see how it loads (SYS0/SYS) to start the DOS initialisation process. But first to carry on from where Level II branched off :- Addr. Code Instruction Function 069CH DA 75 C0 JP C,0075H ; Go if not Disk to Level II ; ............. and so to the DOS IPL 069FH 3E 01 LD A,1 ; Unit Select Mask for Drive 0 06A1H 32 E1 37 LD (37E1H),A ; Select Drive 0 06A4H 21 EC 37 LD HL,37ECH ; Addr of Command/Status Register 06A7H 11 EF 37 LD DE,37EFH ; Addr of Data Register 06AAH 36 03 LD (HL),3 ; 3 = Restore to Command Reg 06ACH 01 00 00 LD BC,0 ; Delay COunt = 65536 06AFH CD 60 00 CALL 0060H ; Delay for 1 Second 1 06B2H CB 46 BIT 0,(HL) ; Test if Controller busy 06B4H 2D FC JR NZ,06B2H ; Loop till not busy 06B6H AF XOR A ; Zero A and clear flags 06B7H 32 EE 37 LD (37EEH),A ; Make Sector Reg = 0 06BAH 01 00 42 LD BC,4200H ; Addr to read Data to 06BDH 3C 8C LD A,8CH ; 8CH = Read Command 06BFH 77 LD (HL),A ; Read Track 0, Sector 0 2 06C0H CB 4E BIT 1,(HL) ; Test if Data ready 06C2H 2B FC JR Z,06C0H ; Wait until Data there 06C4H 1A LD A,(DE) ; Get next Byte from Dat Reg 06C5H 02 LD (BC),A ; Transfer to 4200H plus in RAM 06C6H 0C INC C ; Increment Buffer Pointer 06C7H 20 F7 JR NZ,06C0H ; Do till C = 0 ( 256 Bytes ) 06C9H C3 00 42 JP 4200H ; Transfer control to BOOT Sec ............................... Drive 0 is selected and after a delay, the Disk controller is tested to see if busy. When free, Track 0 Sector 0 (the Boot Sector) is read and written into memory at 4200H. When 256 bytes have been read, control is passed to the Boot sector in Memory. Page 40 INITIALISATION Chapter 4 MODEL I BOOT SECTOR The Boot progran is now in memory at 4200H. As the last line of the code on the previous page shows, control is transferred to the Boot sector immediatly it is loaded. In the 6th Sector of the Disk is the SYS0/SYS program. This is the code that prints the logo for NEWDOS/80 on the screen, and initialises all vectors and addresses to the right values for DOS to execute correctly. SYS0/SYS is made up in the first part of all these addresses and values so that until it starts at 4400H there is no continuous code, only odd addresses and parameters. (The only exception is the code at 4063H (Mod3-44ADH) which converts a Hex. value in DE to ASCII and stores it in (HL). The Boot sector loads SYS0/SYS starting at 4000H. The following is a diagram of what the start of Drive 0 Drive Relative Sector 5 looks like using Superzap :- ------------------------------------------------------------------- | | | Tells the computer to load | | | This is how many Bytes incl 2 Address Bytes (11 bytes) | | | | Address to load DATA to | | | | | DATA (9 bytes) and again | | | | | | | | -- -- ----- ------------------------------ -- | | 00 - 01 0B 0C 40 23 C2 4B C3 09 46 C3 F3 45 01 0B 20 | | | | 10 - 40 C3 00 44 1E 43 EF C3 DB 4A 01 21 3E 40 00 00 | | -- | | | | | and again | ------------------------------------------------------------------- Note :- Because the 2nd byte is 11 then 9 bytes of data are loaded If the 2nd byte is 3 then 1 byte is loaded If the 2nd byte is 0 then 254 bytes are loaded If the 2nd byte is 2 then 256 bytes are loaded This is because address bytes and the 1st data byte are loaded before the counter, the Register C, is tested to see if it is zero. We now consider the BOOT sector. It is disassembled and explained on the next page. Unlike the previous load, the Boot sector loads SYS0/SYS into the Sector Buffer. The code is then transferred to its proper address in memory. The BOOT Sector changes depending on the characteristics of the diskette. However, there is no real change in function, only in parameters. e.g. single/double sided etc. Chapter 4 INITIALISATION Page 41 MODEL I - BOOT SECTOR Addr. Code Instruction Function 4200H 00 NOP ; No operation 4201H FE 11 CP 11H ; Recognition Code + 17 = Dir Sector 4203H F3 DI ; Disable Interrupts 4204H 21 EC 37 LD HL,37ECH ; Command/Status Register 4207H 36 FE LD (HL),FEH ; Code for Request ) Activate 4209H 36 D0 LD (HL),D0H ; Terminate Request ) Drive 420BH 23 INC HL ; Move to Track Register 420CH 36 00 LD (HL),00H ; Track 0 420EH 23 INC HL ; Sector Register 420FH 36 00 LD (HL),00H ; Sector 0 4211H 11 05 00 LD DE,0005H ; D=Track=0,E=Sector=5 4214H D9 EXX ; Alternate Registers 4215H 31 ED 41 LD SP,41EDH ; Set Stack to Comm. Area 4218H 21 FF 51 LD HL,51FFH ; Set HL to Sector Buffer 1 421BH CD 52 42 CALL 4252H ; Get 1st Sector 421EH FE 20 CP 20H ; Set or not Carry Flag 4220H 47 LD B,A ; Store for 422CH 4221H 30 29 JR NC,424CH ; Go to Error handling if > 1FH 4223H 57 LD D,A ; If byte >2 & <32 load to ROM 4224H CD 52 42 CALL 4252H ; 2nd Byte (st area = 0BH) 4227H 4F LD C,A ; Store No. of Bytes 4228H CD 52 42 CALL 4252H ; Get 3rd Byte (1st area = 00H 422BH 5F LD E,A ; LSB of Address to load to .............................. After the 1st byte "NOP" is a recognition code "FE" and the Directory starting Track. This value is used by NEWDOS/80 as well as its own record in the 3rd Sector - the PDRIVE specifications. HL is pointed to the memory address which has the function of READing the status of and WRITing commands to the Floppy Disk Controller. Firstly the FDC is activated by a request. This starts the drive motor rotating. Then a request for termination is sent. HL is moved on to the other memory locations for FDC information. The Track Register and the Sector Register are set to track 0 and Sector 0. DE is loaded with the track and sector number that will be required for loading the SYS0/SYS program. The HL, DE and BC register pairs are stored by the EXX for use in the disk-to-sector buffer load and the primed ones are exchanged for sector buffer-to-memory load. The stack is relocated to the communication area. HL is pointed to the sector buffer address. The call to 4252H increments the value in L and since, in the first instance, L has been loaded with FFH, the RET NZ allows the disk-to-sector buffer load. Before return from the load the value read from the first byte in the sector buffer is checked and if greater than 31 (1FH) an error routine clears the screen, prints 'No SYS' and locks up. If < 31 the value is loaded into B for DJNZ instructions to decrement and determine the flow. Page 42 INITIALISATION Chapter 4 MODEL I BOOT SECTOR Addr. Code Instruction Function 422CH 10 12 DJNZ 4240H ; If 1st byte <> 1 goto 4240H ; Sector buffer-to-memory transfer 422EH CD 52 42 CALL 4252H ; Go & read MSB of 4231H 57 LD D,A ; Address to load to 4232H 0D DEC C ; allow for 2 Byte Addr in 4233H 0D DEC C ; count of Bytes to be loaded 4234H 2C INC L ; Move along in Buffer 4235H CC 55 42 CALL Z,4255H ; if end Buffer load another sector 4238H 7E LD A,(HL) ; then load DATA Reg 4239H 12 LD (DE),A ; into Address in DE. 423AH 13 INC DE ; move Address on 423BH 0D DEC C ; 1 Byte less to load 423CH 20 F6 JR NZ,4234H ; if more go back 423EH 18 DB JR 421BH ; or go load another area 1 4240H 10 F9 DJNZ 423BH ; If 1st byte <> 2 load to ROM ; Get transfer address and execute or Error 4242H CD 52 42 CALL 4252H ; else read next byte 4245H 57 LD D,A ; MSB of transfer address (4D00H) 4246H 1A LD A,(DE) ; Check if contents of 4D00H 4247H FE A5 CP A5H ; is A5H 4249H 13 INC DE ; Move on to 4D01H 424AH D5 PUSH DE ; To stack : if OK return to 424BH C8 RET Z ; transfer addr. or error 1 424CH 21 E5 42 LD HL,42E5H ; 'No SYS' ASCII 424FH C3 C3 42 JP 42C3H ; Go to Error routine. ....................... If the first byte is not 1 or 2 and is less than 32 then the value is given to 'D'. The DJNZ at 422CH branches the program to the DJNZ at 4240H and this passes to 423BH. The code loads the data in the buffer into an address in DE which is in the 300H to 1FFFH range. This allows an ASCII heading at the start of a file. After storing a machine language program on Disk the DOS adds 02 02 xx xx where the first 02 is the end of program code, as explained above, the second 02 is a byte load count and xx xx is the transfer address. If the call at 421BH reads an 02H then the DJNZ at 422CH plus the one at 4240H cause a fall through to 4242H. The MSB of the transfer address is read and the contents of this address is checked to see if it is A5H. If so control passes to the transfer address + 1. If not the 'No SYS' error handling routine executes. The code 4234H to 423CH handles the load from the buffer-to-memory. If the load continues across sectors the call at 4235H tests for the end of the buffer and loads another sector. Chapter 4 INITIALISATION Page 43 MODEL I BOOT SECTOR Addr. Code Instruction Function 5 4252H 2C INC L ; Move on 1 Byte in buffer 4253H 7E LD A,(HL) ; Store in A 4254H C0 RET NZ ; Go back if not end of buffer ; load a new sector into the buffer 1 4255H D9 EXX ; Alternate Registers 4256H 06 0A LD B,0AH ; 10 error tries 1 4258H 21 E1 37 LD HL,37E1H ; Drive control Reg 425BH 36 01H LD (HL),01H ; select Drive 0 425DH D5 PUSH DE ; Store both Track# & Sector# 425EH C5 PUSH BC ; and error count 425FH 7B LD A,E ; check error count 4260H D6 0A SUB 0AH ; is it more than 10 ? 4262H 38 03 JR C,4267H ; if not jump 4264H 5F LD E,A ; if so subtract 10 4265H 36 09 LD (HL),09H ; select Drive 0 4267H 21 EC 37 LD HL,37ECH ; Command Register 426AH CD CE 42 CALL 42CEH ; Delay - get ready 426DH ED 53 EE 37 LD (37EEH),DE ; E in Sect Reg : D=Data Reg 4271H 36 1B LD (HL),1BH ; 27 = SEEK Track 0, 20ms step 4273H CD CE 42 CALL 42CEH ; Delay 4276H 36 88 LD (HL),88H ; 136 = load 1 sector IBM fmt 4278H 11 EF 37 LD DE,37EFH ; DATA Register 427BH 01 00 51 LD BC,5100H ; Buffer 427EH CD D7 42 CALL 42D7H ; Delay ......................... This subroutine (4252H - 42B8H) reads a sector from Disk into the sector buffer. In the 1st read HL is loaded with 51FFH at 4218H. When L is incremented its value is zero and the program falls through the RET NZ (4254H) to the sector buffer load. The registers are alternated, the error count is set to 10, Drive 0 is selected, the Track number, Sector number and Error count are stored, and if the Sector count >10 then 10 is subtracted and Drive 0 again selected. The 9 here instead of 1 probably has a connotation of side. A delay ensues to give the drive time to be ready, the sector number E is placed in the sector register and the data register is zeroed. The command register receives a SEEK instruction and after a delay is asked to load a sector. DE is pointed to the data register, BC to the start of the sector buffer and there is another delay for the FDC to become ready. Page 44 INITIALISATION Chapter 4 MODEL I BOOT SECTOR Addr. Code Instruction Function 1 4281H 7E LD A,(HL) ; Status of Drive 4282H E6 83 AND 83H ; leave Bits 0, 1, and 7 4284H E2 81 42 JP PO,4281H ; if Bit 7, Drive not Ready 4287H 1A LD A,(DE) ; Transfer Data to 4288H 02 LD (BC),A ; Sector Buffer 4289H 03 INC BC ; move on in the Buffer 1 428AH CB 4E BIT 0,(HL) ; If not Busy 428CH C2 B7 42 JP NZ,4287H ; move more data 428FH CB 4E BIT 1,(HL) ; Wait till the 4291H C2 87 42 JP NZ,4287H ; Status Reg 4294H CB 4E BIT 1,(HL) ; has Data read 4296H 20 EF JR NZ,4287H ; request 4298H CB 46 BIT 2,(HL) ; if Drive is not busy 429AH 28 D8 JR Z,42A4H ; go.... 429EH 20 E7 JR NZ,4287H ; data request 42A0H CB 7E BIT 7,(HL) ; Test if Drive is ready 42A2H 28 E6 JR Z,428AH ; if so go try again ............................ This code reads data from the disk into the buffer. The Data Register (DE) contains the byte placed there by the FDC after the required instruction is sent to the Command Register (HL). The loop 4281H to 4284H waits for the FDC to be ready. Bit 7 = not busy reading data from the disk. Bit 0 - ready and Bit 1 - not requesting data to be read. When activated the controller installs a data byte in address 37EFH (DE) and sets Bit 1 of the status register (37ECH). It resets bit 1 when 37EFH is read. The data byte is transferred to the buffer address in Memory (BC). The status register is read to see if another byte of data is ready (Bit 1). The command register is given a read command and if all bits except 0 and 1 are zero then no error exists. The status checks from 428AH to 42A2H give the FDC time to fetch some more data and signal by the bits in the status register that it has done so and is ready for the data register to be read again. If it fails all tests then there is either an error or the buffer has been fully loaded and control must pass to either the data transfer to memory routine or an error routine. Chapter 4 INITIALISATION Page 45 MODEL I BOOT SECTOR Addr. Code Instruction Function 1 42A4H 7E LD A,(HL) ; Store status in A 42A5H 36 D0 LD (HL),D0H ; Interrupt Command 42A7H C1 POP BC ; Restore original 42A8H D1 POP DE ; values for next time 42A9H E6 FC AND 0FCH ; all but Bits 0 & 1 42ABH 20 OC JR NZ,42B9H ; if error/not ready Go 42ADH 1C INC E ; move sector # on 42AEH 7B LD A,E ; if < 10 then 42AFH D6 DA SUB DAH ; go through 42B1H 20 03 JR NZ,4286H ; else incr Track 42B3H 14 INC D ; & set Sector 42B4H 1E 00 LD E,00H ; to 0. 42B6H 09 EXX ; Back to other Registers 42B7H 7E LD A,(HL) ; contents of buffer into A 42B8H C9 RET ; & go back ; ............. Test if all Errors used 42B9H CD D7 42 CALL 4207H ; Delay 42BCH 36 0B LD (HL),0BH ; Restore to Track 0 42BEH 10 98 DJNZ 4258H ; if B <> 1 start again .......................... When the sector is fully read or some error has disrupted the Input the FDC is given a stop (force interrupt) command. This allows the FDC to go into an inactive state and turns the drive off after a wind down delay. The status is read and by eliminating bits 0 and 1 (42A9H) the error status is found. If an error exists the code after a delay tests to see if all 10 of the value errors in B are used and if they are the program falls through to the 'ERROR' message. If there is no error the sector number is incremented and tested as to whether it is 10. If it has then the sector number is zeroed and the track number is incremented. If not there is a relative jump across this code. The registers used for the buffer-to-memory transfer are restored and the disk-to-buffer registers are stored as the primed ones. The first position in the sector buffer is loaded into the A register for analysis on return and the program returns to the code which made the sector buffer load call. If there is an error control goes to the delay. If all errors are not used we go back for another try. If the error count B=0 the programfalls through to error handling. Page 46 INITIALISATION Chapter 4 MODEL I BOOT SECTOR Addr. Code Instruction Function ; ERROR handling 42C0H 21 DD 42 LD HL,42DDH ; 'ERROR' ASCII ; Error print and lock up routine 3 42C3H 7E LD A,(HL) ; Read the byte 42C4H FE 03 CP 03H ; if it is 3 go into 42C6H 28 FB JR Z,42C3H ; an enless loop. 42C8H 23 INC HL ; else 42C9H CD 33 00 CALL 0033H ; & Print 42CCH 18 F5 JR 42C3H ; more. ; After a delay, test for busy 1 42CEH CD 07 42 CALL 42D7H ; Delay subroutine 1 42D1H CB 46 BIT 0,(HL) ; Test for busy 42D3H 20 FC JR NZ,42D1H ; if so wait 42D5H 7E LD A,(HL) ; Get Status value 42D6H C9 RET ; & Return ; Delay subroutine 3 42D7H 3E 06 LD A,06H ; Delay 1 42D9H 3D DEC A ; just 42DAH 20 FD JR NZ,42D9H ; 50 Microseconds 42DCH C9 RET ; and go back ; ASCII storage 1 42DDH - 42DEH 1C 1F ; ASCII - Home & Clear screen 42DFH - 42E3H 45 52 52 4F 52 ; ASCII - ERROR 42E4H 03 ; EOR - terminator 1 42E5H - 42E6H 1C 1F ; ASCII - Home Cursor & Clear 42E7H - 42ECH 4E 4F 20 53 59 53 ; ASCII - NO SYS 42EDH 03 ; End of message 42EEH - 42FFH ; Garbage ............................... The delay loop loads A with 6 and decrements it to 0 with a delay of about 50 microseconds. The routines calling 42CEH first go to the delay subroutine, then there is a FDC test for busy which holds up execution until the bit which holds teh busy signal is not set. The error handling routine prints the message (either NO SYS or ERROR), then when finished goes into an endless loopto lock up the computer. Chapter 4 INITIALISATION Page 47 MODEL III BOOT SECTOR The Boot Sector is loaded by the ROM by much the same method as the Model I excepting of course the use of Ports for FDC control instead of memory addresses. The Boot Sector is loaded into a different address (4300H instead of 4200H) but the sector buffers remains at the same address. The Boot sector disassembled :- Addr. Code Instruction Function 4300H 00 NOP ; No action 4301H FE 11 CP 11H ; Recogn Code + DIR Sector 4303H F3 DI ; Disable Interrupts 4304H 11 05 00 LD DE,0005H ; D = Track E = Sector 4307H D9 EXX ; Alternate ; Buffer vector and stack setting 4308H 31 ED 41 LD SP,41EDH ; Stack to Comm. Area 430BH 21 FF 51 LD HL,51FFH ; Sector Buffer (5100H-51FFH) ; Sector buffer load call 1 430EH CD 45 43 CALL 4345H ; If L+1 = 0 load Sector 4311H FE 20 CP 20H ; If first byte >1FH- Error 4313H 47 LD B,A ; B for DJNZ at 431FH & 4333H 4314H 30 29 JR NC,433FH ; Error if > 1FH 4316H 57 LD D,A ; If A > 2 & < 20H load to ROM ; C = the number of bytes to load into the buffer 4317H CD 45 43 CALL 4345H ; Get No. bytes to load 431AH 4F LD C,A ; into E ; E = the low byte of the address to load to in memory 431BH CD 45 43 CALL 4345H ; Get LSB of Transfer Addr 431EH 5F LD E,A ; into E 431FH 10 12 DJNZ 4333H ; If 1st Byte =1 transfer ......................... This code performs the same function as the Model I code in that it sets up the control code reading and the Sector Buffer Address. This program uses the "INI" mnemonic to load (439CH) and otherwise is very similar to the Model I. Please refer to the Model I explanation as the flow of the program is the same. Page 48 INITTIALISATION Chapter 4 MODEL III BOOT SECTOR Addr. Code Instruction Function 4321H CD 45 43 CALL 4345H ; Get MSB of Transfer Addr. ; Sector buffer to memory transfer routine 4324H 57 LD D,A ; into D 4325H 0D DEC C ; Allow for 2 Bytes 4326H 0D DEC C ; of Transfer Address. 1 4327H 2C INC L ; If end of Buffer 4328H CC 48 43 CALL Z,4348H ; load another Sector 432BH 73 LD A,(HL) ; Load from Buffer 432CH 12 LD (DE),A ; to Transfer Address 432DH 13 INC DE ; Transfer Addr moved on 1 432EH 0D DEC C ; Count 1 less 432FH 2D F6 JR NZ,4327H ; If more go back ; When the byte count has been transferred ( C = 0 ) 4331H 18 DB JR 430EH ; Go load another area ; Pass Control to Transfer Addr. or Error 1 4333H 10 F9 DJNZ 432EH ; If 1st Byte > 2 load to ROM 4335H CD 45 43 CALL 4345H ; MSB of Transfer Addr (4D00H) 4338H 57 LD D,A ; into D 4339H 1A LD A,(DE) ; Check if (4D00H) = A5H 433AH FE A5 CP 0A5H ; If so set Z Flag 433CH 13 INC DE ; Move to 4D01H 433DH D5 PUSH DE ; to Stack for RET 433EH C8 RET Z ; If = A5H Transfer tot SYS0/SYS. ; Error - Print " NO SYS " and lock up. 1 433FH 21 F0 43 LD HL,43F0H ; ASCII "NO SYS" 4342H C3 CC 43 JP 43CCH ; To Error handling ............................ This code checks the 1st byte of the load, if > 2 and < 32 then "D" register contains that value. The second DJNZ at 4033H sends the program to the memory load routine and the code is written in ROM. This is used ( e.g. 5 ) to store ASCII text identifying the Program on Disk. If the 1st byte was 2, this is the code indication the end of the program, it falls through to 4335H and gets the transfer MSB from the buffer and checks to see if the contents of this address is A5H. If so SUSH DE and RET passes control to the program just loaded (SYS0/SYS). IF the transfer address does not hold the required test byte A5H then the RET Z allows the error routine to execute. Chapter 4 INITIALISATION Page 49 MODEL III BOOT SECTOR Addr. Code Instruction Function ; Test for end of Sector Buffer ; Note:- H not incremented so Buffer stays in 5100H - 51FFH range 5 4345H 2C INC L ; Move on in Buffer 4346H 7E LD A,(HL) ; Get Character 4347H C0 RET NZ ; If not end go back for more 1 4348H D9 EXX ; else load another Sector 4349H 06 0A LD B,0AH ; Error count 1 434BH 2E 81 LD L,81H ; = Dbl Dens: Front Side: Trk 0 for Port F4 later 434DH D5 PUSH DE ; Store Track & Sector 434EH C5 PUSH BC ; Error Count & C = 0 434FH 7B LD A,E ; Sector No. 4350H D6 12 SUB 12H ; If < 18 (Sectors per Track) 4352H 38 C3 JR C,3457H ; jump over side swap 4354H 5F LD E,A ; Else Sector No to 0 4355H 2E 91 LD L,91H ; Read Back side of disk 1 4357H CD D7 43 CALL 4357H ; Delay 435AH 7D LD A,L ; Command to 435BH D3 F2 OUT (0F4H),A ; Select Port 435DH 7A LD A,D ; Track to 435EH D3 F3 OUT (0F3H),A ; Track Port 4360H 7B LD A,E ; Sector to 4361H D3 F2 OUT (0F2H),A ; Sector Port 4363H 3E 1B LD A,1BH ; Seek - Verify +20ms Step Rate 4365H D3 FB OUT (0F0H),A ; to Command Port 4367H CD 07 43 CALL 4307H ; Delay 436AH 7D LD A,L ; Change Command to 436BH F6 40 OR 40H ; Wait States Enabled 436DH 5F LD E,A ; Store for 439AH 436EH 16 02 LD D,02H ; Data Request for Port F0H ........................... The code here sets up all the vectors and values for the disk-to-buffer load. First the disk to sector registers are made active (EXX), the error count is initialised and the current track and sector numbers are stored on the stack. The sector number is tested for a value over the number of sectors per track. If this is so, the sector number is set to 0 and back side select bit is set for the command to Port F4H at 435BH. This is what enables NEWDOS/80 to Boot a double sided Disk. After a delay the FDC select, track and sector Ports are sent the required values, Then the value for the select Port is changed to allow the Wait States. The data request value for the Command register is stored in D. Page 50 INITIALISATION Chapter 4 MODEL III BOOT SECTOR Addr. Code Instruction Function 4370H DB F0 IN A,(0F0H) ; Get Status 4372H ED 73 A6 43 LD (43A6H),SP ; Store Stack Pointer 4376H 21 A2 43 LD HL,43A2H ; Set 4049H to contain 4379H 22 4A 40 LD (4043H),HL ; Jump to 43A2H (C3 A2 43) 437CH 3E C3 LD A,0C3H ; for Return to Program 437EH 32 49 40 LD (4049H),A ; from I/O Interrupt 4381H 3E C0 LD A,0C0H ; Activate 4383H D3 E4 OUT (0F0H),A ; Data Request 4385H 3E 88 LD A,88H ; READ - 1 Sector(Bit7) 4387H D3 F0 OUT (0F0H),A ; - IBM Format(Bit3) 4389H 21 00 51 LD HL,5100H ; Sector Buffer 438CH 01 F3 00 LD BC,00F3H ; B = 0 = 256 = Count:C = F3 = DataReg. 438FH CD E2 43 CALL 43E2H ; Delay 1 4392H DB F0 IN A,(0F0H) ; Status 4394H A2 AND D ; Mask all but Data Request 4395H 28 FB JR Z,43E2H ; Wait for DRQ 4397H ED A2 INI ; Get a.byte ; The INI instructionreads 1 byte from disk via Port (C), ; Decrements Count (B), Transfers Byte to (HL) + Incr HL 4399H 7B A,E ; Current State to 1 439AH D3 F4 OUT (0F4H),A ; to SELECT Register 439CH ED A2 INI ; Load - more Byte 439EH 20 FA JR NZ,439AH ; If B <> 0 load more 1 43A0H 18 FE JR 43A0H ; Wait for Interrupt ........................... The FDC is activated by a request. The stack pointer is loaded into the address to restore its content level after disk I/O and the I/O interrupt vector is initialised with the address to restore the flow of the program after I/O has been completed. The Floppy Disk Controller is sent a data request and is notified what Track, Sector and othercontditions are required. The sector buffer address is held in HL, the count of the number of bytes to load is placed in B and the C register (used by Port instructions) is set to Port F3H the data register. After a delay the code "INI" reads 1 byte at a time for as many bytes as are in "B" (256). When the Sector is fully read there is an I/O Interrupt and the program jumps to 43A2H from the interrupt processor vector at 4049H (see the code at 4376H). When the full sector of 256 bytes has been loaded, the CPU locks up untill an Interrupt. Chapter 4 INITIALISATION Page 51 MODEL III BOOT SECTOR Addr. Code Instruction Function 1 43A2H AF XOR A ; Clear A 43A3H D3 E4 OUT (0E4H),A ; Cancel Data Request ; This location was loaded with the stack address by 4372H 14 43A5H 31 00 00 LD SP,0000H ; Restore stack pointer 43A8H DB FD IN A,(0FDH) ; Get Status ; Test for errors - Test for Jump in 43B2H 43AAH E6 FC AND 0FCH ; Test(Ready+Error) Set Z Flag 43ACH 3E D0 LD A,0D0H ; Force 43AEH D3 F0 OUT (0F0H),A ; Interrupt 43B0H C1 POP BC ; Restore Error Count (B),(C), 43B1H D1 POP DE ; Track (D) & Sector (E) 43B2H 20 0C JR NZ,43C0H ; If test fails try again 43B4H 1C INC E ; Next Sector ; On a double sided Disk 43B7H is 24H or 36 Sectors per track 43B5H 7B LD A,E ; Test if 43B6H D6 12 SUB 12H ; = 18 43B8H 20 C3 JR NZ,43BDH ; Jump over if not else 43BAH 14 INC D ; Track on 1 43BBH 1E 00 LD E,00H ; Sector to 0 43BDH D9 EXX ; Exchange 43BEH 7E LD A,(HL) ; 1st byte in buffer into A 43BFH C9 RET ; Go back to caller .......................... After a sector load, the data request is cancelled and the stack pointer is restored to the address it had before I/O and the FDC is sent an interrupt to rest it to an inactive state. The original error count (B), the data register Port (C), the track (D) and sector (E) numbers are retrieved from the stack. Then the FDC is tested for error, and if an error exists control is passed by the test at 43B2H to the routine which decrements the error count and tests if all errors used. If all errors are used the program goes to the error handling routine. The sector number is incremented and tested to see if it exceeds the sector per track value. If so the sector number is zeroed and the track number incremented. Then the registers are alternated , the start of the sector buffer is read and the program returns to the calling code. Page 52 INITIALISATION Chapter 4 MODEL III BOOT SECTOR Addr. Code Instruction Function ; If not Ready or Error, Delay, Seek, Decrement Error Count & RET 1 43C0H CD E2 43 CALL 43E2H ; Delay 43C3H 3E 0B LD A,0BH ; SEEK to 43C5H D3 F0 OUT (0F0H),A ; Command Register 43C7H 10 82 DJNZ 434BH ; If all Errors used fall thru 43C9H 21 E8 43 LD HL,43EBH ; ASCII "ERROR" ; Error handling 3 43CCH 7E LD A,(HL) ; Load it 43CDH FE 03 CP 03H ; If terminator 43CFH 28 FB JR Z,43CCH ; go into endless loop 43D1H 23 INC HL ; else move to next letter 43D2H CD 33 00 CALL 0033H ; Print it 43D5H 18 F5 JR 43CCH ; & go back for more ; Delay and check Status 2 43D7H CD E2 43 CALL 43E2H ; Delay 1 43DAH DB F0 IN A,(0F0H) ; Status 43DCH 0F RRCA ; Test for Bit 0 43DDH 38 FB JR C,43DAH ; if Busy wait 43DFH DB F0 IN A,(0F0H) ; else get Status 43E1H C9 RET ; and return ; Delay for 41 Microseconds 3 43E2H 3E 08 LD A,08H ; Delay count 1 43E4H 3D DEC A ; 1 less 43E5H 20 FD JR NZ,43E4H ; Go if Zero 43E7H C9 RET ; back to caller ; ASCII error messages 1 43E8H - 43EFH ; Clear Screen + ERROR + Terminator 1 43F0H - 43F9H ; Clear Screen + NO SYS + Terminator 43FAH - 43FFH ; Irrelevant - not used. ........................... A delay, a seek command is sent to the FDC and if all errors are not used the program returns to try again for a succesful read of the sector. If all errors are used the error handling takes over and locks up the computer. :::::::::::::::::::::: Chapter 4 INITIALISATION Page 53 --------------------------------------------------------------------------------- Selected pages from Chapter 5 from here --------------------------------------------------------------------------------- NEWDOS/80 SYSTEM COMMAND OPTIONS PDRIVE and SYSTEM parameters are stored on the disk in Drive Relative Sector 2. On the right of the SYSTEM option and the PDRIVE parameter lists, a column whows which byte in this sector holds the information. Some parameters are stored in bits. These are a simple choice of Y (set) or N (reset). The bit involved is also shown in these cases. AA = Enable Password checking "Y" or not "N" F0-7 AB = Force RUN-only condition "Y" or not "N" F0-6 AC = Enable Debounce "Y" or not "N" (requires AJ=Y) Model I only F8-7 AD = Enable 'JKL' Screen to Printer "Y" or not "N" F8-6 AE = Enable '123' Debug entry "Y" or not "N"(requires AB=N) F8-5 AF = Enable 'DFG' Mini-DOS entry "Y" or not "N"(requires AB=N) F8-4 AG = Enable Break Key "Y" or not "N" (requires AB=N) F0-5 AI = Lower Case Mod installed "Y" or not "N" *Model I only) F0-4 AJ = Enable DOS Keyboard intercept routine "Y" or not "N" F8-1 AL = Number of Drives in the System (1 to 4) A0 AM = Number of Read attempts before Error (normally 10) A6 AN = Default Drive number fir DIR command (0-3) A2 AO = Lowest Drive No for new File creation if not specified A3 AP = Himen value installed on Boot D0,D1 AQ = Enable Clear key to function "Y" or not "N" F8-2 AR = Allow Full(5) or CBF(6) Copy without Pswrd "Y" or not "N" F0-1 AS = Force Basic text input to Upper Case "Y" or not "N" F0-0 AT = Allow input requests from Chain File "Y" or not "N" F1-7 AU = Enable Keyboard repeat "Y" or not "N" F8-0 AV = No. 25ms intervals before 1st key repeat (requires AU=Y) A7 AW = Number of Write with Verify attempts before Error A1 AX = Highest ASCII Printable Character for Printer A8 ( U/C only = 5AH(90) or L/C = 7AH(122)) AY = Require Date/Time entry at cold start "Y" or not "N" F9-7 AZ = Require Date/Time on Reset "Y" or use previous value "N" F9-6 BA = Force ROUTE DO.NL (no Video output) at Reset "Y"; not "N" F9-5 BB = Clock is 50cps "Y" or 50 cps "N" (model III only) F9-4 BC = Permit Chaining pause or cancel "Y" or not "N" (req.AB=N) F1-6 BD = Permit "AUTO" negate at reset with Enter key "Y"; not "N" F9-3 BE = Enable "R" as repeat DOS command "Y" or not "N" F1-5 BF = Force LCDVR.N at reset "Y" or not "N" (Model I only) F9-2 BG = Force LC,Y at reset "Y" or not "N" (req. BF=Y if Mod I) F9-1 BH = Enable Blinking Cursor "Y" or not "N" F9-0 BI = ASCII value of cursor char (Mod I-0 = 95;Mod III-0 = 176) A5 BJ = Timing loop multiplier (for speed-up mods) A9 BK = Enable WRDIRP & Dircheck W & C functions "Y" or not "N" F1-4 BM = Follow Format by Verify "Y"; not "N" (eliminated by Zap) F1-3 BN = Directory readable Mod III NEWDOS "Y" or Mod I TRSDOS "N" FA-7 AH, AK, BL, BM, BO-ZZ are not used. PDRIVE PARAMETERS TI uses bits of bytes 02, 07, 0D and 0E. The parameter contains both the interface type and special conditions, of which two or three may be used. First letter bits set A - Standard Tandy Interface 02-2, 0D-0 B - Omikron mapper Interface (Mod I) 02-2,02-3, 0D-1 C - Percom doubler Interface (Mod I) 02-4, 0D-2 D - Apparat Disk Controller (Mod III) 02-3, 0D-3 E - LNW type Interface (Mod I) 02-2, 02-4, 0D-4 Second letter (special condition, 2 or 3 may be used) H - Head settle delay enabled (8 inch Drives) 02-7, 0D-7 I - Sector 1 = lowest Sector on each Track 07-4, 0E-0 J - Track 1 = lowest Track on the Diskette 07-1, 0E-1 K - Track 0 formatted in opp dens to the rest 02-6, 07-1, 0E-2 L - 2 steps between Trks (Read 40Trk on 80TrkDr) 07-2, 0E-3 M - TRSDOS ModI 2.3B or higher or ModIII read. 02-5, 0E-4 TD uses the four lower bits of 0F, 07-0, 07-6, 07-7 - bits set): A - Single density, Single sided ; B - & 07-7, 0F-0 C - Single density, Double sided 07-6, 0F-1 ; D - & 07-7, 0F-0 E - Double density, Single sided 07-0, 0F-2 ; F - & 07-7, 0F-0 G - Double density, Double sided 07-0,07-6,0F-1,0F-2; H - & 07-7, 0F-0 TC (Number of Tracks formatted on the Disk) 03 SPT (Number of Sectors per Track) 04 TSR (Track Step Rate(0=5,1=10,2=20,3=40ms) bits 0 & 1 of 02 & 0C GPL ......... Granules per Lump (& ND/86_90 SPG in bits 4-7) 05 DDSL ........ Disk Directory Starting Lump (used only by Format) 00 & 08 DDGA ........ Number of Granules allocated to Directory 09 SPG(ND/86_90) Sectors per Gran (2=D, 3=E, 4=F, 5=0, 6=1, 7=2, ...)) 0B ,A .......... If no errors, new PDRIVE active (else not till Reboot) Some examples.... Model I ...................... TI TD TC SPT TSR GPL DDSL DDGA ------------------------------------------------------------------ NEWDOS/80 Std S/Dens S/Sided A A 40 10 1 2 17 2 TRSDOS Std (READ) A A 35 10 3 2 17 2 Percom Doubler CK E 39 18 1 2 17 2 Double Sided S/Density A C 40 20 1 4 17 4 D/Sided Double Dens (Percom) CK G 39 36 1 4 17 4 NEWDOS/80 Std 80 Track A A 80 10 1 8 35 6 Double Sided S/Density A C 80 20 1 8 35 6 D/Sided DOuble Dens (Percom) CK G 79 36 1 8 35 6 Model III .................... TI TD TC SPT TSR GPL DDSL DDGA ------------------------------------------------------------------ NEWDOS/80 Std A E 40 18 1 2 17 2 TRSDOS Std (READ) AM E 40 18 3 6 17 2 Double Sided A G 40 36 1 4 17 4 NEWDOS/80 Std 80 Track A E 80 18 1 4 35 4 80 Track DOuble Sided A G 80 36 1 8 35 6 Chapter 5 VARIOUS Page 65 DIRECORY ENTRIES File Primary Directory Entries (FPDE) Store information for the DOS to gain the fast and easy access to Files stored on disk which so distinguishes NEWDOS/80 Version 2. A typical entry would be :- 10 00 00 B7 00 43 4F 4D 50 54 53 45 52 42 41 52 .....COMPUTERBAS 96 42 96 42 03 00 1D 20 FF FF FF FF FF FF FF FF .B.B............ Byte 0 = 10H = File type & Access level. Byte 1 = 00H = Flags - Bit 7 = ASE :Bit 6 = ASC :Bit 5 = update Byte 2 = 00H = Storage - not used in NEWDOS/80 Byte 3 = B7H = EOF offset in the final sector = Last byte used in final sector Byte 4 = 00H = Length of each record (0-255, 0=256) Bytes 5 to 12 = ASCII of File name filled with blanks from right Bytes 13 to 15 = ASCII of extension to file name filled as above Bytes 16 and 17 = Update password hash code - if unused = 9642H Bytes 18 and 19 = Access password hash code - if unused = 9642H Bytes 20 and 21 = No. of sectors (from 1) occupied by file (LSB,MSB) If byte 3 =0, 3 byte value (bytes 21,20,3)= No bytes used by file if byte 3 >0 the value is No bytes used +256, =EOF in RBA format Byte 22 = 1DH = Lump number in which the file starts (from 0) Byte 23 = 20H = Bits 0,1,2,3,4 = No. of grans used in this extend Bits 5,6,7 = 1st granule in the lump the file occupies (0 to 7) The next 3 pairs of bytes have the same format & function as 22 & 23 if the extends are used, otherwise all FF's. Bytes 24 and 25 = 2nd section of contiguous sectors occupied by file Bytes 26 and 27 = 3rd section of contiguous sectors occupied by file Bytes 28 and 29 = 4th section of contiguous sectors occupied by file Byte 30 = FFH = Bit 0 is the flag for the existence of an FXDE Thus FFH if no FXDE, FEH if one exists. Byte 31 = FFH = DEC. Bits 0-4 = Sector number (0-27) of entry in the directory sectors (less 2 used by GAT & HIT) of tthe next FXDE. Bits 5-7 = The FXDE entry number in the sector (= * 32 = byte No.) File Extended Directory Entries (FXDE) are used when more than 4 space areas are assigned to one file. The format is :- Byte 0 = FXDE recognition code. Bits 7 & 4 are both 1 (90H). Byte 1 = Refers back to the DEC of previous FPDE or FXDE of this file Byte 2 to 21 are unused in a FXDE. Byte 22 to 31 are the same as an FPDE. Page 66 VARIOUS Chapter 5 GRANULE ALLOCATION TABLE The Granule Allocation Table (GAT) sector has the information which tells the DOS what granules are free to use and which are used. Also it has bytes describing the mode of formatting, a hash code of the Master Password, the Disk name, and space for an AUTO CHAIN file. N.B.:- a byte is the space allocated to a lump in the GAT table. Bytes 0 to (the number of lumps -1) are used to describe the used or unused state of each granule. To gain more space capacity for the Granule table and still keep as far as possible the old 5 sectors per gran, NEWDOS/80 has severed the connection 1 track = 1 byte. Thus 1 lump = i byte. The number if bits used to convey this is dependent on the number of granules per lump. Thus the smallest amount of allocate space (a granule) = 1 bit. In the simplest case, 5 sectors per gran and 2 grans per track (Single density, Single sided, 40 track), the bytes up to 27H (the 40th byte) would be used and only bits 0 and 1 would be used so that the values in bytes 0 to 27H would be FFH (all used) or FCH (all unused) or FEH (the first gran is unused) or FDG (the last gran us unused). These conditions apply even through tthe bytes used for the table overrun what Tandy uses as a lockout table (bytes 60H to BFH). This is the reason that only the physical maximum of 202 (CAM) cylinders are allowed on hard drives. Bytes C0H to CAH (the 193rd to the 203rd bytes) unused except possibly for hard drives. Byte CBH (the 204th byte) is often used to identify the DOS & format of the disk. TRSDOS = 23H : NEWDOS/80 = 82H : LDOS 51H : DOSPLUS 34. Byte CCH (the 205th byte) is used by some DOS's to store the number of tracks above 35 used on the disk. NEWDOS/80 uses Byte 1FH of HIT Sector. Byte CDH (the 206th byte) is used in some cases to describe the density, no. of sides, and the number of grans per track. NEWDOS = 0. Bytes CEH to CFH contain the hash of the mastr password. With the password inactive the value is 42E0H. Bytes D0H to D7H = ASCII string of the disk name (displayed in DIR) Bytes D8H to DFH = ASCII of date used on creation or changed by PROT Bytes E0H to FFH = AUTO command buffer. Possible use involves only 31 bytes as the buffer must have an End of Record of oDH. Chapter 5 VARIOUS Page 67 HASH INDEX TABLE The Hash Index Table (HIT) sector contains information for the DOS to locate a Directory entry of a file to load it from the disk. When DOS has to load a file, the file name ad extension are read and hashed (coded) into a number between 1 & 255. The HIT sector is read to find a match for the hash, then the position of this code in the HIT sector, the DEC, is used to find the entry involved. Note - DEC = Derectory entry code = position of an entry in the hash table. All files' FPDEs and FXDEs each have an entry in the table. The HIT sector uses every second line in the sector(0,2,3,etc) to store these hashes. The low 5 bits 0,1,2,3,4 value (0-27) of the byte number are the sector number in the Directory sectors on which the file resides (remembering the first 2 sectors are used by GAT & HIT). The high 3 bits 5,6,7 (0-7) value is the number of the 32 byte entry of that FPDE in the sector. If the Hit sector byte is 00H then bit 4 of the first byte of the entry must be 0 too as the directory entry slot is free. Byte 1FH (the 2nd byte) is allocated to store the number of extra (beyond 10 ) sectors the directory uses. Note that the first hash found may be a DEC for an FXDE for the same file or a file with an altogether different name and extension which just happens to hash the same code. The entry ASCII is compared with the required file. If not the same the process starts again. NEWDOS/80 unlike other DOSes does not exclude the use of fixed slots for SYS files by other files if the SYS files are not on the disk. The usual track and sector number of the SYS files on a disk which has SPT=10 & GPL=2 (i.e.1 lump = 1 track) is :- ----------------------------------------------------------------------- | File Trk Gran Sects Len DEC| File Trk Gran Sects Len DEC| | No. No. used Grans | No. No. used Grans | |----------------------------------|----------------------------------| | BOOT /SYS 0 0 0- 1 1 00 | SYS20/SYS 15 1 155-159 1 62 | | SYS0 /SYS 0 1 5- 19 3 20 | SYS1 /SYS 16 0 160-164 1 30 | | SYS17/SYS 10 1 105-109 1 32 | SYS2 /SYS 16 1 165-169 1 40 | | SYS16/SYS 11 0 110-114 1 22 | DIR /SYS 17 0 170-179 2 10 | | SYS11/SYS 11 1 115-119 1 51 | SYS3 /SYS 18 0 180-184 1 50 | | SYS15/SYS 12 0 120-124 1 12 | SYS4 /SYS 18 1 185-189 1 60 | | SYS14/SYS 12 1 125-129 1 02 | SYS18/SYS 19 0 190-194 1 21 | | SYS7 /SYS 13 0 130-134 1 11 | SYS9 /SYS 19 1 195-199 1 31 | | SYS19/SYS 13 1 135-139 1 52 | SYS5 /SYS 20 0 200-204 1 70 | | SYS18/SYS 14 0 140-144 1 42 | SYS6 /SYS 20 1 205-239 7 01 | | SYS13/SYS 14 1 145-149 1 71 | SYS12/SYS 24 0 240-245 1 61 | | SYS10/SYS 15 0 150-154 1 41 | SYS21/SYS 24 1 245-249 1 72 | ----------------------------------------------------------------------- Page 68 VARIOUS Chapter 5 HARD DRIVES with NEWDOS/80 2.5 A hard Drive may have a Data File containing up to 16,000,000 bytes a Data Volume (the old Drive concept) of up to 65535 Sectors a Directory of 246 user Files a PDRIVE allowing 1 to 8 slots (volumes) for a Hard Drive a Data Volume spanning Tracks and Surfaces The limitations 65535 Sectors per Volume ( PDRIVE slot ). 256 Sectors per Track 65535 Tracks ( or Recording Surfaces or Heads ) per Cylinder 65535 Tracks per Surface - all qualified by Tracks per Surface times Tracks per Cylinder must be < 65536 The upgrade to 2.5 from 2.0 comes with 4 extra programs :- 1. HDBACKUP/CMD - for backing up or restoring to a Hard Drive 2. HDFMTAPP/CMD - for formatting a Hard Drive 3. EXTPDRIV/BAS - for setting up PDRIVE parameter sets 4. EXTPDAPP/DAT - for holding the PDRIVE parameter sets as well as modifications to /SYS programs. The number of active PDRIVE slots (Drives) is limited to 8 of which up to 4 may be used for Floppy Drives. 1 Floppy Drive is required for backups but 2 is more practical. The method of storing the backed up Hard Disk files on the floppy is changed so that they cannot be read by standard DOS functions. The sectors containing the programs can be read and changed with Superzap when accessed by Sector not File. Track numbers and File Sector numbers of the Hard Drive are not displayed. Also DIR and FREE will not display Track counts for Hard Drive Volumes. Bytes 20(14H) and 21 of a Directory entry still contain the Sector count so that it is physically limited to 65535. Again for the same reason the NEWDOS/80 application of Sector I/O limits a Volume (old concept of Drive) to 65535 Sectors. But when you consider that this allows for over 16 million bytes to a Volume or File that restriction fades into impracticality. With the advent of Hard Drives and their complications a bit of a byte in the GAT Sector of the Directory still refers to a Granule or the minimum amount of space allocatable. Well as you guesses with all that capacity, the Sectors per Gran must increase beyond 5 to be able to cope but the Granules per Lump is best left alone at 8. Chapter 5 VARIOUS Page 69 HARD DRIVE CONFIGURATION NEWDOS/80 Version 2.5 is a modified 2.0. Compatibility remains with Tandy's own hardware and for this reason it is confined to the Port usage and Addresses used by the Tandy Hard Drive. Most of the code driving the Hard Disk is contained in an extra 5 sectors of SYS0/SYS, and is loaded and initialised on Boot-up. After the normal SYS0/SYS program the next Org address on the disk is F900H and this code contains the Hard Drive Routines. The extra program protects it's lower boundary (F900H) and up to the end of memory is allocated to the extra routines. Thus 700H (1792) bytes may not be used for anything else. This robs the user of very litttle when the extra capacity and speed of the Hard Drives are taken into account. Ports used for Hard Disk I/O by the 2.5 version are C0 to CF. Corvus uses DE and DF and is thus incompatible. The Corvus people have made code (called NEWDOS/90 2.C) to adapt NEWDOS/80 to their Drives and the Host Adapter to interface to the TRS-80, The hard drives use Tandy - 256 byte Sectors - 32 Sects per Trk - 153 Trks per Surface Apparat - 256 byte Sectors - 32 Sects per Trk - 306 Trks per Surface Corvus - 512 byte Sectors - 20 Sects per Trk - 561 Trks per Surface The most difficult decision in using Hard Drives involves the PDRIVE HDS parameters. There are 12 of these. The next page has a listing, but first an explanation of some of the terms involved. DRIVE - A physical entity. = 1 Drive i.e. you may have the maximum of 8 Volumes (PDRIVE slots) on 1 Drive. VOLUME - 1 PDRIVE slot. A section of a Drive, be it a whole Drive or a part, which has it's own Directory. SURFACE - Recording surface - 1 per Drive Head - RSC = Recording Surface count = TPC = Tracks per Cylinder SECTION - Usually means a recording surface entity. CYLINDER - Vertically all the same numbered tracks in a Drive i.e. All Cylinders have (RSC) or (TPC) tracks. GRANULE - Minimum recording space that can be allocated. May contain 5-255 sectors in a Hard Drive. (Std 8) LUMP - as used in Granules per Lump. An area of the Drive used in the DDSL parameter for the Directory. (See DDSL). SECTOR INTERLEAVE COUNT - Delay between reading sectors. Optimal, almost mandatory, 21 for NEWDOS/80 2.5 (used in Format) Page 70 VARIOUS Chapter 5 HARD DRIVE PDRIVE PARAMETERS 1. HDDH - Hard Disk Drive Number Just means the Drive No.(0 to 3). (Max. 4 Hard Drives.) It specifies the Drive the Volume being PDRIVEd is on. 2. TPS - Tracks per Surface The number of Tracks per recording surface. Apparat Std = 306 ; Tandy Std = 153 ; Corvus Std = 561 3. SFS - Section's First Surface The recording surface the Volume starts on. 4. SSC - Section Surface Count The number of surfaces the Volume Spans. Thus SFS + SSC must be <= the total number of surfaces. 5. SPT - Sectors Per Track Number of 256 byte sectors on each track of each surface 32 in Apparat & Tandy, 20 for Corvus (512 bytes/sector). 6. TSR - Track Stepping Rate Apparat = 0? : Tandy = 6 : Corvus = 6 7. VFS - Volume First Sector This is the Sector number on which the Volume starts Can be 0 to 65535. 8. VSC - Volume Sector Count Number of sectors in the volume. If VSC = 0 the PDRIVE slot is used but the computer reports Device not available. 9. SPG - Sectors per granule Floppy standard & default = 5. If a whole Hard Drive is used as 1 Volume, the SPG is increased to keep DDSL<191. 10. GPL - (The old) Granules per Lump Between 2 & 8. A Lump in the GAT Sector is 1 Byte. A Granule is 1 Bit. The Hard Disk std is the max. 8. 11. DDSL - Default Directory Starting Lump The Lump in this volume at whose 1st sector is DIR/SYS. Note - Calculated into Sectors by DDSL * GPL * SPG. 12. DDSA - Default Directory Sector Allocation Different to DDGS in Floppies because the SPG changes. Standard on Hard Drives = 33. Chapter 5 VARIOUS Page 71 --------------------------------------------------------------------------------- Selected pages from Appendix from here --------------------------------------------------------------------------------- A P P E N D I X 2 EXTRA "&" FUNCTIONS 7.23. & Extra uses for the "&" Finction with NEWDOS/80 Models I & III. (1) &ddddd - returns the Hex equivalent od Decimal Input (hhhhH) (2) &%ddddd - returns the Integer signed decimal of ddddd. e.g. &37654 returns 9316H and &%37654 returns -27882. While the "&" function (No.1) can only be used as a String, the "&%" function (No.2) can be used inside a Program for any value (0 to 65535) for PEEKs, POKEs, or any other uses requiring an Integer for operations. As well as expressing -32768 as 8000H, both functions convert 32768 to 8000H as well, so as to give a Hex conversion of address between 32767 and 65536 (No.1), and an integer value (No.2). Naturrally, in Function (2) this conversion stops a FOR-NEXT loop from crossing between 32767 and 32768 as the 32768 is now -32768. i.e. ( FOR I = &%32767 TO &%32768 : POKEI,n : NEXT ) will not work but ( FOR I = 32767 TO 32768 : POKE&%I,n : NEXT ) will work. The Zaps to be applied :- From DOS load SUPERZAP DFS - SYS20/SYS - Sector 3 - MOD 00 change 28 01 2B to C2 AE 56. - Y - - K - 4 - MOD C2 change all 00's from C2 to FB to C0 - 18 EC FE 25 28 14 2B CD C6 56 E5 21 30 41 E5 CD D0 - D2 44 36 48 3E 05 01 C3 81 28 CD 38 23 E5 01 06 E0 - 2B C5 E7 E8 3A 24 41 01 80 9C 11 00 00 B8 C0 3A F0 - 23 41 B9 D0 04 C3 16 07 00 0C 00 00 ?2 02 00 52 This is how it should look when you are finished. N.B.- The underlined Bytes at D0 are the address of a routine in the Model III for converting the Hex contents of the DE Register pair to ASCII. The corresponding address in the Model I is 4063H. Thus in the Model I zap at D0 above 63 40 instead of D2 44. Page 124 EXTRA "&" FUNCTIONS APPENDIX 2 EXTRA "&" FUNCTIONS The most use of the second function will be in the POKE, PEEK & USR usage where the value might cross the invisible barrier between 32767 and 37768. The continual challenge fo quickly figuring the Hexadecimal equivalent of 41550 is also made a thing of the past. Below is a commented disassembly of the code used :- 56AC 18 EC JR 569AH ; End of existing code 1 56AE FE 25 CP 25H ; Test for " % " 56B0 28 14 JR Z,56C6H ; If so go to Subr & Ret to caller 56B2 2B DEC HL ; Go back for Incr in 2338H 1 56B3 C0 C6 56 CALL 56C6H ; Call Subroutine 56B6 E5 PUSH HL ; Store Addr of start of Entry 57B7 21 30 41 LD HL,4130H ; HL points to Print Buffer 57BA E5 PUSH HL ; Store for DE later 56BB CD D2 44 CALL 44D2H ; Convert DE to $, store in (HL) 56BE 36 48 LD (HL),48H ; Add "H" to end of string 56C0 3E 05 LD A,05H ; Load A with length of String 56C2 01 POP DE ; DE = Address of Print Buffer 56C3 C3 81 28 JP 2881H ; Move to String area & Return ; Conversion Subroutine 1 56C6 CD 38 23 CALL 2338H ; Evaluate entry - Result in ACC 56C9 E5 PUSH HL ; Store Addr of start of Entry 56CA 01 06 2B LD BC,2806H ; BC has Routine Addr. 56CD C5 PUSH BC ; on Stack for Return 56CE E7 RST 20H ; Test Number Type Flag 56CF EB RET PE ; Return if not Single Precision 56D0 3A 24 41 LD A,(4124H) ; Exponent of SP No ) If value 56D3 D1 80 90 LD BC,9080H ; BCDE gets SP ) is between 56D6 11 00 00 LD DE,0000H ; value of -32768 ) 32767 & 56D9 B8 CP B ; Is it 90H ? ) 65536 56DA C0 RET NZ ; If not RETurn ) convert to 56DB 3A 23 41 LD A,(4123H) ; MSB of SP No. ) Negative 56DE B9 CP C ; If negative ) by adding 56DF D0 RET NC ; Return ) -65536. 56E0 04 INC B ; BCDE = -65536 ) Result 56E1 C3 16 07 JP 0716H ; Add to ACC & RET ) = Integer The 'Result=Integer' of the bottom line means that the result of the addition is still Single Precision (32768 to 65535) but is cabable of expression as an Integer (-32768 to -1). APPENDIX EXTRA & FUNCTIONS Page 125 SYSTEM OPTION PRINT ENHANCEMENT This enhancement lists up to 12 bytes of ASCII explaining with each option of the SYSTEM command of NEWDOS/80 Version 2. The SYS17/SYS module handles the printing of the SYSTEM options. This Zap clashes with an Apparat ZAP (#057) which corrects an error occurring when the number of lumps exceeds 96, overwriting the lock-out table. By increasing the value of Granules per Lump (GPL PDRIVE parameter) this is obviated (See the table on Page 63). Nor is this modification available with NEWDOS/80 Version 2.5 (Hard Drive) as this area is used for Hard Drive routines. A Superzap read of theh sector is shown below. The first sector, File Relative Sector 0, gives the change to initialize the new code and the Call to execute it. The second sector has a change of one byte from a comma (the previous separator) to a dash (the new separator). The fourth sector has the extra code involved as well as the start of the ASCII. The last sector is all ASCII. Note carefully that the bytes at 08H to 0Bh in the last sector are the load instructions and must not be changed. They tell the DOS to load (01), how many bytes (F2H) and the address into which to load (50F8H). The C0H bytes are filler and print nothing. Disassembly for the Model I :- 501CH D9 EXX ; Alternate Registers 501DH 21 74 50 LD HL,5044H ; Start of ASCII 5020H DE 00 LD C,D ; First gap between Options 5022H D9 EXX ; Store for Print 5023H 11 00 00 LD DE,0000H ; Replace call line 5026H C9 RET ; Go back ; Print Subroutine 5027H D9 EXX ; Stored Registers 5028H 3A 20 40 LD A,(4020H) ; Get LSB of Cursor Position 502BH E6 FC AND 0FCH ; Lose bottom 2 bits 502DH 81 ADD A,C ; Add 0 (first time) or 4 502EH 0E 04 LD C,4 ; Set gap after first 5030H 32 20 40 LD (4020H) ; Set cursor to new position 5033H 06 0C PRINT LD B,12 ; Number of characters 5035H 7E LOOP LD A,(HL) ; Get character 5036H CD 68 4E CALL 4E6BH ; Print it 5039H 23 INC HL ; To next character 503AH 1C F9 DJNZ LOOP ; Do it 12 times 503CH D9 EXX ; Restore regs 503DH 78 LD A,B ; Get separator 503EH CD 6B 4E CALL 4E6BH ; Print it 5041H C9 RET ; Finished, go back Page 126 SYSTEM PRINT ENHANCEMENT APPENDIX SYSTEM PRINT ENHANCEMENT : Model I The following changes are for the Model I :- From SUPERZAP : DFS : SYS17/SYS : 0 : MOD C7 Change C7 from 11 00 00 06 00 to CD 1C 50 06 20 Change CF from CD 6B 4E to CD 27 50 Then move on to the next Sector : ; : MOD 18 Change 18 from 2C to 2D Then move on to File Relative Sector 3 : ; ; : MOD 2C Change 2C from all 00's as per Sector Printout DRV 00 0607 1ABE 1323 0100 FA4F 20CA 10F8 C942 ....."...O ....B 0 10 4F4F 5444 4952 2020 2020 2053 5953 8360 OOTDIR.....SYS.` 0H 20 0000 4200 00FF 0000 0000 FFFF 0921 4450 ..B..........!DP 30 0E00 D911 0000 C9D9 3A20 40E6 FC81 DED4 ........:.@..... DRS 40 3220 4006 0C7E CD68 4E23 10F9 0978 CD6B 2.@..~.kN#...x.k 108 50 4EC9 0000 456E 2050 6173 7377 6F72 6473 N...En.Passwords 6CH 60 5255 4E2D 4F6E 6C79 4D6F 6465 454E 2044 RUN-On!yModeEN.D 70 6562 6F75 6E63 6520 0D45 6E61 626C 6522 ebounce..Enable" 80 4A4B 4C22 456E 6162 6C65 2022 3132 3322 JKL"Enable."123" 90 456E 6162 6C65 2022 4446 4722 DD45 6E42 Enable."DFG".EnB A0 5245 414B 2048 6579 4C2F 4320 4D6F 6420 REAK.KeyL/C.Mod. B0 496E 7374 4B62 6420 496E 7427 6365 7073 InstKbd.Int'cept FRS C0 004E 6F44 7269 7665 73C0 C0C0 5265 6164 .NoDrives...Read 3 D0 732F 4572 72C0 C0C0 4449 5220 4472 6976 s/Err...DIR.Driv 3H E0 65C0 C0C0 004C 6F77 6573 7444 7269 7665 e....LowestDrive F0 4849 4D45 4DC0 C0C0 C0C0 C0C) 456E 436C HIMEM.......EnCl DRV 00 6561 724B 6579 C0C0 01F2 F850 0D43 6F70 earKey.....P.Cop 0 10 794E 6F20 5073 7764 4261 7369 6349 6E70 yNo.PswdBasicImp 0H 20 7455 2F43 4348 4149 4E20 496E 7075 743F tU/CCHAIN.Input? 30 0D4B 6272 6420 5265 7065 6174 3235 6D73 .Kbrd.Repeat25ms DRS 40 4465 6C61 79C0 C0C0 5772 6974 6573 2F45 Delay...Writes/E 109 50 7272 C0C0 0D50 7472 4B69 6768 43C0 C0C0 rr...PtrHighC... 6DH 60 4461 7465 5469 6065 436F 6C64 4461 4761 DateTimeColdDate 70 5469 6D52 6573 6574 DD52 4F55 5445 2044 TimReset.ROUTE.D 80 4F2C 4E4C 4348 4149 4E20 5061 7573 653F ),NLCHAIN.Pause? 90 4F76 6572 7269 6465 4155 544F 0D52 3D43 OverrideAUTO.R=C A0 4D44 5265 7065 6174 466F 7263 654C 4344 MDRepeatForceLCD B0 5652 2C4E 466F 7263 6520 4C43 2C4E 2020 VR,NForce.LC,N.. FRS C0 0D42 6C69 6E6B 4375 7273 6F72 4375 7273 .BlinkCursorCurs 4 D0 72C0 C056 616C C0C0 5469 6D4C 6F6F 7D4D r..Val..TimLoopM 4H E0 756C 74C0 0D45 6E61 622E 5752 4449 5250 ult..Enab.WRDIRP F0 4449 5220 4D4F 4420 332F 3120 0202 004D DIR.MOD.3/1....M APPENDIX SYSTEM PRINT ENHANCEMENT Page 127 SYSTEM OPTION PRINT ENHANCEMENT The only Option which is itself not self-explanatory is the one to choose the Lowest Drive Number for new file creation. The ASCII for this option (A0) shows only "Lowest Dr". The Model I has 5 SYSTEM Options not in the Model III, (AC,AI,AS,BF & BN) whereas the Model III has only one extra, (BB). The user has eliminated the uld BM option which was rendered unnecessary by ZAP 44. Disassemby for the Model III :- 502CH D9 EXX ; Alternate Registers 502DH 21 74 50 LD HL.5074H ; Start of ASCII 5030H AF XOR A ; Zero A 5031H 4F LD C,A ; First gap between Options 5032H D9 EXX ; Store for Print 5033H 32 24 40 LD (4024H),A ; Space Comp. Code toggle 5036H 11 00 00 LD DE,0000H ; Replace call line 5039H C9 RET ; Go back Page 128 SYSTEM PRINT ENHANCEMENT APPENDIX SYSTEM PRINT ENHANCEMENT : Model III The following changes are for Model III :- From SUPERZAP : DFS : SYS17/SYS : 0 : MOD C7 Change C7 from 11 00 00 06 0D to CD 2C 50 06 2D Change D0 from CD 6B 4E to CD 3C 50 Then move on to the next Sector : ; : MOD 18 Change 18 from 2C to 2D Then move on to File Relative Sector 3 : ; ; : MOD 2C Change 2C from all 00's as per Sector Printout DRV 00 1643 8920 0011 0100 FA4F 0543 0604 CD06 .C.......O.C.... 0 10 5021 1750 0607 1ABE 1323 20CA 10F8 C942 P!.P.....#.....B 0H 20 4F4F 5444 4952 2020 2020 2053 5953 8360 OOTDIR.....SYS.` 30 0000 4300 00FF 0000 0000 FFFF D921 7450 ..C..........!tP DRS 40 AF4F D932 2440 1100 00C9 D93A 2040 47E6 .O.2$@.....:.@G. 108 50 3CFE 3438 D73E CDCD 6B4E 1809 78E6 FC81 <.48.>..kN..x... 6CH 60 0E04 3220 4006 0C7E CD6B 4E23 10F9 D978 ..2.@..~.kN#...x 70 CD6B 4EC9 0000 0000 0000 0000 0000 0000 .kN............. 80 0000 0000 456E 2050 6173 7377 6F72 6473 ....En.Passwords 90 5255 4E2D 4F6E 6C79 4D6F 6465 456E 6162 RUN-OnlyModeEnab A0 6C65 2022 4A4B 4C22 456E 6162 6C65 2022 le."JKL"Enable." B0 3132 3322 456E 6162 6C65 2022 4446 4722 123"Enable."DFG" C0 456E 2042 5245 414B 206B 6579 4B62 6449 En.BREAK.keyKbdI 3 D0 6E74 6572 6365 7074 4E6F 2044 7269 7665 nterceptNo.Drive 3H E0 7320 20C0 5265 6164 732F 4572 726F 7220 s...Reads/Error. F0 4449 5220 4472 6976 654E 6FC0 4C6F 7765 DIR.DriveNo.Lowe DRV 00 7374 2044 7269 76C0 01F2 F850 C0C0 C0C0 st.Driv....P.... 0 10 C0C0 4849 4D45 4DC0 456E 2043 6C65 6172 ..HIMEM.En.Clear 0H 20 204B 6579 436F 7079 2043 6F50 7377 7264 .KeyCopy.NoPswrd 30 4368 6169 6E20 496E 7075 743F 4B79 6272 Chain.Input?Kybr DRS 40 6420 5265 7065 6174 3235 6D73 446C 6179 d.Repeat25msDlay 109 50 73C0 C0C0 5772 6974 6573 2F45 7272 6F72 s...Writes/Error 6DH 60 5072 7472 4869 6768 7374 4368 4461 7465 PrtrHighstChDate 70 5469 6D65 436F 6C64 4461 7465 5469 6D52 TimeColdDateTimR 80 6573 6574 524F 5554 4520 444F 2C4E 4C20 esetROUTE.DO,NL. 90 436C 6F63 6835 302F 3630 6379 4368 6169 Clock50/60cyChai A0 6E20 5061 7573 653F 4F76 6572 7269 6465 n.Pause?Override B0 4155 544F 523D 434D 4420 5265 7065 6174 AUTOR=CMD.Repeat FRS C0 466F 7263 6520 4C2F 432C 5920 426C 696E Force.L/C,Y.Blin 4 D0 6B20 4375 7273 6F72 4375 7273 7256 616C k.CursorCursrVal 4H E0 C0C0 C0C0 5469 6D65 4C6F 6F70 4075 6C74 ....TimeLoopMult F0 456E 6162 6C65 5752 4449 5250 0202 C04D EnableWRDIRP...M APPENDIX SYSTEM PRINT ENHANCEMENT Page 129 ABOUT NEWDOS/80 PDRIVES First some things to presume :- 1. NEWDOS/80 has a standard of 5 sectors per Granule (SPG) 2. 1 Granule is the smallest amount of space that can be allocated on a Disk Drive i.e. a program only 10 bytes long takes up 5 sectors or 1280 bytes of disk storage. 3. A lump is a measure of disk storage. Each lump is represented by 1 byte in the GAT sector (1st sector of Directory). One bit of this byte is used for each gran taken. The total number of bits used in each byte is the same as the GPL value (i.e. the number of Granules per Lump). The bits are allocated starting from bit zero. 4. In the lockout table each lump is represented by 1 byte just as in the GAT sector. Similarly, one bit of this byte is used for each gran not locked out. This lockout table is tested as to whether it is in use or not by reading byte 60H of the GAT sector. If not in use this byte should be FFH. As this is the lockout byte for the Boot sector it is not surprising that it should not be locked out. The DOS tests this to see if the lockout table has been over-run by the number of bytes used by the allocation table above it i.e. the number of lumps on the disk. In NEWDOS/80, whenever the number of lumps is greater than 96, the lockout table is used by the Granule Allocation Table. This happens, for example, when the number of sectors used in the drive amounts to more than 960 and GPL=2. - : - : - : - : - : - : - : - : - To begin, the simple :- TI=A : TD=A : TC=40 : SPT=10 : TSR=3 : GPL=2 : DDSL=17 : DDGA=2 This means that we have :- TI=A a standard Tandy Interface Type Dens Side Sect/Tr TD=A Single Density, Single Sided A S/D S/S 10 C S/D D/S 20 (only covers 5 inch) E D/D S/S 18 G D/D D/S 36 TC = 40 Track Count - 40 Track Drive (48 Tracks per Inch) SPT = 10 Sectors per Track (Standard IBM format 256byte Sector) TSR = 3 Stepping rate between Tracks (0=fastest : 3-slowest) GPL = 2 Number if min. units of space (granules) per lump DDSL = 17 Disk Directory starting Lump DDGA = 2 Allocation of space units to Directory Page 130 ABOUT PDRIVES APPENDIX ABOUT NEWDOS/80 PDRIVES Now to get into it :- If you have a 40 Track, Single Sided, Single Density (GPL=2) Drive then 1 Lump = 1 Track, so all is very simple. To determine the status of any track (lump) just count the required number of bytes into the GAT sector and look at which bits are set. There is another table which looks like almost a copy of the Granule Allocation Table below it starting at 60H. This is the lockout table and is used sometimes to tell the DOS not ti use the space represented here as some trouble had occurred during formatting. You might have noticed that this situation the GAT sector show a complete unused lump as FC. This means that all that is used in each byte are bits 0 & 1 (GPL=2). Now each byte refers to a Lump and in the simplest case this is also 1 Track (as above). So you can see what track a byte refers to by counting each byte. Now pull your socks up :- In double sided drives the SPT changes to twice as many because tracks span sides. Then the track-nump nexus is broken. TI=A : TD=C : TC=40 : SPT=20 : TSR=3 : GPL=2 : DDSL=17 : DDGA=2 The SPT has changed to 20, TC remains at 40, GPL at 2, etc. Now the total number of sectors = TC * SPT = 40 * 2 = 800 And the Directory is still at SPG * GPL * DDSL = 5 * 2 * 17 = 170. You have changed the relative position of the directory on the disk, haven't you. Also the number of bytes used by the system in the GAT sector has climbed to 80 (50H) instead of the old 40 (28H). Well why is this so ... because each lump is still 2 grans and considering the sectors per gran does not change, there are twice the number of sectors. So we take the big step :- We now make GPL=4. Now the Directory is back to the same relative position (Sector 340 in 800 Sectors - the same as 170 in 400) and only 40 bytes are used in the GAT sector and theTrack-Lump nexus is restored. However in the GAT an unused lump is now F0, quite a step from FC. Bananas. FC has bits 0 & 1 both 0 catering for 2 granules per lump while F0 has bits 0,1,2 & 3 all 0 this catering for 4 granules per lump. A conclusion can be drawn here as to how many grans to a lump are possible. You guessed it, 8. For a similar reason the number of sectors per granule is limited to 8. Thus we have a maximum capability of 8 * 8 * (202bytes possible in the GAT sector) * 256 bytes per sector. This comes to 3,309,568 bytes (over 3 Megabytes) in 1 PDRIVE slot or 26,476,544 bytes (over 25 Megabytes) for all 8 slots capable. Well, this is how they get on in hard drives with all those thousands of sectors. APPENDIX ABOUT PDRIVES Page 131 Now pull up your proverbial socks up further :- How about double density ? (expletive deleted) 18 sectors per track. How the hell ?? 5 doesn't go into 18. So we have permanently broken the Track-Lump nexus so we have to learn what a lump means and what APPARAT says about Directory start sectors. Now you all know 17. In 40 Tracks this is the standard DDSL and in single density with GPL=2 also the Directory starting Track, but in 80 Tracks APPARAT recommends 35 as the DDSL. In NEWDOS/80 we place the directory at the start of a lump, not a track. Obviously in the double density the lump must span tracks as well as sides ( 5 does not go intto 18 again ). So in the standard Model III, the Type of Drive is TD=E ; if DDSL = 17 then the Directory starting sector is still 170 (if GPL=2) in a 80 track drive ; not even a quarter way through the disk. Although, say, with DDSL=24 the Directory would start about a third way through, up to now GPL=2 and DDSL=17 are standard in all MOdel III disks emanating from Apparat. However, with 40 track double sided there is no established precedent. The most obvious thing to do is to balance the number of sectors with the GPL or make the DDSL suit. There is a precedent for 80 track double sided in that Apparat suggests DDSL=35 and GPL=8 which does balance the amounts quite well. What a lot of pedantic nonsense you say !! Well, as an extreme case, on an 80 track D/S D/D disk there are 80 * 36 = 2880 sectors and if GPL=2 and DDSL=17 the Direcory would start at Drive sector 170. How bloody ridiculous. There is actually no disadvantage in this situation except that you will hear the poor 80 tracker rattle over 40 to 60 tracks nearly every time it accesses a program (the program must be found in the DIR) and the physical wear this might precipitate. With judicious use of the GPL and DDSL values the normal head movement can be cut to a minimum. To keep the lockout table in use, and save the complications caused by it not being so, it seems wise to balance the GPL against the number of granules on the disk as well as keeping the Directory in a sensible place on the disk. A zap (23) to the COPY function explains that DIRCHECK sees an error where none exists when the lockout table is used as part of the Granule allocation table. Zap 57 of NEWDOS/80 corrects an error occurring when the number of lumps exceed 96. Page 132 ABOUT PDRIVES APPENDIX ABOUT NEWDOS/80 PDRIVES Now some theory :- In a drive the most common access is to the SYS files. These are all placed on a system disk in very particular places. The RST 28H Restart which loads these SYS files does not access the HIT Sector at all. The contents of the A register dictates what DEC (location in the Directory) will be loaded. BOOT/SYS and the main resident DOS module SYS0/SYS reside at the start of a disk. All other SYS files are clustered around the Directory from 65 sectors before to 70 sectors after. This is the most efficient place for them no matter where the Directory is or how long it is. These SYS files are used to perform functions and to manipulate Basic programs etc. In the simplest case where SPT=10 the SYStem files take over 145 sectors which is 15 tracks. If SPT=36 then the 145 sectors use just over 4 tracks. The head, in a typical case, moves to the SYS program then to the Directory, then to the program. Considering the fact that the start of the program is the part accessed (you will only at a maximum access the end of the disk minus the length of the program) as well as the likelyhood of some free space at the end of the disk, then just over a third of the way through the disk sounds reasonable efficient place for the start of a Directory. In TRSDOS Model III the number of sectors per gran is 3 and the number of grans per track 6. This keeps the track - lump nexus and the number of bytes used in the GAT sector to 40H. However there is no accomodation for double sided or 80 track disks. In LDOS it is almost the same in track-GAT byte usage and in DOSPLUS the same plan is used. Both these DOSes now cater side and track variation. In both DOSPLUS and LDOS a cylinder is used as a measure of space and it involves all the sectors ona given track, both sides. Thus on a hard drive, considered vertically, the number of surfaces that are used (i.e. the number of platters or disks * the number of sides used on each) on each track are all taken together as being a cylinder. This is the amount of space represented by a byte in the GAT sector. In hard drives LDOS partitions by heads so that it has a nexus which might not occur in NEWDOS/80. We have LDOS and TRSDOS users saying they cannot understand NEWDOS uasge of the word lump but as NEWDOS was first marketed when the state of the art was very rudimentary it was then a very advanced DOS and for that matter still is in some of its functions and capabilities. APPENDIX ABOUT PDRIVES Page 133 ABBREVIATIONS ! Single precision declaration symbol : NTF = 4 # Double precision declaration symbol : NTF = 8 $ String declaration symbol : NTF = 3 % Integer precision declaration symbol : NTF = 2 123 3 keys which when pressed simultaneously execute DEBUG AACC The auxiliary Accumulator ACC The Accumulator ( the A register ) ASC ATTRIB param allowing or not automatic Disk space deallocation ASE ATTRIB param allowing or not automatic Disk space allocation Bit Smallest part of memory. 8 bits to a byte Buffer An area of memory set aside for I/O, typically sector read Bus Multi wired connection between a Device and the CPU Byte A unit of storage in the computer CBF Copy by File Chain To obtain keyboard Input from a file created for this purpose Char A character is usually a printable value ( equivalent to a byte ) CPU Central Processing Unit CR Carriage Return Cass Cassette recording Device Char Character (in the ASCII range 33 to 127) Cur Cursor DAM Data Address Mark DCB Device Block Control DDGA Default Directory Granule allocation DDSA Default Directory DDSL Default Directory Starting Lump DEC Directory Entry Code - refers to the position in the Directory DFG 3 keys which when pressed together pass control to MINI-DOS DIR Disk Drive Directory DOS Disk Operating System DP Double Precision DRQ Data Request ( from a Device ) EOF End of File EOL End of line EOM End of message EOR End of Record EOS End of Statement ESF Exatron Stringy Floppy (a small Data storage Device) Ext Extension to a File name (e.g. prog/BAS) Extent 2 bytes of control data inside an File Directory Entry FCB File Control Block FDC Floppy Disk Controller File A collection of data comprising one entry in the Directory FPDE File Primary Directory Entry FXDE File Extended Directory Entry GAT Granute Allocation Table Page 140 ABBREVIATIONS APPENDIX GPL Granules per Lump Hash Mathematically coded sum of the ASCII values of a file HDDN Hard Disk Drive Number HIMEM Highest Memory locationavailable for use HIT Hash Index Table IFF1 Interrupt flip flop No 1 - This is the Interrupt flag IFF2 Interrupt flip flop No 2 - This is the Interrupt storage flag I/O Input or Output from a Device or routine INT Integer INTRQ Interrupt request from a device or routine IPL Initial Program Loader JKL 3 keys which when pressed together invoke the Screen-print utility LF Line feed LOC Current location in the File LOF Length of file Logical Logical seems in most cases to mean counting from 0 LRL Logical Record Length LSB Least significant byte Lump A section of disk space represented as 1 byte of the GAT sector ms Millisecond MSB Most significant byte PC Program Counter (Reg pair holding the next execution address) RAM Random Access Memory ROM Read only Memory RST The Restart instruction SCC Space Compression Codes Sector Block of 256 bytes of storage on Disk SFS Section's Sirst Surface SP Single Precision SPC Space Compression Codes SPG Sectors per Granule SSC Section Surface Count TC Track Count TD Type of Drive TI Type of Interface TOPMEM The highest Memory location available for use TPS Tracks per Surface Track The unit of disk space the drive head(s) passes over in 1 revolution TSR Track stepping Rate Vector An address which contains a jump to a routine VFS Volume's first Sector VSC Volume Surface Count WRA1 Work Area number 1 ( the Accumulator ) WRA2 Work Area number 2 ( the auxiliary Accumulator ) Zap To change bytes in a program APPENDIX ABBREVIATIONS Page 141 INDEX & Function Extra uses ......................... 124 16 Bit Arithmetic Codes ....................... 110 16 Bit Loads .................................. 107 8 Bit Arithmetic .............................. 108 8 Bit Loads ................................... 106 8 Bit Logical Codes ........................... 109 ASCII Control Codes ........................... 56 ASCII Keyable Characters ...................... 57 Abbreviations ................................. 130 Accumulator ................................... 76 Accumulators .................................. 20 Add/Subtract Flag ............................. 75 Alphabetic Listing ............................ 86 Basic Data Storage Area ....................... 18 Basic Overlay Area ............................ 23 Bibliography .................................. 138 Bit Instructions .............................. 112 Bit-Mapped Listing ............................ 92 Block Search Codes ............................ 111 Block Transfer Codes .......................... 111 Call Instructions ............................. 119 Carry Flag .................................... 75 Cassette Routine Address ...................... 3 Character Sets Model III ...................... 54 Communications Region ......................... 7 Compare HL/DE Restart ......................... 10 Compare previous Input Restart ................ 8 Contents ...................................... iv Contents by Memory ............................ vi DAA Instruction ............................... 114 DAM - Data Address Mark ....................... 35 Data Type Restart ............................. 11 DCB Type Values ............................... 15 DEBUG Restart ................................. 13 Device Control Blocks ......................... 14 Device Handling ROM area ...................... 2 DOS Function Call Restart ..................... 12 DOS Command Buffers ........................... 23 DOS I/O File Buffers .......................... 23 DOS Main Resident Module ...................... 23 DOS Modules ................................... 26 Page 142 INDEX APPENDIX INDEX DOS Overlay Area ............................... 23 DOS Routines .................................. 28 DOS Sector Buffers ............................ 23 DOS Storage Area .............................. 16 Device Control Blocks ......................... 14 Directory Entries ............................. 66 Disk Basic Reserved Word Jumps ................ 24 Disk I/O FCB's & Buffers ...................... 27 Displacement Values ........................... 76 ESF ........................................... 9 ESF ROM Usage ................................. 2 Error Messages ................................ 62 Error Messages Disk Basic ..................... 63 Error Messages Level II ....................... 63 Error Messages TRSDOS ......................... 63 Exatron Stringy Floppy ........................ 2 Extra ROM Addresses Mod 3 ..................... 3 FDC Information .......................... 30 to 33 Flags ......................................... 74 General Purpose Instructions .................. 115 Granule Allocation Table ...................... 67 Graphics Characters ........................... 58 Half Carry Flag ............................... 75 Hard Drive Parameters ......................... 71 Hard Drives ................................... 69 Hash Index Table .............................. 68 I/O Addresses ................................. 2 INput Instructions ............................ 120 IPL ........................................... 3 Initialisation ................................ 35 Initialisation Mod 1 DOS ...................... 40 Instruction Set Listings ...................... 72 Interrupt Restart ............................. 13 Interrupts Model III .......................... 22 Jump Instructions ............................. 118 Jump Relative Instructions .................... 118 APPENDIX INDEX Page 143 INDEX Key values ................................ 4,56,57 Keyboard Buffer ........................... 4,16 Keyboard DCB .................................. 14 Keyboard Map .................................. 4 Keyable Characters ............................ 57 Lev.2 Basic Input Buffer Mod I ................ 22 Lev.2 Basic Input Buffer Mod III .............. 20 Lev.2 Start Basic Prgm Mod I .................. 20 Lev.2 Start Basic Prgm Mod III ................ 22 Line Printer DCB .............................. 21 Mathematic ROM area ........................... 2 Mnemonics ..................................... 73 Model I Boot Sector ........................... 41 Model I DOS Addresses ......................... 2 Model I Cassette Addresses .................... 2 Model III Boot Sector ......................... 48 NEWDOS/80 RAM Usage ........................... 23 Numeric Listing ............................... 77 OUT Instructions .............................. 120 Parity/Overflow Flag .......................... 75 PDRIVE Parameters ............................. 65 PDRIVE Storage ................................ 23 Ports .................................... 30 to 33 Printer ASCII Codes ........................... 56 Printer Control Block ......................... 15 Program Counter ............................... 76 RAM ........................................... 7 RAM Usage - NEWDOS/80 ......................... 23 Reserved Word Codes ........................... 59 Reserved Word Codes & Routines ................ 58 RESet Instructions ............................ 113 Reset Restart ................................. 8 Restarts .................................. 7 to 13 Restart List of Addresses ..................... 7 Return Instructions ........................... 119 ROM ........................................... 1 ROM Basic Interpreter ......................... 2 ROM Call DOS Exits ............................ 25 Page 144 INDEX APPENDIX INDEX ROM Error Messages ............................ 63 ROM Monitoring area ........................... 2 ROM Routines Model III ........................ 3 ROM Tables & References ....................... 2 ROM Utilities ................................. 2 Rotate and Shift Instructions ............. 116,117 ROUTE Control Block ........................... 22 RS-232C ROM Routines Model III ................ 3 RS-232C Control Blocks Model III .............. 21 SET Instructions .............................. 113 Sign Flag ..................................... 75 Space Compression Codes ....................... 6 Space Compression Codes ....................... 59 Stack Operations .............................. 76 Start Basic Address List ...................... 27 Start Basic Programs Under DOS ................ 23 SYSTEM Commands Extra Print ................... 126 SYSTEM Parameter Storage ...................... 23 TRSDOS Routines ............................... 29 Test Alpha/Numeric Restart .................... 9 Test Data Type Flag Restart ................... 11 USR Addresses ................................. 25 Unlisted Instructions ......................... 122 Variable Storage .............................. 60 Video DCB ..................................... 14 Video Memory .................................. 6 Z-80 Flags .................................... 74 Zero Flag ..................................... 75 APPENDIX INDEX Page 145