Mail Archives: djgpp/1995/02/07/17:05:52
> (1) dj AT stealth DOT ctron DOT com (DJ Delorie) wrote:-
> > I don't recommend using the farns* [= _farnspeekw() etc, in <sys/farptr.h>]
> > functions inside other functions. It's not safe. You don't know what someone
> > else might have done with the segment registers between calls.
>
> But my program is almost entirely composed of functions calling functions
> calling functions several deep! Hardly any of it is in main(). If I can only
> use the _farns*() functions in main(), I can't use them. Can I then use the
> _far*() functions that do specify a `selector', and put the `unsigned short
> selector' argument as 0?
It's not impossible to do it your way, just be warned that your
functions can't GUARANTEE that the segment registers have the right
values. The _farns* functions were intended to be used in an enclosed
function, like one that loops through a chunk of video memory, where
you know that there's no opportunity for someone else to use a _far*
function. All it takes is someone calling _far* (say, to get a BIOS
value) and you're toast.
> (2) In the peek and nspeek functions in <sys/farptr.h>, e.g.:-
>
> why not output straight to the result register al/ax/eax?, thus?:-
gcc optimizes it down to that, but my way has two advantages:
(1) There's no reliance on values being returned in eax.
(2) The compiler doesn't print any warning messages about no value
being returned.
- Raw text -