Mail Archives: djgpp/1995/02/07/10:26:06
(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?
(2) In the peek and nspeek functions in <sys/farptr.h>, e.g.:-
extern inline unsigned char _farpeekb(
unsigned short selector, unsigned long offset) {unsigned char result;
asm("movw %0,%%fs" : : "r" (selector));
asm(".byte 0x64\n" " movb (%1),%0" : "=r" ((int)result) : "r" (offset));
return result;}
why not output straight to the result register al/ax/eax?, thus?:-
extern inline unsigned char _farpeekb(
unsigned short selector, unsigned long offset) {
asm("movw %0,%%fs" : : "r" (selector));
asm(".byte 0x64\n" " movb (%1),%0" : %%al : "r" (offset)); }
- Raw text -