Incorporated 3OP CMPJUMP instructions

This commit is contained in:
Jeremiah Orians 2016-10-29 09:52:31 -04:00
parent 1b1b94a121
commit b65c866e75
No known key found for this signature in database
GPG Key ID: 7457821534D2ACCD
8 changed files with 313 additions and 16 deletions

View File

@ -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

View File

@ -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);

View File

@ -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

View File

@ -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;

View File

@ -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 |

11
vm.h
View File

@ -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);

View File

@ -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

View File

@ -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];
}
}