; +-----------------------------------------------------------------+
; | This file is generated by Interactive DisAssembler (IDA)        |
; | Copyright (c) 1991-94 by Ilfak Guilfanov. (2:5020/209@fidonet)  |
; +-----------------------------------------------------------------+

; ENVSIZE.COM, PC MAGAZINE, VOL13N13, Returns size of environment

.8086

seg000          segment byte public 'CODE'
                assume cs:seg000
                org    100h

                assume es:seg000, ss:nothing, ds:seg000

start:
                jmp        loc_0_120         ; Jump

loc_0_102:
                xor        dx, dx            ; Logical Exclusive OR
                div        cx                ; Unsigned Divide
                push       dx
                cmp        ax, 0             ; Compare Two Operands
                jz         loc_0_10F         ; Jump if Zero (ZF=1)
                call       loc_0_102         ; Call Procedure

loc_0_10F:
                pop        dx
                add        dl, 30h           ; Add
                cmp        dl, 39h           ; Compare Two Operands
                jle        loc_0_11B    
                add        dl, 7             ; Add

loc_0_11B:
                mov        ah, 2
                int        21h                ; DOS - DISPLAY OUTPUT
                                ; DL = character to send to standard output
                ret                           ; Return Near from Procedure
loc_0_120:
                mov        dx, OFFSET STRING
                mov        ah, 9
                int        21h                ; DOS -        PRINT STRING
                                       ; DS:DX -> string terminated by "$"
                jmp        loc_0_12B        ; Jump

loc_0_129:
                mov        ds, ax

loc_0_12B:
                mov        bx, ds
                mov        ax, ds:16h
                cmp        ax, bx             ; Compare Two Operands
                jnz        loc_0_129          ; Jump if Not Zero (ZF=0)
                mov        ax, ds:2Ch
                dec        ax                 ; Decrement by 1
                mov        ds, ax
                mov        ax, ds:3
                push       ax
                mov        cl, 4
                shl        ax, cl             ; Shift Logical Left
                mov        cx, 0Ah
                call       loc_0_102          ; Call Procedure
                pop        ax
                or         ah, ah             ; Logical Inclusive OR
                jz         loc_0_14F          ; Jump if Zero (ZF=1)
                mov        al, 0FFh

loc_0_14F:
                mov        ah, 4Ch
                int        21h         ; DOS - 2+ - QUIT WITH EXIT CODE (EXIT)
                                              ; AL = exit code
STRING          db 'SET Env=$'

seg000          ends

                end       start

