home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PROGRAMS / UTILS / DOS_HELP / ENVCAT12.ZIP / ENV_ADRS.ASM next >
Encoding:
Assembly Source File  |  1990-11-27  |  1.6 KB  |  91 lines

  1. TITLE    env_adrs.asm
  2. NAME    env_adrs
  3.  
  4. ; $Header:   E:/mark/envircat/env_adrs.asv   1.0   27 Nov 1990 00:14:18   Mark_Gardner  $
  5.  
  6. ;* environment address
  7. ;  
  8. ;  a routine to determine the address of the environment of the master
  9. ;  COMMAND.COM invocation under DOS.  Does not work with some versions,
  10. ;  typically 4.00.
  11. ;
  12. ;  this routine was taken from an article by Scott Robert Ladd in the
  13. ;  book "MS-DOS SYSTEM PROGRAMMING", edited by Robert Ward, R&D Publications,
  14. ;  260-1 Iowa Street, Lawrence, KS 66046.  My thanks to him, since I was
  15. ;  desperate for a longer path statement, and this was the key.
  16. ;
  17. ;  I hope he will forgive me for leaving out all the comments.  Even though
  18. ;  he put the program in the public domain, R&D might get a few more orders
  19. ;  this way for a very useful book.  I received the book as a 'bonus' for
  20. ;  subscribing to TechSpecialist, which, in spite of its title, is targeted
  21. ;  at specialist programmers in MS-DOS, and is at least as useful as most
  22. ;  other of my subscriptions.
  23. ;
  24. ;>
  25.  
  26.  
  27. .MODEL    LARGE
  28.  
  29. .CODE
  30.  
  31. PUBLIC    _findmenv
  32.  
  33. _findmenv    PROC    FAR
  34.  
  35.     push    es
  36.     push    bx
  37.     push    cx
  38.  
  39.     mov    ah, 52h
  40.     int    21h
  41.  
  42.     mov    ax, word ptr es:[bx-2]
  43.     mov    es, ax
  44.     mov    bx, 3
  45.  
  46.     add    ax, word ptr es:[bx]
  47.     inc    ax
  48.     inc    ax
  49.     mov    es, ax
  50.     mov    bx, 44
  51.  
  52.     mov    ax, word ptr es:[bx]
  53.     cmp    ax, 0
  54.  
  55.     jne    fge_1
  56.  
  57.     mov    ax, es
  58.     dec    ax
  59.     mov    es, ax
  60.     mov    bx, 3
  61.     add    ax, es:[bx]
  62.     inc    ax
  63.  
  64. fge_1:
  65.  
  66.     dec    ax
  67.     mov    es, ax
  68.     mov    bx, 3
  69.  
  70.     mov    dx, es:[bx]
  71.     mov    cl, 4
  72.     shl    dx, cl
  73.     mov    cx, dx
  74.  
  75.     inc    ax
  76.     mov    dx, ax
  77.     xor    ax, ax
  78.  
  79.     pop    cx
  80.     pop    bx
  81.     pop    es
  82.  
  83.     ret
  84.  
  85. _findmenv    ENDP
  86.  
  87. ;-
  88.  
  89. END
  90.  
  91.