Index: arith32.cc =================================================================== RCS file: /home/hohmuth/local/var/cvs/bochs/cpu/arith32.cc,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -p -r1.1.1.1 -r1.2 --- arith32.cc 2001/11/14 17:26:46 1.1.1.1 +++ arith32.cc 2001/11/15 16:10:09 1.2 @@ -856,11 +856,38 @@ BX_CPU_C::CMPXCHG_EdGd(BxInstruction_t * BX_CPU_C::CMPXCHG8B(BxInstruction_t *i) { #if (BX_CPU_LEVEL >= 5) || (BX_CPU_LEVEL_HACKED >= 5) - if (i->mod != 0xc0) { - BX_INFO(("CMPXCHG8B: dest is reg: #UD")); - UndefinedOpcode(i); - } - BX_PANIC(("CMPXCHG8B: not implemented yet")); + + Bit32u op1_64_lo, op1_64_hi, diff; + + if (i->mod == 0xc0) { + BX_INFO(("CMPXCHG8B: dest is reg: #UD")); + UndefinedOpcode(i); + } + + /* pointer, segment address pair */ + read_virtual_dword(i->seg, i->rm_addr, &op1_64_lo); + read_RMW_virtual_dword(i->seg, i->rm_addr + 4, &op1_64_hi); + + diff = EAX - op1_64_lo; + diff |= EDX - op1_64_hi; + +// SET_FLAGS_OSZAPC_32(EAX, op1_32, diff_32, BX_INSTR_CMP32); + + if (diff == 0) { // if accumulator == dest + // ZF = 1 + set_ZF(1); + // dest <-- src + write_RMW_virtual_dword(ECX); + write_virtual_dword(i->seg, i->rm_addr, &EBX); + } + else { + // ZF = 0 + set_ZF(0); + // accumulator <-- dest + EAX = op1_64_lo; + EDX = op1_64_hi; + } + #else BX_INFO(("CMPXCHG8B: not implemented yet")); UndefinedOpcode(i);