From e672bb1f9877d891c1ff162b0673438876a11af0 Mon Sep 17 00:00:00 2001 From: Christian Speckner Date: Mon, 12 Aug 2024 21:37:28 +0200 Subject: [PATCH] Force inline read methods, tread big endian the same way. --- src/emucore/CortexM0.cxx | 60 +++++++++++++++++++++------------------- 1 file changed, 32 insertions(+), 28 deletions(-) diff --git a/src/emucore/CortexM0.cxx b/src/emucore/CortexM0.cxx index 53534c973..e78a2fafb 100644 --- a/src/emucore/CortexM0.cxx +++ b/src/emucore/CortexM0.cxx @@ -24,45 +24,49 @@ #include "Base.hxx" -#ifdef __BIG_ENDIAN__ - #define READ32(data, addr) ( \ - (((uInt8*)(data))[(addr)]) | \ - (((uInt8*)(data))[(addr) + 1] << 8) | \ - (((uInt8*)(data))[(addr) + 2] << 16) | \ - (((uInt8*)(data))[(addr) + 3] << 24) \ - ) - - #define READ16(data, addr) ( \ - (((uInt8*)(data))[(addr)]) | \ - (((uInt8*)(data))[(addr) + 1] << 8) \ - ) - - #define WRITE32(data, addr, value) \ - ((uInt8*)(data))[(addr)] = (value); \ - ((uInt8*)(data))[(addr) + 1] = (value) >> 8; \ - ((uInt8*)(data))[(addr) + 2] = (value) >> 16; \ - ((uInt8*)(data))[(addr) + 3] = (value) >> 24; - - #define WRITE16(data, addr, value) \ - ((uInt8*)(data))[(addr)] = value; \ - ((uInt8*)(data))[(addr) + 1] = (value) >> 8; -#else namespace { - inline uInt32 READ32(const uInt8* data, uInt32 addr) { +#ifdef __BIG_ENDIAN__ + FORCE_INLINE uInt32 READ32(const uInt8* data, uInt32 addr) { + return + (((uInt8*)(data))[(addr)]) | + (((uInt8*)(data))[(addr) + 1] << 8) | + (((uInt8*)(data))[(addr) + 2] << 16) | + (((uInt8*)(data))[(addr) + 3] << 24); + } + + FORCE_INLINE uInt16 READ16(const uInt8* data, uInt32 addr) { + return (((uInt8*)(data))[(addr)]) | (((uInt8*)(data))[(addr) + 1] << 8); + } + + FORCE_INLINE void WRITE32(uInt8* data, uInt32 addr, uInt32 value) { + ((uInt8*)(data))[(addr)] = (value); + ((uInt8*)(data))[(addr) + 1] = (value) >> 8; + ((uInt8*)(data))[(addr) + 2] = (value) >> 16; + ((uInt8*)(data))[(addr) + 3] = (value) >> 24; + } + + FORCE_INLINE void WRITE16(uInt8* data, uInt32 addr, uInt16 value) { + ((uInt8*)(data))[(addr)] = value; + ((uInt8*)(data))[(addr) + 1] = (value) >> 8; + } +#else + FORCE_INLINE uInt32 READ32(const uInt8* data, uInt32 addr) { return (reinterpret_cast(data))[addr >> 2]; } - inline uInt16 READ16(const uInt8* data, uInt32 addr) { + + FORCE_INLINE uInt16 READ16(const uInt8* data, uInt32 addr) { return (reinterpret_cast(data))[addr >> 1]; } - inline void WRITE32(uInt8* data, uInt32 addr, uInt32 value) { + FORCE_INLINE void WRITE32(uInt8* data, uInt32 addr, uInt32 value) { (reinterpret_cast(data))[addr >> 2] = value; } - inline void WRITE16(uInt8* data, uInt32 addr, uInt16 value) { + + FORCE_INLINE void WRITE16(uInt8* data, uInt32 addr, uInt16 value) { (reinterpret_cast(data))[addr >> 1] = value; } -} // namespace #endif +} // namespace // #define THUMB_DISS