home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / lan / driver6s / getenv.asm < prev    next >
Assembly Source File  |  1990-02-13  |  756b  |  38 lines

  1. phd_enviorn    equ    2ch
  2.  
  3. getenv:
  4. ;enter with si->environ string to search for.
  5. ;exit with cy if not found, or nc, es:di->value if found.
  6.     mov    es,cs:[phd_enviorn]    ;get our enviornment segment.
  7.     xor    di,di
  8. getenv_1:
  9.     push    si
  10.     push    di
  11. getenv_2:
  12.     lodsb                ;get a character.
  13.     or    al,al            ;end of string?
  14.     je    getenv_3        ;yes.
  15.     scasb                ;did it match?
  16.     je    getenv_2        ;yes.
  17. getenv_3:
  18.     je    getenv_4
  19.  
  20.     pop    di
  21.     pop    si
  22.  
  23.     xor    al,al            ;skip to the next string.
  24.     mov    cx,100h            ;no string can be longer than 256 bytes.
  25.     repnz    scasb
  26.     jne    getenv_5        ;go if environment is trashed.
  27.  
  28.     cmp    byte ptr es:[di],0    ;is this the last one?
  29.     jnz    getenv_1    ;no - try again.
  30. getenv_5:
  31.     stc
  32.     ret
  33.  
  34. getenv_4:
  35.     add    sp,4            ;pop the old stuff off the stack.
  36.     clc
  37.     ret
  38.