jsmolka / eggvance

A Game Boy Advance emulator.
https://smolka.dev/tags/eggvance
GNU General Public License v3.0
65 stars 1 forks source link

ANDS instruction has no effect on C flag #5

Closed GGORZ10227216 closed 3 years ago

GGORZ10227216 commented 3 years ago
mov r1, #0x80000000
mov r4, #0x1
ands r0, r1, r1, lsl r4

I think the state of cpsr after execute arm code above is : [N:0, Z: 1, C: 1, V:0] --> 0x6 But I found that eggvance give me: [N:0, Z: 1, C: 0, V:0] --> 0x4

After some code tracing, There is a piece of code make me confuse:

src/arm/instr_arm.cpp, line 75 :

constexpr bool kLogical = 
           kOpcode == kOpcodeAdd // ?
        || kOpcode == kOpcodeEor
        || kOpcode == kOpcodeOrr
        || kOpcode == kOpcodeMov
        || kOpcode == kOpcodeBic
        || kOpcode == kOpcodeMvn
        || kOpcode == kOpcodeTst
        || kOpcode == kOpcodeTeq;

Do you mean KOpcodeAnd?

jsmolka commented 3 years ago

Thank you very much for this! That's a typo I would have never found on my own.