1 ; Svjatoslav Agejenko
\r
3 ; compile with FASM - Flat Assembler
\r
5 ; TSR driver for LPT1 communication.
\r
6 ; Functions by INT 63h:
\r
14 ; Get downloaded data
\r
16 ; ES:DI - pointer where to place downloaded data
\r
18 ; AX = Number of bytes downloaded
\r
20 ; copies downloaded data from driver input buffers to
\r
25 ; DS:SI - pointer for data to be uploaded
\r
26 ; CX - amount of bytes to upload
\r
28 ; After interrupt, data will be immediately
\r
29 ; moved to communication driver own output buffer,
\r
30 ; and sent when line becomes avaiable.
\r
32 myint = 63h ; interrupt to hook
\r
33 upbuf = 5000 ; upload buffer size
\r
34 downbuf = 5000 ; download buffer size
\r
35 InPort = 37ah ; input port, for Parallel Printer Port Control Register
\r
36 defspd = 3 ; Default communication speed
\r
37 upbufp = last + downbuf
\r
42 ;============================ TSR initialization ====================
\r
44 mov dx, InPort ; reset line
\r
48 mov ax, 0 ; Saves old interrupt vector
\r
54 mov ax, cs ; Set new interrupt vector for IRQ 0
\r
58 mov ax, int63 ; Set new interrupt vector for INT 63
\r
59 mov [es:4 * myint], eax
\r
63 mov ax, last ; Calculate needed memory size, begin TSR
\r
64 add ax, upbuf + downbuf + 1000
\r
73 ;============================ IRQ 0 handler =========================
\r
76 pushf ; Execute default code in old int vector
\r
79 ;pusha ; Write 1 character, for debugging
\r
85 inc byte [cs:tmr] ; Update timer
\r
87 cmp [cs:progress], 0 ; Check if custom routine is already active
\r
89 cmp [cs:enabled], 0 ; Check if driver is enabled
\r
92 mov [cs:progress], 1 ; Set active flag
\r
103 ;============================ download data from LPT ================
\r
157 cmp word [cs:ubufsiz], 0
\r
160 ; =========================== send data to LPT ======================
\r
215 mov word [ubufsiz], 0
\r
222 mov [cs:progress], 0 ; Terminate active flag
\r
233 ;============================ INT 63h handler =======================
\r
247 mov dx, InPort ; reset line
\r
250 mov [cs:enabled], 1
\r
254 mov [cs:enabled], 0
\r
265 mov ax, [cs:dbufsiz]
\r
266 mov [cs:dbufsiz], 0
\r
275 add di, [cs:ubufsiz]
\r
277 add [cs:ubufsiz], dx
\r