home *** CD-ROM | disk | FTP | other *** search
/ Microsoft Programmer's Library 1.3 / Microsoft-Programers-Library-v1.3.iso / sampcode / dos_ency / section5 / fxn5bh.asm < prev    next >
Encoding:
Assembly Source File  |  1988-08-11  |  1.5 KB  |  32 lines

  1.         ;************************************************************;
  2.         ;                                                            ;
  3.         ;          Function 5BH: Create New File                     ;
  4.         ;                                                            ;
  5.         ;          int create_new(ppathname,attr)                    ;
  6.         ;              char *ppathname;                              ;
  7.         ;              int attr;                                     ;
  8.         ;                                                            ;
  9.         ;          Returns -2 if file already exists,                ;
  10.         ;                  -1 for all other errors,                  ;
  11.         ;                  otherwise returns file handle.            ;
  12.         ;                                                            ;
  13.         ;************************************************************;
  14.  
  15. cProc   create_new,PUBLIC,ds
  16. parmDP  ppathname
  17. parmW   attr
  18. cBegin
  19.         loadDP  ds,dx,ppathname ; Get pointer to pathname.
  20.         mov     cx,attr         ; Get new file's attribute.
  21.         mov     ah,5bh          ; Set function code.
  22.         int     21h             ; Ask MS-DOS to make a new file.
  23.         jnb     cn_ok           ; Branch if MS-DOS returned handle.
  24.         mov     bx,-2
  25.         cmp     al,80           ; Did file already exist?
  26.         jz      ae_err          ; Branch if so.
  27.         inc     bx              ; Change -2 to -1.
  28. ae_err:
  29.         mov     ax,bx           ; Return error code.
  30. cn_ok:
  31. cEnd
  32.