home *** CD-ROM | disk | FTP | other *** search
/ BURKS 2 / BURKS_AUG97.ISO / BURKS / SOFTWARE / LIBS / PMC101.ZIP / LIBSRC.ZIP / GETENV.ASM (.txt) < prev    next >
Assembly Source File  |  1994-06-29  |  1KB  |  86 lines

  1. .386p
  2. locals
  3.  
  4. _DATA           segment dword public use32 'DATA'
  5. _DATA           ends
  6. _BSS            segment dword public use32 'BSS'
  7. _BSS            ends
  8.  
  9. DGROUP          group   _DATA, _BSS
  10. assume  cs:_TEXT, ds:DGROUP
  11.  
  12. extrn   __lowbufptr:dword
  13. extrn   _envsel:word
  14.  
  15. public  GETENV
  16.  
  17. _TEXT           segment byte public use32 'CODE'
  18. assume  cs:_TEXT, ds:DGROUP
  19.  
  20. GETENV:
  21.         push esi edi
  22.         cld
  23.  
  24.         mov edi,[esp+4+8+00h]
  25.         or ecx,-1
  26.         xor al,al
  27.         repne scasb
  28.         not ecx
  29.         lea edx,[ecx-1]
  30.         
  31.         mov es,_envsel
  32.         xor edi,edi
  33.  
  34. @@00l:
  35.         mov esi,[esp+4+8+00h]
  36.         mov ecx,edx
  37.         repe cmpsb
  38.         jne short @@00l00
  39.  
  40.         mov al,'='
  41.         scasb
  42.         jne short @@00l00
  43.  
  44.         mov esi,edi
  45.         or ecx,-1
  46.         xor al,al
  47.         repne scasb
  48.         not ecx
  49.  
  50.         mov edi,__lowbufptr
  51.         mov ax,es
  52.         mov dx,ds
  53.         mov ds,ax
  54.         mov es,dx
  55.         mov eax,edi
  56.  
  57.         mov dl,cl
  58.         shr ecx,2
  59.         rep movsd
  60.         mov cl,dl
  61.         and cl,3
  62.         rep movsb
  63.  
  64.         mov cx,es
  65.         mov ds,cx
  66.         jmp short @@00
  67.  
  68. @@00l00:
  69.         or ecx,-1
  70.         xor al,al
  71.         repne scasb
  72.         cmp es:[edi],al
  73.         jne @@00l
  74.  
  75.         mov ax,ds
  76.         mov es,ax
  77.         xor eax,eax
  78.  
  79. @@00:
  80.         pop edi esi
  81.         ret 04h
  82.  
  83. _TEXT           ends
  84. end
  85.  
  86.