From 5daf57ffe118c191b878a77c2b1a7930af41712e Mon Sep 17 00:00:00 2001 From: a dinosaur Date: Wed, 10 Apr 2024 06:47:12 +1000 Subject: [PATCH] remove masm hex generator --- src/swriter.cpp | 44 -------------------------------------------- 1 file changed, 44 deletions(-) diff --git a/src/swriter.cpp b/src/swriter.cpp index 08d6765..399de24 100644 --- a/src/swriter.cpp +++ b/src/swriter.cpp @@ -5,16 +5,10 @@ #include #include -#define GNU_STYLE 0 -#define MASM_STYLE 1 - -#define HEX_STYLE GNU_STYLE - static inline constexpr char HexU(uint8_t h) { return "0123456789ABCDEF"[h >> 4]; } static inline constexpr char HexL(uint8_t l) { return "0123456789ABCDEF"[l & 15]; } -#if HEX_STYLE == GNU_STYLE template static void CHex(std::ostream& s, T x); template <> void CHex(std::ostream& s, uint8_t x) { @@ -42,40 +36,6 @@ template <> void CHex(std::ostream& s, uint32_t x) if (x > 15) s << HexU(static_cast(x)); s << HexL(static_cast(x)); } -#elif HEX_STYLE == MASM_STYLE -template static void MHex(std::ostream& s, T x); -template <> void MHex(std::ostream& s, uint8_t x) -{ - if (x > 159) s << "0"; - if (x > 15) s << HexU(x); else if (x > 9) s << "0"; - s << HexL(x); - if (x > 9) s << "h"; -} -template <> void MHex(std::ostream& s, uint16_t x) -{ - if (x > 40959) s << "0"; - if (x > 4095) s << HexU(static_cast(x >> 8)); else if (x > 2559) s << "0"; - if (x > 255) s << HexL(static_cast(x >> 8)); else if (x > 159) s << "0"; - if (x > 15) s << HexU(static_cast(x)); else if (x > 9) s << "0"; - s << HexL(static_cast(x)); - if (x > 9) s << "h"; -} -template <> void MHex(std::ostream& s, uint32_t x) -{ - if (x > 0x9FFFFFFF) s << "0"; - if (x > 0xFFFFFFF) s << HexU(static_cast(x >> 24)); else if (x > 0x9FFFFFF) s << "0"; - if (x > 0xFFFFFF) s << HexL(static_cast(x >> 24)); else if (x > 0x9FFFFF) s << "0"; - if (x > 0xFFFFF) s << HexU(static_cast(x >> 16)); else if (x > 655359) s << "0"; - if (x > 65535) s << HexL(static_cast(x >> 16)); else if (x > 40959) s << "0"; - if (x > 4095) s << HexU(static_cast(x >> 8)); else if (x > 2559) s << "0"; - if (x > 255) s << HexL(static_cast(x >> 8)); else if (x > 159) s << "0"; - if (x > 15) s << HexU(static_cast(x)); else if (x > 9) s << "0"; - s << HexL(static_cast(x)); - if (x > 9) s << "h"; -} -#else -# error "Unknown hex style" -#endif template static constexpr const std::string_view DataType(); @@ -95,11 +55,7 @@ static void WriteArrayDetail(std::ostream& s, const I beg, const I end, int perC s << "\t" << DataType() << " "; const Element e = *it; -#if HEX_STYLE == MASM_STYLE - MHex(s, e); -#elif HEX_STYLE == GNU_STYLE CHex(s, e); -#endif if (++it == end) break;