diff --git a/8080emu-first50.c b/8080emu-first50.c index e9d4911..c340a38 100644 --- a/8080emu-first50.c +++ b/8080emu-first50.c @@ -822,11 +822,11 @@ int Emulate8080Op(State8080* state) { state->a = state->memory[state->sp+1]; uint8_t psw = state->memory[state->sp]; - state->cc.z = (0x01 == (psw & 0x01)); - state->cc.s = (0x02 == (psw & 0x02)); + state->cc.cy = (0x01 == (psw & 0x01)); state->cc.p = (0x04 == (psw & 0x04)); - state->cc.cy = (0x05 == (psw & 0x08)); state->cc.ac = (0x10 == (psw & 0x10)); + state->cc.z = (0x40 == (psw & 0x08)); + state->cc.s = (0x80 == (psw & 0x10)); state->sp += 2; } break; @@ -836,11 +836,12 @@ int Emulate8080Op(State8080* state) case 0xf5: //PUSH PSW { state->memory[state->sp-1] = state->a; - uint8_t psw = (state->cc.z | - state->cc.s << 1 | - state->cc.p << 2 | - state->cc.cy << 3 | - state->cc.ac << 4 ); + uint8_t psw = (state->cc.cy | + 1 << 1 + state->cc.p << 2 | + state->cc.ac << 4 | + state->cc.z << 6 | + state->cc.s << 7 ); state->memory[state->sp-2] = psw; state->sp = state->sp - 2; }