From 08f28773828140049be2d7bb01a12f50afdbd05a Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Sat, 21 Dec 2019 20:37:03 -0500 Subject: [PATCH 1/2] I think the 68000 actually loads a byte value onto both the upper and lower data lines. --- Processors/68000/68000.hpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Processors/68000/68000.hpp b/Processors/68000/68000.hpp index ca087411a..8bd61227a 100644 --- a/Processors/68000/68000.hpp +++ b/Processors/68000/68000.hpp @@ -224,8 +224,7 @@ struct Microcycle { */ forceinline uint16_t value16() const { if(operation & SelectWord) return value->full; - const auto shift = byte_shift(); - return uint16_t((value->halves.low << shift) | (0xff00 >> shift)); + return uint16_t((value->halves.low << 8) | value->halves.low); } /*! @@ -237,7 +236,7 @@ struct Microcycle { return uint8_t(value->full >> 8); } - return uint8_t(value->halves.low | (0xff00 >> ((*address & 1) << 3))); + return value->halves.low; } /*! @@ -249,7 +248,7 @@ struct Microcycle { return uint8_t(value->full); } - return uint8_t(value->halves.low | (0x00ff << ((*address & 1) << 3))); + return value->halves.low; } /*! From cf16f4193976b57ce0e3fbdbebd5072d32bf11db Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Sat, 21 Dec 2019 20:58:37 -0500 Subject: [PATCH 2/2] Makes value8_high/low and value16 branchless. --- Processors/68000/68000.hpp | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/Processors/68000/68000.hpp b/Processors/68000/68000.hpp index 8bd61227a..25fa263f1 100644 --- a/Processors/68000/68000.hpp +++ b/Processors/68000/68000.hpp @@ -53,7 +53,9 @@ struct Microcycle { /// which by inspecting the low bit of the provided address. The RW line indicates a read. static const int SelectByte = 1 << 0; // Maintenance note: this is bit 0 to reduce the cost of getting a host-endian - // bytewise address. See implementation of host_endian_byte_address(). + // bytewise address. The assumption that it is bit 0 is also used for branchless + // selection in a few places. See implementation of host_endian_byte_address(), + // value8_high(), value8_low() and value16(). /// Indicates that the address and both data select strobes are active. static const int SelectWord = 1 << 1; @@ -223,8 +225,8 @@ struct Microcycle { this is a write cycle. */ forceinline uint16_t value16() const { - if(operation & SelectWord) return value->full; - return uint16_t((value->halves.low << 8) | value->halves.low); + const uint16_t values[] = { value->full, uint16_t((value->halves.low << 8) | value->halves.low) }; + return values[operation & SelectByte]; } /*! @@ -232,11 +234,8 @@ struct Microcycle { @c 0xff otherwise. Assumes this is a write cycle. */ forceinline uint8_t value8_high() const { - if(operation & SelectWord) { - return uint8_t(value->full >> 8); - } - - return value->halves.low; + const uint8_t values[] = { uint8_t(value->full >> 8), value->halves.low}; + return values[operation & SelectByte]; } /*! @@ -244,11 +243,8 @@ struct Microcycle { @c 0xff otherwise. Assumes this is a write cycle. */ forceinline uint8_t value8_low() const { - if(operation & SelectWord) { - return uint8_t(value->full); - } - - return value->halves.low; + const uint8_t values[] = { uint8_t(value->full), value->halves.low}; + return values[operation & SelectByte]; } /*!