diff --git a/Processors/68000/Implementation/68000Implementation.hpp b/Processors/68000/Implementation/68000Implementation.hpp index 9b2b58891..9006e2832 100644 --- a/Processors/68000/Implementation/68000Implementation.hpp +++ b/Processors/68000/Implementation/68000Implementation.hpp @@ -519,6 +519,31 @@ template void Proces set_ccr(active_program_->source->full); break; + case Operation::EXTbtow: + active_program_->destination->halves.low.halves.high = + (active_program_->destination->halves.low.halves.low & 0x80) ? 0xff : 0x00; + overflow_flag_ = carry_flag_ = 0; + zero_result_ = active_program_->destination->halves.low.halves.high; + negative_flag_ = zero_result_ & 0x8000; + break; + + case Operation::EXTbtol: + active_program_->destination->full = + active_program_->destination->halves.low.halves.low | + ((active_program_->destination->halves.low.halves.low & 0x80) ? 0xffffff00 : 0x00000000); + overflow_flag_ = carry_flag_ = 0; + zero_result_ = active_program_->destination->full; + negative_flag_ = zero_result_ & 0x80000000; + break; + + case Operation::EXTwtol: + active_program_->destination->halves.high.full = + (active_program_->destination->halves.low.full & 0x8000) ? 0xffff : 0x0000; + overflow_flag_ = carry_flag_ = 0; + zero_result_ = active_program_->destination->full; + negative_flag_ = zero_result_ & 0x80000000; + break; + #define and_op(a, b) a &= b #define or_op(a, b) a |= b #define eor_op(a, b) a ^= b diff --git a/Processors/68000/Implementation/68000Storage.cpp b/Processors/68000/Implementation/68000Storage.cpp index 29e3b69cc..a9a90d7d5 100644 --- a/Processors/68000/Implementation/68000Storage.cpp +++ b/Processors/68000/Implementation/68000Storage.cpp @@ -449,7 +449,7 @@ struct ProcessorStorageConstructor { NOP, // Maps to a NOP. EXG, // Maps source and destination registers and an operation mode to an EXG. - SWAP, // Maps a source register to a SWAP. + EXT_SWAP, // Maps a source register to a SWAP or EXT. EORI_ORI_ANDI_SR, // Maps to an EORI, ORI or ANDI to SR/CCR. @@ -656,7 +656,7 @@ struct ProcessorStorageConstructor { {0xf1f8, 0xc148, Operation::EXG, Decoder::EXG}, // 4-105 (p209) {0xf1f8, 0xc188, Operation::EXG, Decoder::EXG}, // 4-105 (p209) - {0xfff8, 0x4840, Operation::SWAP, Decoder::SWAP}, // 4-185 (p289) + {0xfff8, 0x4840, Operation::SWAP, Decoder::EXT_SWAP}, // 4-185 (p289) {0xffff, 0x027c, Operation::ANDItoSR, Decoder::EORI_ORI_ANDI_SR}, {0xffff, 0x023c, Operation::ANDItoCCR, Decoder::EORI_ORI_ANDI_SR}, @@ -671,6 +671,10 @@ struct ProcessorStorageConstructor { {0xffc0, 0x08c0, Operation::BSETb, Decoder::BCHG_BSET}, // 4-58 (p162) {0xffc0, 0x4ac0, Operation::TAS, Decoder::TAS}, // 4-186 (p290) + + {0xfff8, 0x4880, Operation::EXTbtow, Decoder::EXT_SWAP}, // 4-106 (p210) + {0xfff8, 0x48c0, Operation::EXTwtol, Decoder::EXT_SWAP}, // 4-106 (p210) + {0xfff8, 0x49c0, Operation::EXTbtol, Decoder::EXT_SWAP}, // 4-106 (p210) }; std::vector micro_op_pointers(65536, std::numeric_limits::max()); @@ -812,7 +816,7 @@ struct ProcessorStorageConstructor { op(Action::PerformOperation, seq("np np")); } break; - case Decoder::SWAP: { + case Decoder::EXT_SWAP: { storage_.instructions[instruction].set_destination(storage_, Dn, ea_register); op(Action::PerformOperation, seq("np")); } break; diff --git a/Processors/68000/Implementation/68000Storage.hpp b/Processors/68000/Implementation/68000Storage.hpp index 2570176a4..99be37fc2 100644 --- a/Processors/68000/Implementation/68000Storage.hpp +++ b/Processors/68000/Implementation/68000Storage.hpp @@ -109,6 +109,8 @@ class ProcessorStorage { BSETl, BSETb, TAS, + + EXTbtow, EXTbtol, EXTwtol, }; /*!