home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / DOSFUNC.ZIP / DOSFUN.ASM
Assembly Source File  |  1990-05-13  |  2KB  |  76 lines

  1. ;-------------------------------------------------------------------------
  2. ; DOSFUNC.ASM -- Assembly Language Routines to Convert DosWrite, DosRead,
  3. ;                     and DosExit to DOS calls.
  4. ;                PC Magazine * Charles Petzold, 7/88
  5. ;                Copyright (C) 1988, Ziff Communications Co.
  6. ;-------------------------------------------------------------------------
  7.  
  8.         DOSSEG
  9.         .MODEL    LARGE, PASCAL
  10.  
  11. ;----------------------------------------------
  12. ; DosRead (Handle, &Buffer, Count, &BytesRead)
  13. ;----------------------------------------------
  14.  
  15.         .CODE
  16.         PUBLIC    DosRead
  17.  
  18. DosRead        PROC USES BX CX DX DS,    \
  19.         Handle:WORD, Buffer:PTR BYTE, Count:WORD, BytesRead:PTR BYTE
  20.  
  21.         Lds    DX, Buffer        ; Buffer for data
  22.         Mov    CX, Count        ; Number of bytes to read
  23.         Mov    BX, Handle        ; Handle
  24.         Mov    AH, 3Fh            ; DOS function call
  25.         Int    21h
  26.  
  27.         Jc    Finish            ; If error, get out
  28.  
  29.         Lds    BX, BytesRead        ; Get bytes read pointer
  30.         Mov    [BX], AX        ; Store bytes read in there
  31.         Sub    AX, AX            ; Set AX for no error
  32. Finish:         Ret
  33.  
  34. DosRead        ENDP
  35.  
  36. ;---------------------------------------------
  37. ; DosWrite (Handle, &Buffer, Count, &Written)
  38. ;---------------------------------------------
  39.  
  40.         .CODE
  41.         PUBLIC    DosWrite
  42.  
  43. DosWrite    PROC USES BX CX DX DS,    \
  44.          Handle:WORD, Buffer:PTR BYTE, Count:WORD, Written:PTR BYTE
  45.  
  46.         Lds    DX, Buffer        ; Buffer with data
  47.         Mov    CX, Count        ; Number of bytes to write
  48.         Mov    BX, Handle        ; Handle
  49.         Mov    AH, 40h            ; DOS function call
  50.         Int    21h
  51.  
  52.         Jc    Finish            ; If error, get out
  53.  
  54.         Lds    BX, Written        ; Get bytes written pointer
  55.         Mov    [BX], AX        ; Store bytes written in there
  56.         Sub    AX, AX            ; Set AX for no error
  57. Finish:         Ret
  58.  
  59. DosWrite    ENDP
  60.  
  61. ;---------------------------------
  62. ; DosExit (TermThreads, ExitCode)
  63. ;---------------------------------
  64.  
  65.         .CODE
  66.         PUBLIC    DosExit
  67.  
  68. DosExit        PROC TermThreads:WORD, ExitCode:WORD
  69.  
  70.         Mov    AX, ExitCode        ; Get exit code from stack
  71.         Mov    AH, 4Ch            ; DOS function call
  72.         Int    21h
  73.  
  74. DosExit        ENDP
  75.         END
  76.