1
0
Fork 0

Support reading/writing memory on bigendian machines.

Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@610
This commit is contained in:
Sjoerd van der Berg 2002-12-30 21:53:44 +00:00
parent a70ff185dd
commit dccb4e4e73

View file

@ -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