ZaneDubya / YCPU

An imaginary 16-bit cpu, with a complete specification, emulator, assembler, and disassembler, in C#.
24 stars 3 forks source link

Emulator's BTI pattern does not match spec. #16

Open ZaneDubya opened 4 years ago

ZaneDubya commented 4 years ago

https://github.com/ZaneDubya/YCPU/blob/652601eb3a7540d5b1a610346a5b0b43469328b4/Source/Libraries/YpsilonCPU/Emulation/Processor/YCPU.BitPatterns.cs#L63

Suggested fix:

    private void BitPatternBTI(ushort operand, out ushort value, out RegGeneral destination) {
        destination = (RegGeneral)((operand & 0xE000) >> 13); // bits DEF
        RegGeneral source = (RegGeneral)((operand & 0x0F00) >> 8);
        bool asRegister = (operand & 0x1000) != 0;
        value = asRegister ?
            (ushort)(R[(int)source] & 0x000F) :
            (ushort)((operand & 0x1E00) >> 9);
    }
PrincessRiikka commented 4 years ago

(ushort)((operand & 0x1E00) >> 9); -> (ushort)((operand & 0x0F00) >> 8); (or source, not sure about the types there) Rest looks okay.