home *** CD-ROM | disk | FTP | other *** search
/ Microsoft Programmer's Library 1.3 / Microsoft-Programers-Library-v1.3.iso / sampcode / msj / msjv4_4 / overlays / support.asm < prev   
Encoding:
Assembly Source File  |  1989-01-30  |  2.5 KB  |  73 lines

  1.                 .model  LARGE,C
  2.                 .code
  3.  
  4.                 public  errputs
  5. errputs         proc    far C uses ax bx cx di ds es, string:ptr
  6.                 les     di,string               ;es:di -> string
  7.                 push    di                      ;save original offset
  8.                 mov     al,0                    ;terminator byte
  9.                 mov     cx,0100h                ;length to examine for null
  10.                 repne   scasb                   ;look for it
  11.                 pop     ax                      ;ax = orig pointer
  12.                 sub     di,ax
  13.                 dec     di                      ;di = length
  14.                 mov     cx,di
  15.                 mov     bx,2                    ;stderr
  16.                 mov     dx,ax                   ;buffer address
  17.                 mov     ah,40h                  ;write to file
  18.                 int     21h
  19.                 ret
  20. errputs         endp
  21.  
  22.  
  23. mylseek         proc    far C uses bx cx, handle:WORD, ofs:DWORD, whence:WORD
  24.                 public  mylseek
  25.                 mov     ax,whence
  26.                 mov     ah,42h
  27.                 mov     bx,handle
  28.                 push    es
  29.                 les     dx,ofs
  30.                 mov     cx,es
  31.                 pop     es
  32.                 int     21h                     ;result left in dx:ax, nicely
  33.                 jnc     lseekdone
  34.                 mov     ax,-1
  35. lseekdone:      ret
  36. mylseek         endp
  37.  
  38.  
  39. myread          proc    far C uses bx ds dx, handle:WORD, buf:PTR, len:WORD
  40.                 public  myread
  41.                 mov     ah,3fH
  42.                 mov     bx,handle
  43.                 mov     cx,len
  44.                 lds     dx,buf
  45.                 int     21h                     ;result nicely in ax for return
  46.                 jnc     readdone
  47.                 mov     ax,-1
  48. readdone:       ret
  49. myread          endp
  50.  
  51. myopen          proc    far C uses ds dx, fname:PTR, mode:WORD
  52.                 public  myopen
  53.                 mov     ax,mode
  54.                 mov     ah,3dH
  55.                 lds     dx,fname
  56.                 int     21h                     ;result nicely in ax for return
  57.                 jnc     opendone
  58.                 mov     ax,-1
  59. opendone:       ret
  60. myopen          endp
  61.  
  62. myclose         proc    far C uses bx, handle:WORD
  63.                 public  myclose
  64.                 mov     ah,3eH
  65.                 mov     bx,handle
  66.                 int     21h                     ;result nicely in ax for return
  67.                 ret
  68. myclose         endp
  69.  
  70.  
  71.                 end
  72.  
  73.