Re: referring to segments other than DS - how?
- From: Pop Tart <morespamsREMOVE@xxxxxxxxxxxxxxx>
- Date: Wed, 27 Feb 2008 13:21:51 -0600
On Wed, 27 Feb 2008 17:48:51 +0000, Frank Kotler wrote:
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
Thanks Frank. Maybe you or someone else can help with this. Assuming I
only have 16-bit registers, and I've got a buffer in BSS, how do I write
the buffer to a file? If I understand correctly, function 40h / int 21h
needs the address of the buffer to be in DS:DX, so I have to move the BSS
segment to DS. However, my program is terminating on the int 21h below -
before even setting error code to AX or setting the Carry Flag.
(I have ES set to BSS below. label 'InputBuffer is an offset into BSS)
mov ax, 40h ; func. write array
mov bx, EncFileHandle ; file handle to bx
mov cx, 500 ; bytes to write from 3fh abv
mov di, es
mov ds, di ; set ds to es for inp.buffer
mov dx,OFFSET InputBuffer
int 21h ;terminates abrubtly here
cmp ax,0 ; did we write anything
je EmptyOutput
Only thing I can think is that EncFileHandle, which is a label to an
offset into the regular Data Segment (not BSS), causes it to screw up...
However, reading a file into this array in the same fashion, with 3Fh /
int 21h, didn't have a problem. If the function *is* interpreting
EncFileHandle to be in *BSS*, how the heck does anyone write to an
uninitialized buffer? !@#$%! :)
Again, I'm trying not to use 32-bit registers. Many thanks in advance.
--
Regards,
Pop Tart
.
- Follow-Ups:
- Re: referring to segments other than DS - how?
- From: japheth
- 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
- Re: referring to segments other than DS - how?
- From: Frank Kotler
- referring to segments other than DS - how?
- Prev by Date: Re: referring to segments other than DS - how?
- Next by Date: Re: Cause IRQ5 programmatically
- 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
|