Clean up code for conditional jumps
Amended: A binary file got in there
This commit is contained in:
parent
305663c110
commit
55db78a15d
28
utils/emul.c
28
utils/emul.c
@ -192,22 +192,6 @@ void modrm(int size) {
|
||||
if (mod == 2) rmptr += (int16_t)imm16();
|
||||
}
|
||||
|
||||
int cond(int num) {
|
||||
int r = 0;
|
||||
switch(num >> 1) {
|
||||
case 2:
|
||||
r = !scratch;
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "Condition code %d not implemented\n", num);
|
||||
exit(1);
|
||||
break;
|
||||
}
|
||||
// Each odd condition is the negation of the previous
|
||||
if (num & 1) r=1-r;
|
||||
return r;
|
||||
}
|
||||
|
||||
void push(uint16_t v) {
|
||||
SP -= 2;
|
||||
*(uint16_t*)&mem[SP] = v;
|
||||
@ -296,7 +280,17 @@ void step() {
|
||||
break;
|
||||
case 0x70 ... 0x7F: // Jcc
|
||||
reg = ip + (int8_t)imm8();
|
||||
if (cond(opcode-0x70)) {
|
||||
switch((opcode-0x70) >> 1) {
|
||||
case 0: scratch = flags.bit.o; break;
|
||||
case 1: scratch = flags.bit.s; break;
|
||||
case 2: scratch = flags.bit.z; break;
|
||||
case 3: scratch = flags.bit.c; break;
|
||||
case 4: scratch = flags.bit.c || flags.bit.z; break;
|
||||
case 5: scratch = flags.bit.s != flags.bit.o; break;
|
||||
case 6: scratch = flags.bit.z || flags.bit.s != flags.bit.o; break;
|
||||
case 7: scratch = flags.bit.p; break;
|
||||
}
|
||||
if (!!(opcode & 1) != scratch) {
|
||||
ip = reg;
|
||||
}
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user