VOGONS


First post, by Syntaxomat

User metadata
Rank Newbie
Rank
Newbie

I want to know if the location of the enviroment variables always starts at memory address hex 0:12B0?
Thx.

Reply 1 of 3, by ripsaw8080

User metadata
Rank DOSBox Author
Rank
DOSBox Author

That would be the environment variables of the first shell, but there's no guarantee it will be at that specific address.

The address is better expressed as 0128:0000, because its often referred to as the "environment segment" of a program.

Every program executed gets a copy of its parent's environment segment in a separate memory block, and when you execute a program from the shell then it's the shell's environment that is copied. The environment segment is pointed to by the word at offset 2Ch in a program's PSP.

Reply 2 of 3, by Syntaxomat

User metadata
Rank Newbie
Rank
Newbie

I think if we want to change the content of an enviroment variable or to set a new variable we can not work with the copy in the PSP and so we have to write to this enviroment segment:

0128:0000 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
0128:0010 EA 60 10 00 F0 00 00 00-00 00 00 00 00 00 00 00 .`..............
0128:0020 4D 18 01 44 00 00 00 00-00 00 00 00 00 00 00 00 M..D............

I found the enviroment variables at this location. What are these bytes above?
0128:0030 50 41 54 48 3D 5A 3A 5C-00 43 4F 4D 53 50 45 43 PATH=Z:\.COMSPEC
0128:0040 3D 5A 3A 5C 43 4F 4D 4D-41 4E 44 2E 43 4F 4D 00 =Z:\COMMAND.COM.
0128:0050 42 4C 41 53 54 45 52 3D-41 32 32 30 20 49 37 20 BLASTER=A220 I7
0128:0060 44 31 20 48 35 20 54 36-00 00 00 00 00 00 00 00 D1 H5 T6........

We can use variables for a highscore of a game or how many times we play a game and so on.... in one session.

Reply 3 of 3, by ripsaw8080

User metadata
Rank DOSBox Author
Rank
DOSBox Author

I wrote 8 by mistake; 012B:0000 is the equivalent address. Each segment is a paragraph, 16 bytes, so the transform is simple.

You will almost certainly not find the first shell's environment segment at the same address on other DOS systems, and it may change in later releases of DOSBox. The best thing to do is to find the PSP of the first shell in order to determine its environment segment.

In DOSBox the first shell's PSP is at 0118:0000, so the word at 0118:002C is the environment segment. But as I mentioned, you shouldn't rely on specific addresses.