;***************************************************************************
; EG3.ASM
;               This program will display all the environment varaibles
;
;***************************************************************************

.386
.model flat
.stack 200h
.code


TheStart:                               ; Program starts execution here


        mov     ax,0EE02h               ; Get DOS32 address info
        int     31h                     ; EDI -> Environment segment

        mov     bh,0


;
;  Display the environment.
;

Plot_char_loop:
        mov     al,[edi]              ; read char from environment
        inc     edi
        cmp     al, 0
        jz string_ended               ; If char zero the string has ended.

          mov    ah,0eh                 ; Set AH to video service func
          int    10h                    ; Plot the character.
          jmp Plot_char_loop            ; and continue loop.

      string_ended:

                cmp     byte ptr gs:[edi+1],0  ; If the next char is zero then
                jz     Envir_Ended             ; evnironmet has ended.
                mov     al,10                  ; Else only string has ended
                int     10h                    ; and do a carrage return.
                mov     al,13
                int     10h
                jmp Plot_char_loop

Envir_Ended:


    mov  ax,4c00h                         ; stop the program
    int  21h


END TheStart
