Skip to content

MCL6809 project: bug in ANDCC and ORCC instructions #51

Description

@Pieter56

Hi Ted,

Nice projects. I was using the MCL6809.ino and found a problem in the instructions opcode_0x1C () and opcode_0x1CA() for the respective instructions ANDCC immediate and ORCC immediate.

Replace UpdateFlags( AND_Common(REGISTER_CC,ea_data8) ); , with UpdateFlags(REGISTER_CC & ea_data8) ;
and replace UpdateFlags( OR_Common(REGISTER_CC,ea_data8) ); , with UpdateFlags(REGISTER_CC | ea_data8) ; to solve it.

The reason is that the AND_Common and OR_Common subroutines will change the NZV flags after the operation.
In some cases this may give the wrong result.
For instance V flag will be cleared, irrespective of the value of the operands.
If all the flags were all cleared before the ANDCC instruction, the zero flag will be set. That should not happen either.

Cheers.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions