referring to segment offsets in read address mode
- From: Brian Phillips <spamtrap@xxxxxxxxxx>
- Date: Fri, 29 Feb 2008 03:35:50 -0600
I had tucked this question into a stale thread at alt.lang.asm, and
didn't receive any input, so trying here....
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!
.
- Follow-Ups:
- Re: referring to segment offsets in read address mode
- From: Frank Kotler
- Re: referring to segment offsets in read address mode
- Prev by Date: Re: Seg fault with hla 1.99 on Fedora 8 linux
- Next by Date: Re: Jumping into middle of instruction
- Previous by thread: Setting IOPL of a Procedure
- Next by thread: Re: referring to segment offsets in read address mode
- Index(es):
Relevant Pages
|