ocpu: Add CMP instruction
This commit is contained in:
parent
05914bb508
commit
055f16d956
|
@ -59,6 +59,8 @@
|
|||
#define INS_XOR_REG 0xC4
|
||||
#define INS_NAND_IM 0x25
|
||||
#define INS_NAND_REG 0xC5
|
||||
#define INS_CMP_IM 0x26
|
||||
#define INS_CMP_REG 0xC6
|
||||
#define INS_OCPU_NOP 0x90
|
||||
#define INS_OCPU_SEC 0x61
|
||||
#define INS_OCPU_CLC 0x62
|
||||
|
|
|
@ -420,6 +420,34 @@ void ocpu_execute() {
|
|||
write_register(reg, 0, word_value);
|
||||
}
|
||||
break;
|
||||
case INS_CMP_IM:
|
||||
int reg_value = match_register(ocpu_fetch_byte());
|
||||
value = ocpu_fetch_byte();
|
||||
if (reg_value == value) {
|
||||
ocpu.ZF = 1;
|
||||
ocpu.CF = 0;
|
||||
} else if (reg_value < value) {
|
||||
ocpu.ZF = 0;
|
||||
ocpu.CF = 1;
|
||||
} else {
|
||||
ocpu.ZF = 0;
|
||||
ocpu.CF = 0;
|
||||
}
|
||||
break;
|
||||
case INS_CMP_REG:
|
||||
int reg1_value = match_register(ocpu_fetch_byte());
|
||||
int reg2_value = match_register(ocpu_fetch_byte());
|
||||
if (reg1_value == reg2_value) {
|
||||
ocpu.ZF = 1;
|
||||
ocpu.CF = 0;
|
||||
} else if (reg1_value < reg2_value) {
|
||||
ocpu.ZF = 0;
|
||||
ocpu.CF = 1;
|
||||
} else {
|
||||
ocpu.ZF = 0;
|
||||
ocpu.CF = 0;
|
||||
}
|
||||
break;
|
||||
case INS_OCPU_NOP:
|
||||
break;
|
||||
case INS_OCPU_SEC:
|
||||
|
|
Loading…
Reference in New Issue