home *** CD-ROM | disk | FTP | other *** search
/ ftp.shrubbery.net / 2015-02-07.ftp.shrubbery.net.tar / ftp.shrubbery.net / pub / pc / unix / unx.arc / SETRAW.ASM < prev    next >
Assembly Source File  |  1986-01-17  |  1KB  |  62 lines

  1.  
  2.     public  getraw, setraw
  3.  
  4. ;----- dos ----------------------
  5. ; Call DOS function # n.
  6. dos     macro   fn
  7.     mov     ah, fn
  8.     int     21h
  9.     endm
  10.  
  11.  
  12. code    segment para public 'CODE'
  13. assume cs:code
  14.  
  15. ;----- Getraw ---------------------------------------------
  16. ; Returns AX=1 if file BX is a device in raw mode; 0 otherwise.
  17. ; Returns Carry set & errorcode in AX if DOS error.
  18.  
  19. getraw  proc    near
  20.     mov     al, 0
  21.     DOS     44h             ; Get attributes
  22.     jc      gr_exit         ; bad file handle?
  23.     mov     ax, 20h
  24.     and     al, dl          ; get that bit
  25.     mov     cl, 4
  26.     shr     ax, cl
  27.     clc
  28. gr_exit:
  29.     ret
  30.  
  31.  
  32. getraw  endp
  33.  
  34. ;----- Setraw -------------------------------------------
  35. ; Sets Raw state of file BX to (AX != 0) if file is a device.
  36. ; Returns Carry set & errorcode in AX if DOS error.
  37.  
  38. setraw  proc    near
  39.     mov     cx, ax
  40.     mov     al, 0
  41.     DOS     44h
  42.     jc      sr_exit
  43.     test    al, 80h         ; It it a device?
  44.     jz      sr_exit         ; nope- do nothing.
  45.     ; Current mode in DX; set CX = 20H if CX nonzero.
  46.     or      cx, cx
  47.     jz      sr_ax0
  48.         mov     cx, 20h
  49. sr_ax0: and     dx, 00cfh       ; clear old raw bit and hi byte,
  50.     or      dx, cx          ; set new value.
  51.     mov     al, 1
  52.     DOS     44h
  53. sr_exit:
  54.     ret
  55. setraw  endp
  56.  
  57.  
  58. code    ends
  59.  
  60.     end
  61.  
  62.