Improve lptdrv documentation
authorSvjatoslav Agejenko <svjatoslav@svjatoslav.eu>
Sat, 2 Aug 2025 00:36:36 +0000 (03:36 +0300)
committerSvjatoslav Agejenko <svjatoslav@svjatoslav.eu>
Sat, 2 Aug 2025 00:36:36 +0000 (03:36 +0300)
Networking/LPT communication driver/index.org
Networking/LPT communication driver/test.ASM

index edb8565..5ba91f0 100755 (executable)
@@ -31,31 +31,61 @@ By utilizing only three wires and software controlled bit-banging
 algorithm, custom, comparatively simple, cheap and long cable can be\r
 built to connect 2 computers in a DIY network setup.\r
 \r
-* LPT Communication Driver (LPTDRV)\r
+* LPT Communication Driver\r
 \r
-LPTDRV is a memory-resident driver designed to facilitate\r
-communication between computers using parallel printer ports\r
-(LPT). Developed in assembly language, this driver hooks into the\r
-system's IRQ 0 to periodically monitor LPT port statuses, allowing for\r
-data exchange without requiring constant polling by applications.\r
 \r
-Features and Capabilities:\r
+The LPT Communication Driver is a Terminate and Stay Resident (TSR)\r
+driver designed to facilitate communication between computers using\r
+parallel printer ports (LPT). This driver uses bit-banging to send and\r
+receive data serially over the LPT port, utilizing only three wires\r
+for communication.\r
 \r
-- Interrupt-Driven Communication :: By utilizing hardware interrupts,\r
-  LPTDRV efficiently handles data transmission and reception without\r
-  overwhelming system resources.\r
+Driver hooks into the system's IRQ 0 to ensure that system timer\r
+always keeps executing it in the background. While operating as a\r
+background process, it periodically monitors LPT port to detect\r
+incoming transmission. When transmission is detected, driver receives,\r
+decodes and stores it into preallocated 5000 byte receive buffer.\r
 \r
-- Buffer Management :: It features separate 5000-byte buffers for\r
-  incoming and outgoing data, providing smooth asynchronous\r
-  communication.\r
+Applications can then communicate with the driver on their own\r
+schedule using INT 63h to poll for and retrieve received messages, if\r
+any. Applications can also send outgoing messages into 5000 byte\r
+driver outbox memory buffer. Thereafter driver will transmit those\r
+messages in background mode over the wire.\r
+\r
+Download:\r
+- Source code: [[file:lptdrv.asm][lptdrv.asm]]\r
+- Compiled binary: [[file:lptdrv.com][lptdrv.com]]\r
+\r
+\r
+** Driver API\r
+*** Deactivate the driver\r
+\r
+*Parameters*:\r
+: AH = 0\r
+\r
+*Returns*: None\r
+\r
+*** Activates the driver\r
+\r
+*Parameters*:\r
+: AH = 1\r
+\r
+*Returns*: None\r
+\r
+*** Retrieve downloaded data from the driver's input buffer\r
+\r
+*Parameters*:\r
+: AH = 2\r
+: ES:DI = Pointer to the location where downloaded data should be placed\r
+\r
+*Returns*:\r
+: AX : Number of bytes downloaded\r
 \r
-- Protocol Handling :: Implements a simple protocol for data encoding\r
-  and decoding over parallel ports, demonstrating practical low-level\r
-  communication techniques.\r
+*** Upload data to the driver's output buffer for transmission\r
 \r
-- Ease of Integration :: Applications can communicate with the driver\r
-  using INT 63h, making it straightforward to integrate into existing\r
-  software.\r
+*Parameters*:\r
+: AH = 3\r
+: DS:SI: Pointer to the data to be uploaded\r
+: CX: Number of bytes to upload\r
 \r
-- Speed :: During my testing, it achieved a maximum transfer speed of\r
-  approximately 12 Kb/s.\r
+*Returns*: None\r
index e98e680..efcb500 100644 (file)
@@ -3,28 +3,28 @@
 org 100h\r
 \r
 mov     ah, 1   ; activate driver\r
-int    63h\r
+int        63h\r
 \r
 l1:\r
-mov    di, last\r
-mov    ah, 2\r
-int    63h\r
-cmp    ax, 0\r
+mov        di, last\r
+mov        ah, 2\r
+int        63h\r
+cmp        ax, 0\r
 je     l2\r
 \r
-cmp    byte [last], 0\r
+cmp        byte [last], 0\r
 jne    l3\r
 call   send4kb\r
 jmp    l2\r
 l3:\r
 \r
-add    ax, last\r
-mov    di, ax\r
-mov    byte [ds:di], 36\r
+add        ax, last\r
+mov        di, ax\r
+mov        byte [ds:di], 36\r
 \r
-mov    ah, 9\r
-mov    dx, d1\r
-int    21h\r
+mov    ah, 9\r
+mov    dx, d1\r
+int        21h\r
 \r
 \r
 l2:\r
@@ -39,34 +39,34 @@ mov     ah, 0
 int     16h\r
 cmp     al, 27\r
 je      quit\r
-cmp    al, 13\r
-je     send\r
-cmp    al, 32\r
-je     TestSpeed\r
+cmp        al, 13\r
+je         send\r
+cmp        al, 32\r
+je         TestSpeed\r
 \r
 jmp     l1\r
 \r
 quit:\r
 mov     ah, 0   ; deactivate driver\r
-int    63h\r
+int        63h\r
 ret\r
 \r
 send:\r
 mov     cx, d1 - d2\r
-mov    si, d2\r
-mov    ah, 3\r
-int    63h\r
+mov        si, d2\r
+mov        ah, 3\r
+int        63h\r
 jmp    l1\r
 \r
 send4kb:\r
-mov    cx, 4096\r
-mov    si, last\r
-mov    ah, 3\r
-int    63h\r
+mov        cx, 4096\r
+mov        si, last\r
+mov        ah, 3\r
+int        63h\r
 ret\r
 \r
 TestSpeed:\r
-mov    byte [last], 0\r
+mov        byte [last], 0\r
 mov     cx, 0\r
 \r
 l5:\r
@@ -74,11 +74,11 @@ push        cx
 call   send4kb\r
 l4:\r
 mov     di, last + 1\r
-mov    ah, 2\r
-int    63h\r
-cmp    ax, 0\r
+mov        ah, 2\r
+int        63h\r
+cmp    ax, 0\r
 je      l4\r
-pop    cx\r
+pop        cx\r
 \r
 mov     dx, d3\r
 mov     ah, 9\r
@@ -95,6 +95,6 @@ jmp   l1
 \r
 d3      db '. $'\r
 d4      db 13, 10, 'done', 13, 10, '$'\r
-d2     db 'Quick brown fox jumped over the lazy dogs. 0123456789ABCDEF'\r
-d1     db 13,10,'Data recieved:'\r
+d2         db 'Quick brown fox jumped over the lazy dogs. 0123456789ABCDEF'\r
+d1         db 13,10,'Data recieved:'\r
 last:\r