jsmolka / gba-tests

A collection of Game Boy Advance tests.
MIT License
101 stars 9 forks source link

Test that TST/TEQ/CMP/CMN don't write back the actual value #3

Closed Ankeraout closed 4 years ago

Ankeraout commented 4 years ago

gba-suite does not detect when tst r0, r1 actually acts as ands r0, r0, r1. The same thing happened for TEQ. I did not test for CMP and CMN.

jsmolka commented 4 years ago

Could you provide an assembly example for this? I have no idea how a tst could act as ands because they are using different opcodes to begin with.

Ankeraout commented 4 years ago

In my source code, I made this mistake:

    DECLARE_DATAPROC_OPCODE(
        tst,
        uint32_t result = Rn_v & op2;

        logicSetFlags(result);
        registerWrite(Rd, result); // Here is the problem.

        S_FOOTER;
    )

In this case, the test fails because TST, like CMP, CMN and TEQ, is not supposed to change the value of Rd. The test shows a red screen.

Removing registerWrite(Rd, result); from the code fixed the problem.

Here is the source code of the test.

jsmolka commented 4 years ago

Glad you figured it out. I am not going to add extra tests for this because I consider it default hehavior.