51b .MODEL TINY .386 .CODE ORG 100h start: jmp main COMM_INIT EQU 0 COMM_EXIT EQU 1 COMM_SEND EQU 2 COMM_RCV EQU 3 rs232 STRUCT portadr dw ? irq dw ? baudrate dw ? parity dw ? wordlen dw ? stopbits dw ? rs232 ENDS rs rs232 <> no_comm db 'No RS-232 driver found!', 13, 10, '$' main: push cs pop ds mov ax, 0 mov es, ax mov dx, es:[180h] shl edx, 16 mov dx, es:[182h] cmp edx, 0 jnz comm_installed_ok mov ah, 9 mov dx, offset no_comm int 21h jmp err_exit comm_installed_ok: mov ah, COMM_INIT ;Initialize comm port mov rs.portadr, 02f8h mov rs.irq, 3 mov rs.baudrate, 9600 mov rs.parity, 0 mov rs.wordlen, 8 mov rs.stopbits, 1 push cs pop es mov di, offset rs int 60h comm_lp: mov ah, COMM_RCV ;Check if byte available from comm int 60h ;port cmp ax, 0 ;No, check if key pressed jz chk_key mov ah, 2 ;Yes, write byte to screen mov dl, al int 21h chk_key: mov ah, 1 int 16h jz comm_lp mov ah, 0 int 16h cmp al, 27 jz rdy mov ah, COMM_SEND ;Send byte to comm port mov dx, ax wait_cts: int 60h cmp ax, 0 jnz comm_lp mov ax, dx jmp wait_cts rdy: mov ah, 1 int 60h err_exit: mov ax, 4c00h int 21h END start . 0