.model tiny .code org 100h start: jmp go env1 db 'Process environment',10,13,'$' env2 db 'Parent environment',10,13,'$' exec db 'Executable name: ','$' cmlp db 'Command line:' lf db 10,13,'$' buf db 512 DUP (?) ;___________________________________________________________________ ; ; Display something using dos function 9 ; lfdisp: mov dx,offset lf display: push ds push cs pop ds mov ah,9 int 21h pop ds ret ;___________________________________________________________________ ; ; Move a string from the environment to our local buf ; movestring: sub cx,cx mov di,offset buf mov dx,di msl: lodsb or al,al jz msend cmp cx,511 jnc msl stosb inc cx jmp msl msend: mov al, '$' stosb ret ;___________________________________________________________________ ; ; Dump the environment ; ; dumpenv: call display push cs pop es mov si,0 delp: call movestring call display call lfdisp test byte ptr [si],0ffh jnz delp inc si inc si inc si call lfdisp call lfdisp ; ; At this point we dump the file name ; mov dx,offset exec call display call movestring call display call lfdisp call lfdisp ret ;___________________________________________________________________ ; ; Main program ; go: sub bh,bh mov bl,ds:[80h] mov byte ptr [81h+bx],'$' mov dx,offset cmlp call display mov dx,81h call display call lfdisp call lfdisp mov dx,offset env1 mov ds,cs:[2ch] call dumpenv mov dx,offset env2 mov ds,cs:[16h] mov ds,ds:[2ch] call dumpenv mov ax,4c00h int 21h end start