; ; Driver for serial barcode scanners ; ; By Petr Adamek 1998. ; This program is public domain ; CSEG SEGMENT PUBLIC 'CODE' ASSUME CS:CSEG, DS:CSEG, ES:CSEG, SS:CSEG ;COM FILE ORG 0100h ; Origin for COM Files Serial7: JMP Install ; Install TSR COM EQU 03F8h ; Select Serial Port CR EQU 0Dh ; Return LF EQU 0Ah ; LineFeed EOT EQU "$" ; End of text Bell EQU 07h ; Bell ASC_STX EQU 02h ; STX - Start of text ASC_ETX EQU 03h ; ETX - End of text ASC_RETURN EQU 0Dh ; RETURN IRQ EQU 4 ; IRQ4 for COM1 Interrupts INT_MASK EQU 11101111b ; IRQ4 Mask for 8259 DATA EQU COM ; Serial Ports Data IER EQU COM+1 ; Interrupt Enable Register MCR EQU COM+4 ; Modem Control Register MSR EQU COM+6 ; Modem Control Status PIC_MASK EQU 21h ; 8259 Interrupt Mask Port PIC_EOI EQU 20h ; 8259 EOI Port Int_0C: PUSH AX ; Store Registers PUSH BX PUSH CX PUSH DX PUSH SI PUSH DI PUSH DS PUSH ES PUSH BP MOV DX,MCR ; Read the Modem Control Register IN AL,DX ; Or else!!!! MOV DX,DATA ; Character from Serial Port IN AL,DX CMP AL,ASC_STX JE INT_EOJ CMP AL,ASC_ETX JNE Cont MOV AL,ASC_RETURN Cont: MOV CL,AL Out1C: MOV AH,05h ; Output CL to Keyboard Buffer MOV CH,00h INT 16h INT_EOJ: MOV AL,20h ; Send EOI to 8259 OUT PIC_EOI,AL POP BP ; Restore Registers POP ES POP DS POP DI POP SI POP DX POP CX POP BX POP AX IRET Install: MOV AH,09h ; Display Program Info MOV DX,Offset BootMess INT 21h MOV AX,3500h+IRQ+8 ; Get Interrupt vector INT 21h MOV DX,Offset int_0C ; Checks to see if already CMP BX,DX ; Installed JZ Already ; If so display Installed message MOV AX,2500h+IRQ+8 ; Set Interrupt vector MOV DX,Offset int_0C INT 21h MOV AX,00h+10101110b ; Initilise Com Port 1 MOV DX,0000h ; Baud Rate 2400, 7-E-2 INT 14h MOV DX,MCR ; Set Modem-Control Register MOV AL,00001011b ; DTR, RTS and OUT2 bits OUT DX,AL MOV DX,IER ; Set Interrupt Enable Register MOV AL,00000001b ; On Serial Port Controller OUT DX,AL IN AL,PIC_MASK ; Read Current 8259 mask AND AL,INT_MASK ; Set Mask for Com Port not bit 4 OUT PIC_MASK,AL ; Write new 8259 mask MOV AH,09h ; Display Installed.. MOV DX,Offset InstMess INT 21h MOV DX,Offset Install ; Terminate Stay Resident (Exit) INT 27h Already: MOV AH,09h ; Display Already Installed.. MOV DX,Offset AlreMess INT 21h RET ; Exit without Installing TSR BootMess: DB "COM2KEYB Public Domain",cr,lf DB "COM1, Baud Rate 2400, 7 bits, 2 stop bits, Even parity" DB cr,lf,eot InstMess: DB "Driver Installed..." DB cr,lf,cr,lf,eot AlreMess: DB cr,lf DB "Error: Driver Already Installed..." DB cr,lf,cr,lf,Bell,eot CSEG ends end Serial7