Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Return segment address of the environment and it's size

ligangligang Posts: 76Member
/*************************************************************************/* Return segment address of the environment and it's size */
/*****************************************************************************/
static
int MemENV (unsigned int *seg, unsigned int *esize)
{
unsigned int envseg;
unsigned int envsegsize;

/* Get ENV SegAddress */
/* This needs to be in ASM to insure working in all environments */
*/
/* It does this by getting the "Master Environment" from Command.com */

_asm
{
push es ; Save Regs
push si ; Save Regs
push di ; Save Regs

; push ds ; Save Regs
; mov ax, 5100h ; Parm to request the cur PSP address
; INT 21h ; DOS Function to get PSP Seg address
; pop ds ; Restore Regs
; mov es, bx ; Point to it
; mov ax, es:[2ch] ; Get ENV seg addr
; mov ourenv, ax ; Save it

push ds ; Save Regs
mov ax, 352Eh ; Parm to request the 2E int
INT 21h ; DOS Function to get PSP Seg address
pop ds ; Restore Regs
mov ax, es:[2ch] ; Get ENV seg addr
mov envseg, ax ; Save ENV Segment addr

dec ax ; Point to MCB (prev paragraph)
mov es, ax ; Put in es
mov ax, es:[03h] ; Get size in paragraphs
mov envsegsize, ax ; Save ENV Segment size

pop di ; Restore Regs
pop si ; Restore Regs
pop es ; Restore Regs
}

*seg = envseg; /* Return Seg value */
*esize = envsegsize; /* Return Seg size */

return (0); /* Return */
}

If Anyone can reveal any details for this function ?


Comments

  • AsmGuru62AsmGuru62 Posts: 6,519Member
    : /*************************************************************************/* Return segment address of the environment and it's size */
    : /*****************************************************************************/
    : static
    : int MemENV (unsigned int *seg, unsigned int *esize)
    : {
    : unsigned int envseg;
    : unsigned int envsegsize;
    :
    : /* Get ENV SegAddress */
    : /* This needs to be in ASM to insure working in all environments */
    : */
    : /* It does this by getting the "Master Environment" from Command.com */
    :
    : _asm
    : {
    : push es ; Save Regs
    : push si ; Save Regs
    : push di ; Save Regs
    :
    : ; push ds ; Save Regs
    : ; mov ax, 5100h ; Parm to request the cur PSP address
    : ; INT 21h ; DOS Function to get PSP Seg address
    : ; pop ds ; Restore Regs
    : ; mov es, bx ; Point to it
    : ; mov ax, es:[2ch] ; Get ENV seg addr
    : ; mov ourenv, ax ; Save it
    :
    : push ds ; Save Regs
    : mov ax, 352Eh ; Parm to request the 2E int
    : INT 21h ; DOS Function to get PSP Seg address
    : pop ds ; Restore Regs
    : mov ax, es:[2ch] ; Get ENV seg addr
    : mov envseg, ax ; Save ENV Segment addr
    :
    : dec ax ; Point to MCB (prev paragraph)
    : mov es, ax ; Put in es
    : mov ax, es:[03h] ; Get size in paragraphs
    : mov envsegsize, ax ; Save ENV Segment size
    :
    : pop di ; Restore Regs
    : pop si ; Restore Regs
    : pop es ; Restore Regs
    : }
    :
    : *seg = envseg; /* Return Seg value */
    : *esize = envsegsize; /* Return Seg size */
    :
    : return (0); /* Return */
    : }
    :
    : If Anyone can reveal any details for this function ?
    :
    :
    :
    [blue]The environment is the pairs of "NAME=VALUE" strings separated by zero bytes, at the end of this array the double zero byte symbol. Go to DOS - type "set" - you get your pairs which can be accessed programmatically using that function.[/blue]
Sign In or Register to comment.