Microsoft BASIC Decoded & Other Mysteries
Total Page:16
File Type:pdf, Size:1020Kb
Written by James Farvour Microsoft BASIC Decoded & Other Mysteries Foreword by Harvard Pennington Edited by Jim Perry Graphics by John Teal Cover by Harvard Pennington TRS-80 Information Series Volume 2 Contents Foreword .............................................................................4 Single Precision Routines..............................................21 Chapter 1: Introduction .......................................................5 SP Addition ...............................................................22 Overview.........................................................................6 SP Subtraction...........................................................22 Memory Utilization .........................................................6 SP Multiply ...............................................................22 Communications Region .................................................8 SP Divide ..................................................................22 Level II Operation ...........................................................8 SP Comparison..........................................................22 Input Phase ......................................................................8 Double Precision Routines ............................................22 Interpretation & Execution..............................................9 DP Addition...............................................................22 Verb Action...................................................................11 DP Subtraction ..........................................................23 Arithmetic & Math ........................................................11 DP Multiply...............................................................23 I/O Drivers.....................................................................12 DP Divide..................................................................23 System Utilities .............................................................13 DP Comparison .........................................................23 IPL.................................................................................13 Math Routines ...............................................................23 Reset Processing (non disk)...........................................13 Absolute Value..........................................................23 Reset Processing (disk) .................................................14 Return Integer............................................................23 Disk BASIC...................................................................14 Arctangent .................................................................24 Cosine........................................................................24 Chapter 2: Subroutines ......................................................15 Raise Natural Base ....................................................24 I/O Calling Sequences...................................................15 Raise X To Power Of Y ............................................24 Keyboard Input..............................................................15 Natural Log ...............................................................25 Scan Keyboard ..........................................................15 FP To Integer.............................................................25 Wait For Keyboard....................................................16 Reseed Random Number...........................................25 Wait For Line ............................................................16 Random Number .......................................................25 Video Output.................................................................16 Sine............................................................................25 Video Display............................................................16 Square Root...............................................................25 Clear Screen ..............................................................17 Tangent......................................................................26 Blink Asterisk............................................................17 Function Derivation.......................................................26 Printer Output................................................................17 System Functions ..........................................................27 Print Character...........................................................17 Compare Symbol.......................................................27 Get Printer Status ......................................................17 Examine Next Symbol...............................................27 Cassette I/O ...................................................................18 Compare DE:HL .......................................................27 Select & Turn On Motor ...........................................18 Test Data Mode .........................................................27 Write Leader..............................................................18 DOS Function Call....................................................28 Read Leader...............................................................18 Load DEBUG............................................................28 Read One Byte ..........................................................18 Interrupt Entry Point..................................................28 Write One Byte..........................................................18 SP In BC:DE To WRA1............................................28 Conversion Routines .....................................................19 SP Pointed To By HL To WRA1 ..............................28 Data Type Conversions .................................................19 SP Into BC:DE ..........................................................29 FP To Integer.............................................................19 SP From WRA1 Into BC:DE ....................................29 Integer To SP.............................................................19 WRA1 To Stack ........................................................29 Integer to DP .............................................................19 General Purpose Move ..............................................29 ASCII to Numeric .........................................................19 Variable Move...........................................................29 ASCII To Integer.......................................................19 String Move...............................................................30 ASCII To Binary .......................................................19 BASIC Functions ..........................................................30 ASCII To DP.............................................................20 Search For Line Number ...........................................30 Binary To ASCII ...........................................................20 Find Address Of Variable..........................................30 HL To ASCII & Display ...........................................20 GOSUB .....................................................................31 Integer To ASCII.......................................................20 TRON........................................................................31 FP To ASCII..............................................................20 TROFF ......................................................................31 Arithmetic Routines ......................................................21 RETURN...................................................................31 Integer Routines ............................................................21 Write Message...........................................................31 Integer Addition ........................................................21 Amount Of Free Memory..........................................31 Integer Subtraction ....................................................21 Print Message ............................................................32 Integer Multiplication................................................21 Number Representation.............................................32 Integer Division.........................................................21 Integer Comparison ...................................................21 Chapter 3: Cassette & Disk ...............................................33 2 Microsoft BASIC Decoded & Other Mysteries Acknowledgments Cassette I/O....................................................................33 Cassette Format .............................................................34 This book has been a long time in its creation, without the SYSTEM Format...........................................................34 help, advice and support of many people it would not have Disk I/O .........................................................................35 been possible. In particular thanks are due to Rosemary Disk Controller Commands ...........................................35 Montoya for her days of keyboarding, David Moore for Disk Programming Details.............................................37 hours of example testing, Jerry De Diemar, Mary and MG DOS Exits......................................................................37 at Helens place for turning the Electric Pencil files into type Disk BASIC Exits..........................................................38 and Al Krug for his