data  segment  'data'
com   dw 0
data  ends
code  segment word public 'code'
dgroup group data
       assume cs:code,ds:dgroup,ss:dgroup
      public int232,sndchr,recchr
; sets port to ibaud baud,no parity,1 stop bit,8 data bits
; call int232(ibaud,com,status)
int232  proc far
      push bp
      mov bp,sp
      mov es,[bp+16]
      mov bx,[bp+10]
      mov dx,es:[bx]
      dec dx
      mov com,dx
      mov ah,0
      mov bx,[bp+14]
      mov al,es:[bx]
      int 14h
      mov bx,[bp+6]
      mov es:[bx],ax
      mov sp,bp
      pop bp
      ret 12
int232 endp
; sends a string of characters of num length to port
; call sndchr(string,num,status)
sndchr  proc far
      push bp 
      mov  bp,sp
      push di
      push si
      mov  dx,com
      mov  es,[bp+16]
      mov  di,[bp+10]
      mov  cx,es:[di]
      mov  di,[bp+14]
sd:   mov  ah,1
      mov  al,es:[di]
      int  14h
      inc  di
      loop sd
stop: mov  bx,[bp+6]
      mov  es:[bx],ax
      pop  si
      pop  di
      mov  sp,bp
      pop  bp          
      ret  12         
sndchr  endp
; receives a string of characters of num length to port
; call recchr(string,num,status)
recchr  proc far
      push bp 
      mov  bp,sp
      push di
      push si
      mov  dx,com
      mov  es,[bp+16]
      mov  di,[bp+10]
      mov  cx,es:[di]
      mov  di,[bp+14]
rc:   mov  ah,2
      int  14h
      mov  es:[di],al
      cmp  al,0dh
      je   sto
      inc  di
      loop rc
sto:  mov  bx,[bp+6]
      mov  es:[bx],ax
      pop  si
      pop  di
      mov  sp,bp
      pop  bp          
      ret  12         
recchr  endp
code  ends
      end
