Re: referring to segments other than DS - how?
- From: Frank Kotler <fbkotler@xxxxxxxxxxx>
- Date: Wed, 27 Feb 2008 17:48:51 GMT
Pop Tart wrote:
Hi,
I'm back again with two 16-bit newb questions :)
1)
With int 21h function 3Fh, I'm trying to write then read an array of bytes in the uninitialized data section.
When I call the int 21h / 3Fh to read from a file and store in an uninitialized buffer - I assume the interrupt wants both BX and DX to be offsets to DS, so how do I set DS to uninitialized section (BSS) in MASM. I know how to set DS to "DATA" segment in MASM :
mov ax, @data
mov ds, ax
so for BSS, would it be:
mov ax, _BSS
I tried @BSS, that didn't assemble.
;-----------------------------------
I'm not sure about this one - I'd assume data and bss are in the same segment...
2)
Secondly, if I set ES to the data segment, DS, for example
mov ax, @data
mov es, ax
How do I de-reference a byte that is offset in the ES section? Which registers are legal to use?
ie, this isn't assembling for me:
mov ax, @data ; set es to data segmet
mov es, ax
mov dx, OFFSET InputBuffer
mov al, BYTE PTR es:[dx]
The MASM assembler complains about the last line, saying:
main.asm(134): error A2031: must be index or base register.
I change 'dx' to 'di' and it assembles ok. Which other registers are legal?
Using 16-bit instructions, si and di are "index" registers, bx and bp are "base" registers. You can use an (optional) offset, plus an (optional) base register, plus an (optional) index register. That is, [si + bx] is okay but [si + di] is not. We can, even in 16-bit code, use 32-bit addressing modes - mov al, BYTE PTR es:[edx] would work. I think you'd need to "enable" 32-bit instructions for Masm - ".386" *after* the ".model" directive, IIRC. Simplest thing is to stick with si, di, and bx for addressing (bp is "special" in that it defaults to ss:[bp]).
Best,
Frank
.
- Follow-Ups:
- Re: referring to segments other than DS - how?
- From: Pop Tart
- Re: referring to segments other than DS - how?
- References:
- referring to segments other than DS - how?
- From: Pop Tart
- referring to segments other than DS - how?
- Prev by Date: referring to segments other than DS - how?
- Next by Date: Re: referring to segments other than DS - how?
- Previous by thread: referring to segments other than DS - how?
- Next by thread: Re: referring to segments other than DS - how?
- Index(es):
Relevant Pages
|