top of page

PDP-11 BASIC Analysis Project

The PDP-11 BASIC Analysis project is an effort to disassemble and analyse line-by-line the operation of the PDP-11 BASIC code. The analysis is extensive and multiple blog entries have been posted describing different components of the BASIC application.

 

A couple of clarifications in advance, this is not a project about loading or using BASIC on the PDP-11.

  • If you want to load and use PDP-11 BASIC in an emulated environment, go here.

  • If you want to understand how PDP-11 BASIC is loaded and run, go here.

  • If you want more information on programming BASIC on the PDP-11, go here.

If, you're looking for a line-by-line disassembly of the PDP-11 BASIC code, here you go:

  • Part 0: The PDP-11 BASIC code relies heavily on the use of software TRAPs. You need a clear and concise understanding of these before any of the rest of this series is going to make sense. Also, this article describes the code used by PDP-11 BASIC to "route" TRAPs to different handling subroutines.

  • Part 1: Analyses the TTY interrupt handling routines, TRAP 0, TRAP 2 and TRAP 66.

  • Part 2: Analyses TRAP 100, TRAP 72 and TRAP 152.

  • Part 3: Analyses TRAP 70, TRAP 10, TRAP 4 and the odd-numbered TRAP values.

  • Part 4: Describes the initial setup and the display of the short-form options dialog.

  • Part 5: Explains the operation of the long-form options dialog, the memory and tape reader configuration, deleting the extended functions, loading the EXF function, jumping to display "READY" and entering the syntax parsing loop.

  • Part 6: Starts the analysis of the syntax parsing code by looking at the identification of line numbers, determining which command has been entered and the tokenising of the BASIC command.

  • Part 7: Analyses TRAP 74, TRAP 76, TRAP 102 and TRAP 104. These are used in the second part of the syntax parsing code analysis.

  • Part 8: Describes the remainder of the syntax parsing code, the execution of BASIC commands in immediate mode and the storage of BASIC commands in deferred mode.

  • Part 9: Examines TRAP 106 and the operation of the BASIC LIST command.

  • Part 10: Looks at the operation of the OLD, SAVE and DELETE BASIC commands.

  • Part 11: Describes the BASIC runtime state storage model and examines in detail TRAP 130, TRAP 122, TRAP 112 and TRAP 114.

  • Part 12: Analyses the GOTO, GOSUB and RETURN BASIC commands, as well as TRAP 120 and TRAP 134.

  • Part 13: Explains in detail the operation of the integer-to-ASCII functionality by examining TRAP 64, TRAP 14 and TRAP 12.

  • Part 14: Examines the structure of floating point numbers in PDP-11 BASIC and looks at TRAP 36 and TRAP 40.

  • Part 15: This post examines some of the floating point operations; TRAP 24 (negatate a floating point number), TRAP 20 (add two floating point numbers) and TRAP 22 (subtract two floating point numbers).

  • Part 16: Examines the multiplication code; TRAP 62 (32-bit integer multiplication), TRAP 16 (16-bit integer multiplication) and TRAP 30 (floating point multiplication).

  • Part 17: This post will take a look at some more floating point manipulation TRAPs; TRAP 26 (floating point division) and TRAP 34 (floating point comparison). TRAP 54, which is used by TRAP 34, is also described, along with TRAP 32.

  • Part 18: Describes the ASCII-to-floating point parsing code, TRAP 6.

  • Part 19: Introduces user-defined functions and describes the BASIC DEF command, along with some TRAPs that support its operation (TRAP 140, TRAP 126 and TRAP 110).

  • Part 20: Describe the operation of TRAPs that are used to manage floating point variables on the stack and in the runtime state storage. We'll be looking at TRAP 142, TRAP 150, TRAP 146, TRAP 144 and TRAP 132.

  • Part 21: Analyses the mathemetical expression evaluation code. Expressions are used all over the place and the main entry point to parsing them is TRAP 136.

  • Part 22: Describes the operation of TRAP 124 and the BASIC DIM and LET commands, as well as the DATA and REM commands.

  • Part 23: Analyses the BASIC IF command.

  • Part 24: Analyses the BASIC INPUT, READ and RESTORE commands.

  • Part 25: Analyses the BASIC FOR and NEXT commands.

  • Part 26: Describes TRAP 116 and the BASIC RUN, STOP, END and RANDOMIZE commands.

This project is still underway, so I will keep this page up to date as I add new parts of the analysis.

bottom of page