From dccb4e4e73620a0142d6dda24d769450b95e4554 Mon Sep 17 00:00:00 2001 From: Sjoerd van der Berg Date: Mon, 30 Dec 2002 21:53:44 +0000 Subject: [PATCH] Support reading/writing memory on bigendian machines. Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@610 --- include/mem.h | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/include/mem.h b/include/mem.h index 169e49c0..19e3d301 100644 --- a/include/mem.h +++ b/include/mem.h @@ -60,6 +60,33 @@ extern HostPt memory; Working on big or little endian machines */ +#ifdef WORDS_BIGENDIAN + +INLINE Bit8u readb(HostPt off) { + return off[0]; +}; +INLINE Bit16u readw(HostPt off) { + return off[0] | (off[1] << 8); +}; +INLINE Bit32u readd(HostPt off) { + return off[0] | (off[1] << 8) | (off[2] << 16) | (off[3] << 24); +}; +INLINE void writeb(HostPt off,Bit8u val) { + off[0]=val; +}; +INLINE void writew(HostPt off,Bit16u val) { + off[0]=(Bit8u)((val & 0x00ff)); + off[1]=(Bit8u)((val & 0xff00) >> 8); +}; +INLINE void writed(HostPt off,Bit32u val) { + off[0]=(Bit8u)((val & 0x000000ff)); + off[1]=(Bit8u)((val & 0x0000ff00) >> 8); + off[2]=(Bit8u)((val & 0x00ff0000) >> 16); + off[3]=(Bit8u)((val & 0xff000000) >> 24); +}; + +#else + INLINE Bit8u readb(HostPt off) { return *(Bit8u *)off; }; @@ -79,6 +106,7 @@ INLINE void writed(HostPt off,Bit32u val) { *(Bit32u *)(off)=val; }; +#endif /* The Folowing six functions are slower but they recognize the paged memory system */ //TODO maybe make em inline to go a bit faster