home *** CD-ROM | disk | FTP | other *** search
/ The Unsorted BBS Collection / thegreatunsorted.tar / thegreatunsorted / programming / misc_programming / io386.asm < prev    next >
Assembly Source File  |  1992-11-23  |  1KB  |  62 lines

  1. ; io386.asm
  2. ;
  3. ; This module contains 4 C callable procedures that allow access to the
  4. ; hardware ports. They must be defined in the calling program as follows:
  5. ;
  6. ;    extern _Far16 _Pascal OUTP8(USHORT, UCHAR);
  7. ;    extern _Far16 _Pascal OUTP16(USHORT, USHORT);
  8. ;    extern UCHAR _Far16 _Pascal INP8(USHORT);
  9. ;    extern USHORT _Far16 _Pascal INP16(USHORT);
  10. ;
  11. ; This module will compile under MASM or TASM.
  12. ;
  13.  
  14. R2SEG SEGMENT BYTE PUBLIC USE16 'CODE'
  15.       ASSUME  CS:R2SEG, DS:NOTHING
  16.  
  17. PUBLIC OUTP8
  18. OUTP8  PROC  FAR
  19.   push  bp
  20.   mov   bp, sp
  21.   mov   dx, [bp+8]
  22.   mov   al, [bp+6]
  23.   out   dx, al
  24.   pop   bp
  25.   ret   4
  26. OUTP8  ENDP
  27.  
  28. PUBLIC OUTP16
  29. OUTP16 PROC  FAR
  30.   push  bp
  31.   mov   bp, sp
  32.   mov   dx, [bp+8]
  33.   mov   ax, [bp+6]
  34.   out   dx, ax
  35.   pop   bp
  36.   ret   4
  37. OUTP16 ENDP
  38.  
  39. PUBLIC INP8
  40. INP8   PROC  FAR
  41.   push  bp
  42.   mov   bp, sp
  43.   mov   dx, [bp+6]
  44.   in    al, dx
  45.   sub   ah, ah
  46.   pop   bp
  47.   ret   2
  48. INP8 ENDP
  49.  
  50. PUBLIC INP16
  51. INP16  PROC  FAR
  52.   push  bp
  53.   mov   bp, sp
  54.   mov   dx, [bp+6]
  55.   in    ax, dx
  56.   pop   bp
  57.   ret   2
  58. INP16 ENDP
  59.  
  60. R2SEG   ENDS
  61.    END
  62.