home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / cdisk.zip / IOPL / IOSEG.ASM next >
Assembly Source File  |  1992-12-29  |  1KB  |  48 lines

  1. ;
  2. ; Sample IOPL segment 
  3. ;
  4.         PUBLIC        IN_PORT
  5.         PUBLIC        OUT_PORT
  6.  
  7.         .model large
  8.         .286P
  9.  
  10. _IOSEG  segment    word public USE16 'CODE'
  11.  
  12.     assume      CS: _IOSEG, DS: DGROUP, SS: DGROUP
  13.     .286P
  14. ;
  15. IN_PORT  proc       far
  16. ;
  17.         push    bp         ;set up stack frame
  18.         mov     bp,sp      ;save bp
  19.         push    dx         ;save dx
  20.     mov     dx,[bp+6]  ;get port address
  21.         in      ax,dx      ;do input
  22.         pop     dx         ;restore regs
  23.         pop     bp         ;return in ax
  24.         ret     2          ;remove from IOPL stack
  25. ;
  26. IN_PORT  endp
  27.  
  28. OUT_PORT proc       far
  29. ;
  30.         push    bp         ;set up stack frame
  31.         mov     bp,sp      ;save it
  32.         push    ax         ;save ax
  33.         push    dx         ;and dx
  34.     mov     ax,[bp+6]  ;get data
  35.         mov     dx,[bp+8]  ;get port
  36.         out     dx,al      ;do output
  37.         pop     dx         ;restore regs
  38.         pop     ax
  39.         pop     bp
  40.     ret     4          ;remove off local stack
  41. ;
  42. OUT_PORT endp
  43.  
  44. _IOSEG  ends
  45.       end 
  46.  
  47.  
  48.