Re: referring to segments other than DS - how?
- From: Pop Tart <morespamsREMOVE@xxxxxxxxxxxxxxx>
- Date: Thu, 28 Feb 2008 09:12:29 -0600
On Wed, 27 Feb 2008 11:04:31 -0800, japheth wrote:
in 16bit, if you're using the .model directive (ie .model small), @data
will be the "group" of the data segment. Then both logical segments
_DATA and _BSS are contained in the same physical segment (which is
called DGROUP) and the "offset" operator will refer to the physical
segment then (at least with MASM v6+).
I think this is more clear to me now. Feel free to correct me if I'm
wrong.
In looking at the opcodes for:
mov ax, _bss
it is something like:
B8 BD 13 ==> intel ==> mov ax, 13BD
And if I have already declared in a label in BSS (masm's ".data?"
directive) like this:
..data?
MyFileHandle WORD ?
and then if I later copy ax to that memory location labeled MyFileHandle,
the opcode will look something like this:
A3 84 03 ==> intel ==> mov word ptr [384], ax
My first expectation was that this would be "mov word ptr [0], ax",
because I was thinking that there was a separate physical section, and
"MyFileHandle" would reference the 1st byte in that section. This is
wrong!
The processor doesn't really know about the bss section - the processor
just moves the value in ax into the memory location which is 384 (hex)
bytes into the physical data segment (DGROUP). This location (384h) can
be in multiple logical segments. If the physical data segment starts at
segment 13A4 then the following reference refers to that same location
==> 13A4:0384,
and this is 13DC4h bytes from the beginning of the program's memory
(13A40h + 384h). Each segment is 16 bytes from the last segment.
Segment 0001 is 16 bytes higher than segment 0000.
THIS segment/offset, 13BD:01F4
also refers to the same physical location as 13A4:0384.
==> 13BD0h + 01F4h = 13DC4h, and
==> 13A40h + 0384h = 13DC4
Again, each segment is a logical 16 (decimal) byte block. So, segment
0001 is at byte 16d in the program's memory. We can multiply the segment
by 16d (or, 10h) to find the exact location in the program of that
segment. Segment 0002 * 10h = 00020h bytes into the memory.
If BSS is at logical segment 13BD, and DS is at logical segment 13A4,
then BSS is 19h segments higher than DS, or 190h bytes higher than DS
(400 decimal bytes).
13BDh - 13A4h = 19h
19 segments is 19h * 10h bytes. 190h bytes.
Hopefully, I'm right about this. If so, maybe this will help another
newbie reading the forum. Feel free to correct or add.
--
Regards,
Pop Tart
.
- References:
- referring to segments other than DS - how?
- From: Pop Tart
- Re: referring to segments other than DS - how?
- From: japheth
- referring to segments other than DS - how?
- Prev by Date: Re: Cause IRQ5 programmatically
- Next by Date: Re: [OT] the lack of humility
- Previous by thread: Re: referring to segments other than DS - how?
- Next by thread: Re: referring to segments other than DS - how?
- Index(es):
Relevant Pages
|