.MODEL TINY .DATA ;values for COM2 with IRQ3 base equ 2f8h ;COM1 3f8h, COM2 2f8h, COM3 3e8h, COM4 2e8h mski equ 0f7h ;COM1 0efh, COM2 0f7h, COM3 0efh, COM4 0f7h divf equ 12 ;115200/my_speed = divf intt equ 44 ;COM1, COM3 (irq4) 48, COM2, COM4 (irq3) 44 bpos dw 257 + offset bpos ;buffer pointer .CODE ORG 100h sta: xor ax,ax mov es,ax mov ax,cs mov bx,offset srv ;irq service pointer call exv ;set and retrieve vector push ax push bx mov dx,base+3 mov ax,0b80h ;enable divider write out dx,ax ;set OUT2, RTS, DTR mov dl,low(base+0) mov ax,divf ;divider value out dx,ax mov dl,low(base+3) mov al,03h ;8xData, 1xStop, Parity none out dx,al mov dl,low(base+1) mov al,1 out dx,al ;irq after receiving dec dl in al,dx ;freeing buffer in al,21h push ax ;push old mask and al,mski out 21h,al ;unmask interrupt mov bx,257 + offset bpos ;initial buffer position wat: cmp bl,byte ptr[offset bpos] jz nrc mov dl,byte ptr[bx] ;release char from buffer mov ah,02h int 21h inc bl nrc: mov ah,06h ;check for keybhit mov dl,0ffh int 21h jz wat mov dl,low(base+0) out dx,al cmp al,27 jnz wat pop ax ;restore mask out 21h,al pop bx pop ax exv: mov di,intt xchg bx, es:[di] xchg ax, es:2[di] ret srv: push ax push dx push bx mov dx,base+0 in al,dx mov bx,word ptr cs:[offset bpos] mov byte ptr cs:[bx],al inc byte ptr cs:[offset bpos] mov al,20h out 20h,al pop bx pop dx pop ax iret end sta