LPC (Line Printer Control) Driver Disassembly
Page Customization
Page Index
LPC/CMD
Other Navigation
Description:
LPC is a small TSR (Terminate and Stay Resident) utility that installs a keyboard/display driver to handle line printer control characters. The loader at 7000H reserves 42 bytes of low memory, patches the DOS keyboard vector, and relocates the driver code into protected memory.
The driver intercepts character output and tracks control characters (CR, LF, FF). When a carriage return follows another control character, it routes through ROM's CR handler to prevent double line feeds and other printer output issues.
Program Entry: 7000H
Memory Used: 42 bytes (002AH) reserved below high memory
Variables:
| Address | Bytes | Purpose |
|---|---|---|
| 4026H | 2 | DOS high memory pointer (HIMEM) |
| 4411H | 2 | DOS keyboard/display driver vector |
| 7036H | 2 | Patch location: original vector stored here |
| 7046H | 2 | Patch location: original vector stored here |
| 704DH | 2 | Patch location: original vector stored here |
| 7057H | 1 | Last character storage (pre-relocation address) |
Technical Notes
Relocation: The driver code at 702EH-7057H is copied to low memory below the original keyboard vector address. The addresses 7036H, 7046H, 704DH reference locations within the driver that get patched with the original DOS keyboard vector before relocation. After relocation, these become relative offsets within the relocated code.
Vector Chain: The loader stores the original keyboard vector (from 4411H) into the driver at three JP instruction locations. This allows the driver to chain to the original handler for normal character output while intercepting specific control sequences.
Control Character Handling: The driver tracks CR (0DH), LF (0AH), and FF (0CH). When any of these control characters is followed by a CR, the driver routes through ROM address 042AH (the CR handler) instead of normal character output at 03C3H. This prevents double line feeds that can occur when CR+LF sequences are sent to line printers.
Disassembly:
7000H - Loader Entry Point
This routine verifies sufficient memory is available (high memory must be at 03C2H or above), saves the current keyboard vector, reserves 42 bytes of memory, patches the vector addresses into the driver, relocates the driver to protected memory, and updates the DOS keyboard vector to point to the new driver.
702EH - Keyboard/Display Intercept Driver
This driver intercepts character output to handle line printer control sequences. It strips bit 7 from characters, tracks the last character output, and provides special handling when control characters (CR, LF, FF) follow each other. When a CR follows a control character, it routes to ROM's CR handler to prevent printer output issues. This code is relocated to low memory at runtime.
Last character was not a control character - normal output path.
Last character was a control character - check if current is CR for special handling.
7057H - Last Character Storage
Single byte storage for tracking the last character output. Initialized to 0DH (CR).