ocpu: Add NOT instruction

This commit is contained in:
g1n 2022-04-20 15:47:18 +03:00
parent 84305fe0fb
commit 05914bb508
Signed by: g1n
GPG Key ID: 8D352193D65D4E2C
2 changed files with 21 additions and 10 deletions

View File

@ -48,16 +48,17 @@
#define INS_DIV_REG 0xB4
#define INS_INC 0x15
#define INS_DEC 0x16
#define INS_AND_IM 0x20
#define INS_AND_REG 0xC0
#define INS_OR_IM 0x21
#define INS_OR_REG 0xC1
#define INS_NOR_IM 0x22
#define INS_NOR_REG 0xC2
#define INS_XOR_IM 0x23
#define INS_XOR_REG 0xC3
#define INS_NAND_IM 0x24
#define INS_NAND_REG 0xC4
#define INS_NOT 0x20
#define INS_AND_IM 0x21
#define INS_AND_REG 0xC1
#define INS_OR_IM 0x22
#define INS_OR_REG 0xC2
#define INS_NOR_IM 0x23
#define INS_NOR_REG 0xC3
#define INS_XOR_IM 0x24
#define INS_XOR_REG 0xC4
#define INS_NAND_IM 0x25
#define INS_NAND_REG 0xC5
#define INS_OCPU_NOP 0x90
#define INS_OCPU_SEC 0x61
#define INS_OCPU_CLC 0x62

View File

@ -350,6 +350,16 @@ void ocpu_execute() {
write_register(reg, 0, word_value);
}
break;
case INS_NOT:
reg = ocpu_fetch_byte();
if (!is_word_reg(reg)) {
value = ~(match_register(reg));
write_register(reg, value, 0);
} else {
word_value = ~(match_register(reg));
write_register(reg, 0, word_value);
}
break;
case INS_AND_IM:
reg = ocpu_fetch_byte();
if (!is_word_reg(reg)) {