Mail Archives: djgpp/1995/10/16/05:52:36
kokuryu AT igc DOT net (David Somner) said (Subject: Question on djgpp dpmi
pointers):-
> I need to know how to convert the _go32_seginfo structure to a far pointer
> that will point to the referenced memory location in convtional memory as
> allocated by _go32_dpmi_allocate_dos_memory()
#include <dpmi.h>
#define SEL _go32_info_block.selector_for_linear_memory
#define uns unsigned
inline void _farpokeb(uns short selector, uns long offset, uns char value) {
asm("movw %0,%%fs" : : "r" (selector));
asm(".byte 0x64\n" " movb %0,(%1)" : : "r" ((uns char)value), "r" (offset));}
inline void _farpokew(uns short selector, uns long offset, uns short value) {
asm("movw %0,%%fs" : : "r" (selector));
asm(".byte 0x64\n" " movw %0,(%1)" : : "r" (value), "r" (offset));}
inline void _farpokel(uns short selector, uns long offset, uns long value) {
asm("movw %0,%%fs" : : "r" (selector));
asm(".byte 0x64\n" " movl %0,(%1)" : : "r" (value), "r" (offset));}
inline uns char _farpeekb(uns short selector, uns long offset) {uns char R;
asm("movw %0,%%fs" : : "r" (selector));
asm(".byte 0x64\n" " movb (%1),%0" : "=r" ((int)R) : "r" (offset)); return R;}
inline uns short _farpeekw(uns short selector, uns long offset) {uns short R;
asm("movw %0,%%fs" : : "r" (selector));
asm(".byte 0x64\n" " movw (%1),%0" : "=r" (R) : "r" (offset)); return R;}
inline uns long _farpeekl(uns short selector, uns long offset) {uns long R;
asm("movw %0,%%fs" : : "r" (selector));
asm(".byte 0x64\n" " movl (%1),%0" : "=r" (R) : "r" (offset)); return R;}
/*-----*/
/* and then e.g.*/
/*-----*/
class c_byte {public: uns int addr;
inline c_byte_addr&adr();
inline char val(){return _farpeekb(SEL,addr);};
inline void operator=(char c){_farpokeb(SEL,addr,c);};
inline char(){return _farpeekb(SEL,addr);};};
- Raw text -