TIP: Click on subject to list as thread! ANSI
echo: 80xxx
to: GERALD KASZUBA
from: JAMES VAHN
date: 1997-09-16 18:06:00
subject: Re: Com Port Handling

> I would like to know how to read quickly from a com port. The reason I
> ask this is because the ah,2 INT 14h routine takes around one second
> per character. 
Something I was playing with a while back.  It diverts data going
through the comport to a monochrome monitor on a dual screen setup.
A wee bit of a bug- once the status port is read, it's cleared. So
there is no way to tell if the data is fresh. The output of this
program therefor tends to stutter... 
TASM 2.5
;------------------------------------------------------------------
; COM-mon.asm - TSR to display modem data to video screen.
;               Supports dual screen operation.
;               James Vahn (root@short.circuit.com)  (1:346/15.1)
COM     equ 2           ;COM2 equ 2, COM1 equ 1
Screen  equ 0B000h      ;Monochrome B000h, VGA B800h
                        
if COM eq 2
        Port    equ 2F8h           ;COM2
        ISRo    equ 2Ch
        ISRs    equ 2Eh
else
        Port    equ 3F8h           ;COM1
        ISRo    equ 30h
        ISRs    equ 32h
endif
Hook    EQU     1Ch                ;Hook vector 1Ch.
.286                               ;Uses 286 codes, PUSHA & POPA
cseg segment
assume cs:cseg
org 100h                           ;COM format.
Begin:
        jmp     Init               ;Jump over the ISR code
                                   ; to the intitialization code.
Old_Int         dd      ?          ;Storage- points to the old ISR.
loc             dw      ?          ;Points to screen position.
New_ISR:
        pusha                      ;Save the registers
        push    ds
        push    es
        push    cs                 ;DS=CS
        pop     ds
        xor     ax,ax
        mov     es,ax
        mov     ax,cs              ;Compare IRQ vector in memory
        cmp     ax,es:[ISRs]       ; to see if already installed.
        je      Exit
        mov     ax,es:[ISRo]       ;Install hook.
        mov     OldIRQo,ax
        mov     ax,es:[ISRs]
        mov     OldIRQs,ax
        mov     ax,offset NewIRQ
        mov     es:[ISRo],ax
        push    cs
        pop     ax                 ;AX=CS  
        mov     es:[ISRs],ax
        cld
        mov     ax,Screen
        mov     es,ax
        mov     di,0
        mov     cx,2000            ;Clear the screen.
        mov     ax,0720h
        rep     stosw
        mov     loc,0
Exit:
        pop     es
        pop     ds
        popa                       ;End of ISR- exit
        jmp     cs:[Old_Int]       ; to old vector.
NewIRQ:
        pusha                      ;Save the registers.
        push    ds
        push    es
        push    cs                 ;DS=CS
        pop     ds
        pushf                      ;Dummy for IRET.
FarCall db      9Ah                ;Hard coded Far CALL.
OldIRQo dw      ?
OldIRQs dw      ?
        mov     ax,Screen          ;Screen memory address.
        mov     es,ax
        mov     dx,Port
        in      al,dx              ;Read the port, a bad assumption
        mov     bx,loc             ; that the data is valid.
        mov     es:[bx],al         ;Write to video screen.
        add     loc,2
        cmp     loc,4000           ;At end of screen memory?
        jl      EndIRQ             ;Nope.
        mov     loc,0              ;Yes, reset.
 EndIRQ:
        mov     al,20h
        out     20h,al
        pop     es
        pop     ds
        popa                       ;End of ISR- exit
        iret
;**********************************************
Init:
        mov     dx,offset Msg      ;Prints the hello message.
        mov     ah,09h
        int     21h
        mov     bx,02Ch            ;Release the environment memory.
        mov     es,[bx]
        mov     ah,49h
        int     21h
        mov     ah,35h             ;Get old vector and store it.
        mov     al,Hook
        int     21h
        mov     word ptr [Old_Int],bx
        mov     word ptr [Old_Int+2],es
        mov     al,Hook            ;Change the target vector.
        mov     dx,offset New_ISR
        mov     ah,25h
        int     21h
        mov     dx,offset Init     ;Allocate TSR memory
        int     27h                ; and exit to DOS.
Msg  db 13,10
     db 'Comport is now hooked. All com port data will'
     db ' be echoed to the screen',13,10
     db 'Reboot to remove this TSR. Sorry!',13,10
     db 13,10,36
cseg ends
end Begin
--- ifmail-tx (i386 Linux)
---------------
* Origin: jvahn@short.circuit.com (1:346/15.1@fidonet)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.