Mail Archives: djgpp/1996/11/18/19:44:38
lnwdt AT form-net DOT com wrote:
>
> >On Fri, 15 Nov 1996 lnwdt AT form-net DOT com wrote:
>
> >> I am working on a sound blaster library, and I just want to make
> >> something sure:
> >>
> >> int segment, selector;
> >>
> >> segment = __dpmi_allocate_dos_memory(size, selector);
> >>
> >> Which variable must I put in the ES register, which in EDI?
>
> >Where do ES or EDI come in for the above snippet? Can you elaborate?
>
> Ok, sorry.
>
> I want to do the sound mixing in asm. I want to use 'stosb' and 'movsb'
> etc. that needs es:edi. The memory i am allocating is for the DMA transfers.
>
> I have played around a bit, but something strange happens.
> I get the segment by doing this:
>
> long unsigned segment;
> int selector;
> segment = __dpmi_allocate_dos_memory(size, &selector) << 4;
>
> but when I use:
>
> _farnspokeb(segment, 0);
>
> I get a general fault protection error, but:
>
> _farpokeb(_dos_ds, segment, 0);
>
> gives no error. Is this correct? Any reason? (I am still getting the grips
> with protected mode etc.)
>
> Secondly, what is the use for the 'selector' variable, other than using
> it in '__dpmi_free_dos_memory(selector)' ?
>
> Or I going about this in totaly the wrong way?
>
> Thanks.
> Leon
>
> to: IN:eliz AT is DOT elta DOT co DOT il
> cc: IN:djgpp AT delorie DOT com
The reason _farnspokeb(segment, 0) gives a fault protection error is
because the selector is not set, whereas, _farpokeb(_dos_ds, segment, 0)
works because
you are providing the selector value (_dos_ds) in the function call. If
you want
to use _farnspokeb instead of using _farpokeb and having to specify the
selector
as _dos_ds every time, you must set the selector beforehand by calling
the
_farsetsel() function which, in your case, can be called with
"_farsetsel(_dos_ds);"
This will leave the selector set to _dos_ds unless you perform certain
memory
manipulations which I can't think of off the top of my head. And, of
course,
_farsetsel() is in "sys/farptr.h". Hope that helps a little. -James
- Raw text -