diff --git a/CHANGELOG.org b/CHANGELOG.org index 8d6d283..5e4374c 100644 --- a/CHANGELOG.org +++ b/CHANGELOG.org @@ -10,6 +10,7 @@ + Revised stage0 Monitor to utilize ANDI and updated the Hex0 version to incorporate the enhancements made previously + Imported CMPSKIP instructions that operate on 2 registers + Corrected CMPJUMP(u) to CMPJUMP(u)I to match current naming scheme for instructions ++ Imported CMPJUMP instructions that operate on 3 registers ** Fixed + Fixed leading char bug in M0 diff --git a/High_level_prototypes/asm.c b/High_level_prototypes/asm.c index b4f6eda..fc728cf 100644 --- a/High_level_prototypes/asm.c +++ b/High_level_prototypes/asm.c @@ -264,6 +264,17 @@ void assemble(struct Token* p) setExpression(p, "STOREX8", "05049", 4); setExpression(p, "STOREX16", "0504A", 4); setExpression(p, "STOREX32", "0504B", 4); + setExpression(p, "CMPJUMP.G", "05050", 4); + setExpression(p, "CMPJUMP.GE", "05051", 4); + setExpression(p, "CMPJUMP.E", "05052", 4); + setExpression(p, "CMPJUMP.NE", "05053", 4); + setExpression(p, "CMPJUMP.LE", "05054", 4); + setExpression(p, "CMPJUMP.L", "05055", 4); + setExpression(p, "CMPJUMPU.G", "05060", 4); + setExpression(p, "CMPJUMPU.GE", "05061", 4); + setExpression(p, "CMPJUMPU.LE", "05064", 4); + setExpression(p, "CMPJUMPU.L", "05065", 4); + /* 2OP Integer Group */ setExpression(p, "NEG", "090000", 4); diff --git a/High_level_prototypes/defs b/High_level_prototypes/defs index 01027c5..6573baa 100644 --- a/High_level_prototypes/defs +++ b/High_level_prototypes/defs @@ -94,6 +94,16 @@ DEFINE STOREX 05048 DEFINE STOREX8 05049 DEFINE STOREX16 0504A DEFINE STOREX32 0504B +DEFINE CMPJUMP.G 05050 +DEFINE CMPJUMP.GE 05051 +DEFINE CMPJUMP.E 05052 +DEFINE CMPJUMP.NE 05053 +DEFINE CMPJUMP.LE 05054 +DEFINE CMPJUMP.L 05055 +DEFINE CMPJUMPU.G 05060 +DEFINE CMPJUMPU.GE 05061 +DEFINE CMPJUMPU.LE 05064 +DEFINE CMPJUMPU.L 05065 # 2OP Integer Group DEFINE NEG 090000 diff --git a/High_level_prototypes/disasm.c b/High_level_prototypes/disasm.c index 7f6087f..bfdec0a 100644 --- a/High_level_prototypes/disasm.c +++ b/High_level_prototypes/disasm.c @@ -485,6 +485,56 @@ void decode_Integer_3OP(struct Instruction* c) strncpy(Name, "STOREX32", 19); break; } + case 0x050: /* CMPJUMP.G */ + { + strncpy(Name, "CMPJUMP.G", 19); + break; + } + case 0x051: /* CMPJUMP.GE */ + { + strncpy(Name, "CMPJUMP.GE", 19); + break; + } + case 0x052: /* CMPJUMP.E */ + { + strncpy(Name, "CMPJUMP.E", 19); + break; + } + case 0x053: /* CMPJUMP.NE */ + { + strncpy(Name, "CMPJUMP.NE", 19); + break; + } + case 0x054: /* CMPJUMP.LE */ + { + strncpy(Name, "CMPJUMP.LE", 19); + break; + } + case 0x055: /* CMPJUMP.L */ + { + strncpy(Name, "CMPJUMP.L", 19); + break; + } + case 0x060: /* CMPJUMPU.G */ + { + strncpy(Name, "CMPJUMPU.G", 19); + break; + } + case 0x061: /* CMPJUMPU.GE */ + { + strncpy(Name, "CMPJUMPU.GE", 19); + break; + } + case 0x064: /* CMPJUMPU.LE */ + { + strncpy(Name, "CMPJUMPU.LE", 19); + break; + } + case 0x065: /* CMPJUMPU.L */ + { + strncpy(Name, "CMPJUMPU.L", 19); + break; + } default: /* Unknown 3OP*/ { break; diff --git a/ISA_HEX_Map.org b/ISA_HEX_Map.org index 55fe32f..fd76168 100644 --- a/ISA_HEX_Map.org +++ b/ISA_HEX_Map.org @@ -176,10 +176,32 @@ | 05 04 Ex xx | Reserved | | | 05 04 Fx xx | Reserved | | +**** CMPJUMP group +| Hex | Name | Comment | +|-------------+-------------------+-----------------| +| 05 05 0a bc | CMPJUMP.G a b c | a > b ? PC = c | +| 05 05 1a bc | CMPJUMP.GE a b c | a >= b ? PC = c | +| 05 05 2a bc | CMPJUMP.E a b c | a == b ? PC = c | +| 05 05 3a bc | CMPJUMP.NE a b c | a != b ? PC = c | +| 05 05 4a bc | CMPJUMP.LE a b c | a <= b ? PC = c | +| 05 05 5a bc | CMPJUMP.L a b c | a < b ? PC = c | +| 05 05 6x xx | Reserved | | +| ... | Reserved | | +| 05 05 Fx xx | Reserved | | +| 05 06 0a bc | CMPJUMPU.G a b c | a > b ? PC = c | +| 05 06 1a bc | CMPJUMPU.GE a b c | a >= b ? PC = c | +| 05 06 2a bc | Reserved | | +| 05 06 3a bc | Reserved | | +| 05 06 4a bc | CMPJUMPU.LE a b c | a <= b ? PC = c | +| 05 06 5a bc | CMPJUMPU.L a b c | a < b ? PC = c | +| 05 06 6x xx | Reserved | | +| ... | Reserved | | +| 05 06 Fx xx | Reserved | | + **** Reserved group 2 | Hex | Name | |-------------+----------| -| 05 05 0x xx | Reserved | +| 05 07 0x xx | Reserved | | ... | Reserved | | 05 FF Fx xx | Reserved | diff --git a/vm.h b/vm.h index c88d7d5..23988f8 100644 --- a/vm.h +++ b/vm.h @@ -231,7 +231,16 @@ void CMPSKIPU_G(struct lilith* vm, struct Instruction* c); void CMPSKIPU_GE(struct lilith* vm, struct Instruction* c); void CMPSKIPU_LE(struct lilith* vm, struct Instruction* c); void CMPSKIPU_L(struct lilith* vm, struct Instruction* c); - +void CMPJUMP_G(struct lilith* vm, struct Instruction* c); +void CMPJUMP_GE(struct lilith* vm, struct Instruction* c); +void CMPJUMP_E(struct lilith* vm, struct Instruction* c); +void CMPJUMP_NE(struct lilith* vm, struct Instruction* c); +void CMPJUMP_LE(struct lilith* vm, struct Instruction* c); +void CMPJUMP_L(struct lilith* vm, struct Instruction* c); +void CMPJUMPU_G(struct lilith* vm, struct Instruction* c); +void CMPJUMPU_GE(struct lilith* vm, struct Instruction* c); +void CMPJUMPU_LE(struct lilith* vm, struct Instruction* c); +void CMPJUMPU_L(struct lilith* vm, struct Instruction* c); /* Prototypes for functions in vm_decode.c*/ struct lilith* create_vm(size_t size); diff --git a/vm_decode.c b/vm_decode.c index 0359880..5956e33 100644 --- a/vm_decode.c +++ b/vm_decode.c @@ -1106,6 +1106,116 @@ bool eval_3OP_Int(struct lilith* vm, struct Instruction* c) STOREX32(vm, c); break; } + case 0x050: /* CMPJUMP.G */ + { + #ifdef DEBUG + strncpy(Name, "CMPJUMP.G", 19); + #elif TRACE + record_trace("CMPJUMP.G"); + #endif + + CMPJUMP_G(vm, c); + break; + } + case 0x051: /* CMPJUMP.GE */ + { + #ifdef DEBUG + strncpy(Name, "CMPJUMP.GE", 19); + #elif TRACE + record_trace("CMPJUMP.GE"); + #endif + + CMPJUMP_GE(vm, c); + break; + } + case 0x052: /* CMPJUMP.E */ + { + #ifdef DEBUG + strncpy(Name, "CMPJUMP.E", 19); + #elif TRACE + record_trace("CMPJUMP.E"); + #endif + + CMPJUMP_E(vm, c); + break; + } + case 0x053: /* CMPJUMP.NE */ + { + #ifdef DEBUG + strncpy(Name, "CMPJUMP.NE", 19); + #elif TRACE + record_trace("CMPJUMP.NE"); + #endif + + CMPJUMP_NE(vm, c); + break; + } + case 0x054: /* CMPJUMP.LE */ + { + #ifdef DEBUG + strncpy(Name, "CMPJUMP.LE", 19); + #elif TRACE + record_trace("CMPJUMP.LE"); + #endif + + CMPJUMP_LE(vm, c); + break; + } + case 0x055: /* CMPJUMP.L */ + { + #ifdef DEBUG + strncpy(Name, "CMPJUMP.L", 19); + #elif TRACE + record_trace("CMPJUMP.L"); + #endif + + CMPJUMP_L(vm, c); + break; + } + case 0x060: /* CMPJUMPU.G */ + { + #ifdef DEBUG + strncpy(Name, "CMPJUMPU.G", 19); + #elif TRACE + record_trace("CMPJUMPU.G"); + #endif + + CMPJUMPU_G(vm, c); + break; + } + case 0x061: /* CMPJUMPU.GE */ + { + #ifdef DEBUG + strncpy(Name, "CMPJUMPU.GE", 19); + #elif TRACE + record_trace("CMPJUMPU.GE"); + #endif + + CMPJUMPU_GE(vm, c); + break; + } + case 0x064: /* CMPJUMPU.LE */ + { + #ifdef DEBUG + strncpy(Name, "CMPJUMPU.LE", 19); + #elif TRACE + record_trace("CMPJUMPU.LE"); + #endif + + CMPJUMPU_LE(vm, c); + break; + } + case 0x065: /* CMPJUMPU.L */ + { + #ifdef DEBUG + strncpy(Name, "CMPJUMPU.L", 19); + #elif TRACE + record_trace("CMPJUMPU.L"); + #endif + + CMPJUMPU_L(vm, c); + break; + } default: return true; } #ifdef DEBUG diff --git a/vm_instructions.c b/vm_instructions.c index 31bca27..677fdf7 100644 --- a/vm_instructions.c +++ b/vm_instructions.c @@ -1985,11 +1985,7 @@ void CMPSKIP_GE(struct lilith* vm, struct Instruction* c) void CMPSKIP_E(struct lilith* vm, struct Instruction* c) { - int32_t tmp1, tmp2; - tmp1 = (int32_t)(vm->reg[c->reg0]); - tmp2 = (int32_t)(vm->reg[c->reg1]); - - if(tmp1 == tmp2) + if((vm->reg[c->reg0]) == (vm->reg[c->reg1])) { vm->ip = vm->ip + 4; } @@ -1997,11 +1993,7 @@ void CMPSKIP_E(struct lilith* vm, struct Instruction* c) void CMPSKIP_NE(struct lilith* vm, struct Instruction* c) { - int32_t tmp1, tmp2; - tmp1 = (int32_t)(vm->reg[c->reg0]); - tmp2 = (int32_t)(vm->reg[c->reg1]); - - if(tmp1 != tmp2) + if((vm->reg[c->reg0]) != (vm->reg[c->reg1])) { vm->ip = vm->ip + 4; } @@ -2033,7 +2025,7 @@ void CMPSKIP_L(struct lilith* vm, struct Instruction* c) void CMPSKIPU_G(struct lilith* vm, struct Instruction* c) { - if((vm->reg[c->reg0]) > vm->reg[c->reg1]) + if((vm->reg[c->reg0]) > (vm->reg[c->reg1])) { vm->ip = vm->ip + 4; } @@ -2041,7 +2033,7 @@ void CMPSKIPU_G(struct lilith* vm, struct Instruction* c) void CMPSKIPU_GE(struct lilith* vm, struct Instruction* c) { - if((vm->reg[c->reg0]) >= vm->reg[c->reg1]) + if((vm->reg[c->reg0]) >= (vm->reg[c->reg1])) { vm->ip = vm->ip + 4; } @@ -2049,7 +2041,7 @@ void CMPSKIPU_GE(struct lilith* vm, struct Instruction* c) void CMPSKIPU_LE(struct lilith* vm, struct Instruction* c) { - if((vm->reg[c->reg0]) <= vm->reg[c->reg1]) + if((vm->reg[c->reg0]) <= (vm->reg[c->reg1])) { vm->ip = vm->ip + 4; } @@ -2057,8 +2049,100 @@ void CMPSKIPU_LE(struct lilith* vm, struct Instruction* c) void CMPSKIPU_L(struct lilith* vm, struct Instruction* c) { - if((vm->reg[c->reg0]) < vm->reg[c->reg1]) + if((vm->reg[c->reg0]) < (vm->reg[c->reg1])) { vm->ip = vm->ip + 4; } } + +void CMPJUMP_G(struct lilith* vm, struct Instruction* c) +{ + int32_t tmp1, tmp2; + tmp1 = (int32_t)(vm->reg[c->reg0]); + tmp2 = (int32_t)(vm->reg[c->reg1]); + if(tmp1 > tmp2) + { + vm->ip = vm->reg[c->reg2]; + } +} + +void CMPJUMP_GE(struct lilith* vm, struct Instruction* c) +{ + int32_t tmp1, tmp2; + tmp1 = (int32_t)(vm->reg[c->reg0]); + tmp2 = (int32_t)(vm->reg[c->reg1]); + if(tmp1 >= tmp2) + { + vm->ip = vm->reg[c->reg2]; + } +} + +void CMPJUMP_E(struct lilith* vm, struct Instruction* c) +{ + if((vm->reg[c->reg0]) == (vm->reg[c->reg1])) + { + vm->ip = vm->reg[c->reg2]; + } +} + +void CMPJUMP_NE(struct lilith* vm, struct Instruction* c) +{ + if((vm->reg[c->reg0]) != (vm->reg[c->reg1])) + { + vm->ip = vm->reg[c->reg2]; + } +} + +void CMPJUMP_LE(struct lilith* vm, struct Instruction* c) +{ + int32_t tmp1, tmp2; + tmp1 = (int32_t)(vm->reg[c->reg0]); + tmp2 = (int32_t)(vm->reg[c->reg1]); + if(tmp1 <= tmp2) + { + vm->ip = vm->reg[c->reg2]; + } +} + +void CMPJUMP_L(struct lilith* vm, struct Instruction* c) +{ + int32_t tmp1, tmp2; + tmp1 = (int32_t)(vm->reg[c->reg0]); + tmp2 = (int32_t)(vm->reg[c->reg1]); + if(tmp1 < tmp2) + { + vm->ip = vm->reg[c->reg2]; + } +} + +void CMPJUMPU_G(struct lilith* vm, struct Instruction* c) +{ + if((vm->reg[c->reg0]) > (vm->reg[c->reg1])) + { + vm->ip = vm->reg[c->reg2]; + } +} + +void CMPJUMPU_GE(struct lilith* vm, struct Instruction* c) +{ + if((vm->reg[c->reg0]) >= (vm->reg[c->reg1])) + { + vm->ip = vm->reg[c->reg2]; + } +} + +void CMPJUMPU_LE(struct lilith* vm, struct Instruction* c) +{ + if((vm->reg[c->reg0]) <= (vm->reg[c->reg1])) + { + vm->ip = vm->reg[c->reg2]; + } +} + +void CMPJUMPU_L(struct lilith* vm, struct Instruction* c) +{ + if((vm->reg[c->reg0]) < (vm->reg[c->reg1])) + { + vm->ip = vm->reg[c->reg2]; + } +}