http://altairbasic.org/ Altair BASIC 3.2 (4K) - Annotated Disassembly [This is a work in progress, about 90% complete] Here is a complete annotated disassembly of Altair BASIC 3.2 (4K). I have faithfully followed the program order, and the code naturally divides into three sections - the Interpreter, the Maths Package, and Initialisation. Each of these sections is more-or-less logically subdivided into a number of subsections. 1. The Interpreter Interpreter (Explanation) - Explanations and overviews of most of the internal logic used in BASIC. It describes the memory layout, key concepts, structures and variables, and you shouldn't look at a line of code until you've read through this. Section Base Size Key Functions 1.1 Restarts 0000 61 Start, SyntaxCheck, NextChar, OutChar, CompareHLDE, FTestSign, PushNextWord 1.2 Keyword Tables 003D 189 [no code in this section] 1.3 Error Codes & 00FA 152 [no code in this section] Globals GetFlowPtr, CopyMemoryUp, 1.4 Utility 0192 101 CheckEnoughVarSpace, CheckEnoughMem, Functions OutOfMemory, SyntaxError, DivideByZero, Error The BASIC Stop, Main, StoreProgramLine, 1.5 Prompt & 01F7 375 FindProgramLine, New, Run, ResetAll, Program InputLineWith'?', Tokenize, InputLine Storage 1.6 Terminal I/O 036E 32 OutChar_tail, InputChar 1.7 LIST Handler 038E 71 List 1.8 FOR Handler 03D5 76 For 1.9 Execution 0421 61 ExecNext, Exec 1.10 More Utility 045E 63 NextChar_tail, Restore, TestBreakKey, Functions CharIsAlpha, GetSubscript 1.11 Goto, Gosub, 049D 101 LineNumberFromStr, Gosub, Goto, Return, and Return FindNextStatement 1.12 Assigning 0502 20 Let, AssignVar Variables 1.13 IF Handler 0516 63 If 1.14 Printing 0555 143 Print, NewLine, PrintString, ToNextTabBreak, Tab 1.15 INPUT & READ 05E4 101 Input, Read Handlers 1.16 NEXT Handler 0649 65 Next 1.17 Expression 068A 135 EvalExpression, EvalTerm Evaluation 1.18 Variable 0711 232 Dim, GetVar, GetArrayVar Management Total size: 2041 bytes --------------------------------------------------------------------- 2. The Math Package Math package (explained) - All the concepts needed to understand the math package. Section Base Size Key Functions 2.1 Utility 07F9 17 FWordToFloat, FAddOneHalf Functions Addition & 2.2 Subtraction 080A 81 FSub, FAdd FNormalise, FMantissaLeft, 2.3 Mantissa Magic 085B 136 FMantissaInc, Overflow, FAddMantissas, FNegateInt, FMantissaRtOnce, FMantissaRtMult 2.4 Multiplication 08E3 247 FMul, FDiv, FDivByTen, FMulByTen, & Division FZero, FExponentAdd FTestSign_tail, InvSignToInt, 2.5 Sign Magic 09DA 40 SignToInt, Sgn, FCharToFloat, Abs, FNegate 2.6 Moving FACCUM 0A02 53 FPush, FLoadFromMem, FLoadFromBCDE, about FCopyToBCDE, FLoadBCDE, FCopyToMem 2.7 Unpacking & 0A37 64 FUnpack, FCompare Comparison 2.8 Converting to 0A77 60 FAsInteger, FMantissaDec, Int Integers 2.9 Reading 0AB3 124 FIn Numbers 2.10 Printing 0B2F 242 PrintIN, PrintInt, FOut Numbers 2.11 SQR 0C21 62 Sqr 2.12 RND 0C5F 54 Rnd 2.13 SIN 0C95 130 Sin Total size: 1307 bytes. --------------------------------------------------------------------- 3. Initialisation Section Base Size Key Functions 3.1 IO Detection 0D21 109 Init 3.2 Configuration 0D8E 367 Total size: 478 bytes.