x86 Assembly

Moderators: None (Apply to moderate this forum)
Number of threads: 4563
Number of posts: 16029

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Return segment address of the environment and it's size Posted by ligang on 26 Sept 2002 at 6:14 PM
/*************************************************************************/* 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 ?


Report
Re: Return segment address of the environment and it's size Posted by AsmGuru62 on 26 Sept 2002 at 10:49 PM
: /*************************************************************************/* 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 ?
:
:
:
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.



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.