home *** CD-ROM | disk | FTP | other *** search
/ Piper's Pit BBS/FTP: ibm 0020 - 0029 / ibm0020-0029 / ibm0028.tar / ibm0028 / GRLF-C-1.ZIP / GCOMM / _ASIINIT.ASM < prev    next >
Encoding:
Assembly Source File  |  1990-08-14  |  2.3 KB  |  68 lines

  1.         page    60,132
  2. ;
  3. ; The Greenleaf Comm Library
  4. ;
  5. ; Copyright (C) 1984-90 Greenleaf Software Inc.  All Rights Reserved.
  6. ;
  7.  
  8.         include model.h
  9.         include prologue.h
  10.         include asiports.equ
  11.  
  12.         pseg    _asiinit
  13.  
  14. ;==>--  int _asiinit(ioaddress,divisor,pa_st_wl)
  15. ;       unsigned ioaddress,             /* I/O base address of 8250 */
  16. ;                divisor,               /*Divisor to load up, sets baud rate*/
  17. ;                pa_st_wl;              /* Parity, Stopbits & word length */
  18. ;
  19.         cproc   _asiinit,,,,,<NOSI,NODI>
  20.         mov     cx,parm1_       ;cx=8250 base address
  21.         mov     dx,INTER
  22.         add     dx,cx           ;shut down 8250 interrupts
  23.         in      al,dx           ;read how interrupts are set
  24.         KILL_TIME
  25.         push    ax              ;save 'em away
  26.         xor     al,al           ;disable 8250 interrupts
  27.         out     dx,al           ;
  28.         KILL_TIME
  29.         mov     dx,LSREG        ;now wait for current character to be
  30.         add     dx,cx           ;be shifted out (if there is one)
  31. _wtmty: in      al,dx
  32.         KILL_TIME
  33.         test    al,THRE
  34.         jz      _wtmty
  35.         mov     bx,parm2_       ;bx=divisor
  36.         mov     al,DLAB         ;set dlab for baud rate
  37.         mov     dx,LCREG
  38.         add     dx,cx           ;dx=line control register for port
  39.         out     dx,al           ;assert Divisor Latch Access Bit (DLAB)
  40.         KILL_TIME
  41.         mov     dx,cx           ;dx=base 8250
  42.         mov     al,bl           ;least significant divisor byte to al
  43.         out     dx,al
  44.         KILL_TIME
  45.         inc     dx              ;dx=base 8250 + 1
  46.         mov     al,bh           ;most significant divisor byte to al
  47.         out     dx,al
  48.         KILL_TIME
  49.         mov     al,parm3_       ;get parity,stop etc.
  50.         and     al,not DLAB     ;make dlab=0
  51.         mov     dx,LCREG
  52.         add     dx,cx           ;dx=line control register port
  53.         out     dx,al
  54.         KILL_TIME
  55.         pop     ax              ;get interrupt setting back
  56.         mov     dx,INTER
  57.         add     dx,cx
  58.         cli
  59.         out     dx,al           ;do it twice (per National)
  60.         KILL_TIME
  61.         out     dx,al
  62.         KILL_TIME
  63.         sti
  64.         xor     ax,ax           ;return 0 (ASSUCCESS)
  65.         cproce
  66.         endps
  67.         end
  68.