| 278 | } |
| 279 | |
| 280 | void assertResult(struct Data* data, CPU* cpu, int instruction, U32 resultvar1, U32 resultvar2, int r1, int r2, U32 address, int bits, bool ignoreFlags = false) { |
| 281 | if (data->useResultvar2 && data->resultvar2 != resultvar2) { |
| 282 | failed("instruction: %d var2: %d != %d", instruction, resultvar2, data->resultvar2); |
| 283 | } |
| 284 | if (!data->dontUseResultAndCheckSFZF && data->result != resultvar1) { |
| 285 | failed("instruction: %d var1: %d != %d", instruction, resultvar1, data->result); |
| 286 | } |
| 287 | if (!ignoreFlags) { |
| 288 | if (data->hasCF && (cpu->getCF() ? 1 : 0) != data->fCF) { |
| 289 | cpu->getCF(); |
| 290 | failed("instruction: %d CF", instruction); |
| 291 | } |
| 292 | if (data->hasOF && (cpu->getOF() != 0) != data->fOF) { |
| 293 | cpu->getOF(); |
| 294 | failed("instruction: %d OF", instruction); |
| 295 | } |
| 296 | if (data->hasAF && (cpu->getAF() != 0) != data->fAF) { |
| 297 | cpu->getAF(); |
| 298 | failed("instruction: %d AF", instruction); |
| 299 | } |
| 300 | if (data->hasSF && (cpu->getSF() != 0) != data->fSF) { |
| 301 | cpu->getSF(); |
| 302 | failed("instruction: %d SF", instruction); |
| 303 | } |
| 304 | if (data->hasZF && (cpu->getZF() != 0) != data->fZF) { |
| 305 | cpu->getZF(); |
| 306 | failed("instruction: %d ZF", instruction); |
| 307 | } |
| 308 | if (data->dontUseResultAndCheckSFZF) { |
| 309 | if ((cpu->getSF() != 0) != data->fSF) { |
| 310 | failed("instruction: %d SF", instruction); |
| 311 | } |
| 312 | if ((cpu->getZF() != 0) != data->fZF) { |
| 313 | failed("instruction: %d ZF", instruction); |
| 314 | } |
| 315 | } |
| 316 | } |
| 317 | if (bits == 8 || bits == 16) { |
| 318 | if (r1 >= 0) { |
| 319 | if ((cpu->reg[r1].u32 & 0xFFFF0000) != (DEFAULT & 0xFFFF0000)) { |
| 320 | failed("instruction: %d reg overwrite %d", instruction, r1); |
| 321 | } |
| 322 | } |
| 323 | if (r2 >= 0) { |
| 324 | if ((cpu->reg[r2].u32 & 0xFFFF0000) != (DEFAULT & 0xFFFF0000)) { |
| 325 | failed("instruction: %d reg overwrite %d", instruction, r2); |
| 326 | } |
| 327 | } |
| 328 | } |
| 329 | if (bits == 8) { |
| 330 | if (address != 0) { |
| 331 | if ((memory->readd(address) & 0xFFFFFF00) != (DEFAULT & 0xFFFFFF00)) { |
| 332 | failed("instruction: %d memory overwrite %d", instruction, address); |
| 333 | } |
| 334 | } |
| 335 | } |
| 336 | if (bits == 16) { |
| 337 | if (address != 0) { |
no test coverage detected