Re: referring to segments other than DS - how?



New Question, but it relates to the above.

In a 16 bit real address mode assembly program - using masm 6.11 here -

If I have the following labels declared in ".data?" (BSS):


COUNT equ 500

..data?
InputBuffer BYTE COUNT DUP(?)
OpenFileHandle WORD ?
EncFileHandle WORD ?

and later.....

;read file into input buffer
mov ah, 3Fh ; read array of bytes
mov bx, OpenFileHandle ; src file handle
mov cx, COUNT ; max bytes to read
mov di, OFFSET _bss ; set DS to BSS
mov ds, di
mov dx, OFFSET InputBuffer ; addr to rcv bytes
int 21h ; AX = bytes read

the assembler produces an offset from logical _data for "OpenFileHandle",
but then it produces an offset from logical _bss for "InputBuffer". Both
are declared in ".data?" (bss).

I had to move the offset to _bss into DS for the function 3Fh, so at
first I thought that was the reason. So I inserted some test code like
this:
;--------------------------
;test segments begin
mov di, OFFSET _bss
mov ds, di
mov bx, OpenFileHandle ; src file handle

mov di, @data
mov ds, di
mov bx, OpenFileHandle
;test segments end
;------------------------

the same offset was used in both cases, (0384h in my current debug
session). The offset is only valid from the original, regular data
segment that DS is initialized with when the program starts.

This is *not* a case where the segments overlap and actually refer to the
same physical location.

Thanks for your input!
--
Regards,
Pop Tart
.



Relevant Pages

  • referring to segment offsets in read address mode
    ... but then it produces an offset from logical _bss for "InputBuffer". ... I had to move the offset to _bss into DS for the function 3Fh, ... ;test segments begin ... The offset is only valid from the original, regular data ...
    (comp.lang.asm.x86)
  • Re: referring to segment offsets in read address mode
    ... I had to move the offset to _bss into DS for the function 3Fh, ... first I thought that was the reason. ... ;test segments begin ... do you understand that the assembler does not actually know what value ...
    (comp.lang.asm.x86)
  • Re: referring to segment offsets in read address mode
    ... I'm still not sure why one label ... declared in masm's uninitialized data gets translated by the assembler as ... section gets translated as an offset from _bss. ...
    (comp.lang.asm.x86)
  • 2.6.9-mm1 : compile error & question
    ... I'am getting this error when compiling 2.6.9-mm1: ... LD vmlinux ... BFD: Warning: Writing section `.bss' to huge file offset ...
    (Linux-Kernel)
  • Re: referring to segment offsets in read address mode
    ... I had to move the offset to _bss into DS for the function 3Fh, ... ;test segments begin ... One point of confusion is that somewhere along the line I introduced the ...
    (comp.lang.asm.x86)