YCPU icon indicating copy to clipboard operation
YCPU copied to clipboard

Emulator's BTI pattern does not match spec.

Open ZaneDubya opened this issue 4 years ago • 1 comments

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);
    }

ZaneDubya avatar Apr 24 '20 15:04 ZaneDubya

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

PrincessRiikka avatar Apr 24 '20 19:04 PrincessRiikka