home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PROGRAMS / UTILS / DOS_HELP / UNDOC2E.ZIP / INT2E.ASM next >
Encoding:
Assembly Source File  |  1989-05-17  |  2.1 KB  |  60 lines

  1. ;
  2. ;  INT2E.ASM
  3. ;
  4. ;
  5. ; this routine calls the UNDOCUMENTED DOS interupt 2eh so that
  6. ; you can execute a command from within your program as it would
  7. ; behave if you typed it by hand. This means that you can actually
  8. ; set DOS environment variables using this call, and have the 
  9. ; change be permanent.
  10. ;
  11. ; To set an environment variable, you would setup a string so that
  12. ; the first byte contains the string length, and the actual string
  13. ; starts at byte 1. You must terminate the string with an 0dh.
  14. ; Then, you call int2e(char near *string). This routine only works
  15. ; in small model, but you could play around with it so that large
  16. ; model code would work.
  17. ;
  18. ; this code taken from an example in the magazine "C USERS GROUP"
  19. ; which I highly recommend for any serious C programmer.
  20. ;
  21.  
  22. .model small                    ; small model code only
  23. .data                           
  24. save_ss dw ?                    ; place to store stack info
  25. save_sp dw ?
  26.  
  27. .code                           ; start of code area
  28.  
  29. public _int_2e                  ; global to all modules
  30. _int_2e proc                    ; procedure definition
  31.         push    bp              ; setup to access argument
  32.         mov     bp,sp
  33.         push    si              ; save registers we will trash
  34.         push    di
  35.         push    ds
  36.         push    es
  37.         mov     ax,dgroup       ; setup data segment
  38.         mov     ds,ax
  39.         mov     save_sp,sp      ; save stack pointer
  40.         mov     save_ss,ss      ; and stack segment
  41.         mov     si,[bp+4]       ; move dgroup offset (string to execute)
  42.         int     2eh             ; make the undocumented DOS call
  43.         mov     ax,dgroup       ; restore data segment
  44.         mov     ds,ax
  45.         cli                     ; disable ints
  46.         mov     sp,save_sp      ; restore stack pointer
  47.         mov     ss,save_ss      ; and stack segment
  48.         sti                     ; enable ints
  49.         pop     es              ; restore registers we destroyed
  50.         pop     ds
  51.         pop     di
  52.         pop     si
  53.         pop     bp
  54.         ret                     ; all done
  55.  
  56. _int_2e endp
  57.  
  58. end
  59.  
  60.