home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / unix / pcclone / 32bit / 1033 / llstuff.asm < prev    next >
Encoding:
Assembly Source File  |  1993-01-12  |  2.3 KB  |  131 lines

  1. ;
  2. ;   "Copyright 1993 John Hood. All rights reserved.";
  3. ;
  4.  
  5.  
  6. ;   This driver is free software; you can redistribute it and/or
  7. ;   modify it under the terms of the GNU General Public License as
  8. ;   published by the Free Software Foundation; either version 1, or
  9. ;   (at your option) any later version.
  10. ;
  11. ;   As a special case, this driver may be incorporated in any OS kernel,
  12. ;   whether the GNU General Public License applies to it or not.
  13. ;
  14. ;   This driver is distributed in the hope that it will be useful,
  15. ;   but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. ;   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  17. ;   GNU General Public License for more details.
  18. ;
  19. ;   You may have received a copy of the GNU General Public License
  20. ;   along with this driver; if not, write to the Free Software
  21. ;   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  22.  
  23.  
  24. ; Assembler code for Xenix/386
  25. ; This is hand-optimized C compiler code.  Don't expect it to be
  26. ; pretty, or commented, or anything like that.  It might get
  27. ; replaced at a sneeze.
  28.  
  29.     TITLE    llstuff
  30.  
  31.     .386
  32.  
  33. ifdef    ASM
  34.  
  35. DGROUP    GROUP    CONST, _BSS, _DATA
  36. PUBLIC  _llstuff
  37. CONST    SEGMENT  DWORD USE32 PUBLIC 'CONST'
  38. CONST      ENDS
  39. _DATA    SEGMENT  DWORD USE32 PUBLIC 'DATA'
  40. _DATA      ENDS
  41. _BSS    SEGMENT  DWORD USE32 PUBLIC 'BSS'
  42. _BSS      ENDS
  43. _TEXT    SEGMENT  DWORD USE32 PUBLIC 'CODE'
  44.     ASSUME   CS: _TEXT, DS: DGROUP, SS: DGROUP, ES: DGROUP
  45. EXTRN    _spl7:NEAR
  46. EXTRN    _outb:NEAR
  47. EXTRN    _inb:NEAR
  48. EXTRN    _splx:NEAR
  49.  
  50. _llstuff    PROC NEAR
  51.     push     ebp
  52.     mov      ebp, esp
  53.     sub      esp, 8
  54.     push     edi
  55.     push     esi
  56.  
  57. ; reg esi = buf
  58.     mov    esi, dword ptr [ebp+12]
  59. ; reg edi = endbuf
  60.     mov    edi, dword ptr [ebp+16]
  61. ; reg ebx = portbase
  62.     mov    edx, dword ptr [ebp+8]
  63. ;    spincount = 20
  64. ; reg ecx = inspincount
  65. ; loaded when needed in $wait
  66.  
  67.  
  68.     cmp      esi, edi
  69.     jae      SHORT $exit
  70.  
  71.     inc    edx
  72.  
  73.     align    4
  74. $top:
  75.     in    al,edx
  76.     test     al, 128
  77.     je      SHORT $wait
  78. $ready:
  79.     dec    edx
  80.     lodsb
  81.     out    edx,al
  82.  
  83.     out    132,al
  84.  
  85.     pushfd
  86.  
  87.     mov    al,13
  88.     lea    edx, dword ptr [edx+2]
  89.  
  90.     cli
  91.  
  92.     out    edx,al
  93.  
  94.     out    132,al
  95.  
  96.     mov    al,12
  97.     out    edx,al
  98.  
  99.     popfd
  100.     dec    edx
  101.  
  102.     cmp      esi, edi
  103.     jb      SHORT $top
  104.  
  105. $exit:
  106.     mov      eax, esi
  107.     pop      esi
  108.     pop      edi
  109.     leave    
  110.     ret      
  111.  
  112.  
  113. $wait:
  114.     mov      ecx, DWORD PTR [ebp+20]
  115. $waitloop:
  116.     in    al,edx
  117.     test     al, 128
  118.     jne    SHORT $ready
  119.     dec      ecx
  120.     jne      SHORT $waitloop
  121.     jmp    short $exit
  122.  
  123. _llstuff    ENDP
  124.  
  125. _TEXT    ENDS
  126.  
  127. endif    ; ASM
  128.  
  129.  
  130. END
  131.