Implemented bit optimization group and updated assembler, disassembler and M0 definitions to reflect the change
This commit is contained in:
parent
1b545f6806
commit
14c6ea8440
|
@ -314,6 +314,12 @@ void assemble(struct Token* p)
|
|||
setExpression(p, "STORE8", "21", 4);
|
||||
setExpression(p, "STORE16", "22", 4);
|
||||
setExpression(p, "STORE32", "23", 4);
|
||||
setExpression(p, "ANDI", "B0", 4);
|
||||
setExpression(p, "ORI", "B1", 4);
|
||||
setExpression(p, "XORI", "B2", 4);
|
||||
setExpression(p, "NANDI", "B3", 4);
|
||||
setExpression(p, "NORI", "B4", 4);
|
||||
setExpression(p, "XNORI", "B5", 4);
|
||||
setExpression(p, "CMPJUMP.G", "C0", 4);
|
||||
setExpression(p, "CMPJUMP.GE", "C1", 4);
|
||||
setExpression(p, "CMPJUMP.E", "C2", 4);
|
||||
|
|
|
@ -144,6 +144,12 @@ DEFINE STORE 20
|
|||
DEFINE STORE8 21
|
||||
DEFINE STORE16 22
|
||||
DEFINE STORE32 23
|
||||
DEFINE ANDI B0
|
||||
DEFINE ORI B1
|
||||
DEFINE XORI B2
|
||||
DEFINE NANDI B3
|
||||
DEFINE NORI B4
|
||||
DEFINE XNORI B5
|
||||
DEFINE CMPJUMP.G C0
|
||||
DEFINE CMPJUMP.GE C1
|
||||
DEFINE CMPJUMP.E C2
|
||||
|
|
|
@ -826,6 +826,36 @@ void decode_Integer_2OPI(struct Instruction* c)
|
|||
strncpy(Name, "STORE32", 19);
|
||||
break;
|
||||
}
|
||||
case 0xB0: /* ANDI */
|
||||
{
|
||||
strncpy(Name, "ANDI", 19);
|
||||
break;
|
||||
}
|
||||
case 0xB1: /* ORI */
|
||||
{
|
||||
strncpy(Name, "ORI", 19);
|
||||
break;
|
||||
}
|
||||
case 0xB2: /* XORI */
|
||||
{
|
||||
strncpy(Name, "XORI", 19);
|
||||
break;
|
||||
}
|
||||
case 0xB3: /* NANDI */
|
||||
{
|
||||
strncpy(Name, "NANDI", 19);
|
||||
break;
|
||||
}
|
||||
case 0xB4: /* NORI */
|
||||
{
|
||||
strncpy(Name, "NORI", 19);
|
||||
break;
|
||||
}
|
||||
case 0xB5: /* XNORI */
|
||||
{
|
||||
strncpy(Name, "XNORI", 19);
|
||||
break;
|
||||
}
|
||||
case 0xC0: /* CMPJUMP.G */
|
||||
{
|
||||
strncpy(Name, "CMPJUMP.G", 19);
|
||||
|
@ -1243,7 +1273,7 @@ void eval_instruction(struct Instruction* c)
|
|||
break;
|
||||
}
|
||||
case 0x0E ... 0x2B: /* 2OPI */
|
||||
case 0xC0 ... 0xDF:
|
||||
case 0xB0 ... 0xDF:
|
||||
{
|
||||
decode_Integer_2OPI(c);
|
||||
break;
|
||||
|
|
|
@ -528,22 +528,22 @@ DO NOT USE.
|
|||
|
||||
** CMPSKIP Group
|
||||
| Hex | Name | Comment |
|
||||
|-------------+-------------+------------------------------------|
|
||||
| A0 0a ii ii | CMPSKIP.G | a > ii ii ? Skip Next instruction |
|
||||
| A0 1a ii ii | CMPSKIP.GE | a >= ii ii ? Skip Next instruction |
|
||||
| A0 2a ii ii | CMPSKIP.E | a == ii ii ? Skip Next instruction |
|
||||
| A0 3a ii ii | CMPSKIP.NE | a != ii ii ? Skip Next instruction |
|
||||
| A0 4a ii ii | CMPSKIP.LE | a <= ii ii ? Skip Next instruction |
|
||||
| A0 5a ii ii | CMPSKIP.L | a < ii ii ? Skip Next instruction |
|
||||
|-------------+---------------------+------------------------------------|
|
||||
| A0 0a ii ii | CMPSKIP.G a ii ii | a > ii ii ? Skip Next instruction |
|
||||
| A0 1a ii ii | CMPSKIP.GE a ii ii | a >= ii ii ? Skip Next instruction |
|
||||
| A0 2a ii ii | CMPSKIP.E a ii ii | a == ii ii ? Skip Next instruction |
|
||||
| A0 3a ii ii | CMPSKIP.NE a ii ii | a != ii ii ? Skip Next instruction |
|
||||
| A0 4a ii ii | CMPSKIP.LE a ii ii | a <= ii ii ? Skip Next instruction |
|
||||
| A0 5a ii ii | CMPSKIP.L a ii ii | a < ii ii ? Skip Next instruction |
|
||||
| A0 6a ii ii | Reserved | |
|
||||
| ... | Reserved | |
|
||||
| A0 Fa ii ii | Reserved | |
|
||||
| A1 0a ii ii | CMPSKIPU.G | a > ii ii ? Skip Next instruction |
|
||||
| A1 1a ii ii | CMPSKIPU.GE | a >= ii ii ? Skip Next instruction |
|
||||
| A1 0a ii ii | CMPSKIPU.G a ii ii | a > ii ii ? Skip Next instruction |
|
||||
| A1 1a ii ii | CMPSKIPU.GE a ii ii | a >= ii ii ? Skip Next instruction |
|
||||
| A1 2a ii ii | Reserved | |
|
||||
| A1 3a ii ii | Reserved | |
|
||||
| A1 4a ii ii | CMPSKIPU.LE | a <= ii ii ? Skip Next instruction |
|
||||
| A1 5a ii ii | CMPSKIPU.L | a < ii ii ? Skip Next instruction |
|
||||
| A1 4a ii ii | CMPSKIPU.LE a ii ii | a <= ii ii ? Skip Next instruction |
|
||||
| A1 5a ii ii | CMPSKIPU.L a ii ii | a < ii ii ? Skip Next instruction |
|
||||
| A1 6a ii ii | Reserved | |
|
||||
| ... | Reserved | |
|
||||
| A1 Fa ii ii | Reserved | |
|
||||
|
@ -553,28 +553,41 @@ At this time these instructions only produce a warning; but could do anything.
|
|||
DO NOT USE.
|
||||
| Hex | Name |
|
||||
|-------------+----------|
|
||||
| B0 00 00 00 | Reserved |
|
||||
| A2 00 00 00 | Reserved |
|
||||
| ... | Reserved |
|
||||
| BF FF FF FF | Reserved |
|
||||
| AF FF FF FF | Reserved |
|
||||
|
||||
** Bit optimization group
|
||||
| Hex | Name | Comment |
|
||||
|-------------+-----------------+--------------------|
|
||||
| B0 ab ii ii | ANDI a b ii ii | a = b & ii ii |
|
||||
| B1 ab ii ii | ORI a b ii ii | a = b \vert ii ii |
|
||||
| B2 ab ii ii | XORI a b ii ii | a = b XOR ii ii |
|
||||
| B3 ab ii ii | NANDI a b ii ii | a != b && ii ii |
|
||||
| B4 ab ii ii | NORI a b ii ii | a != b \vert ii ii |
|
||||
| B5 ab ii ii | XNORI a b ii ii | a != b XOR ii ii |
|
||||
| B6 00 00 00 | Reserved | |
|
||||
| ... | Reserved | |
|
||||
| BF FF FF FF | Reserved | |
|
||||
|
||||
** CMPJUMP Group
|
||||
| Hex | Name | Comment |
|
||||
|-------------+-------------+-------------------------------------|
|
||||
| C0 ab ii ii | CMPJUMP.G | a > b ? PC = PC + ii ii |
|
||||
| C1 ab ii ii | CMPJUMP.GE | a >= b ? PC = PC + ii ii |
|
||||
| C2 ab ii ii | CMPJUMP.E | a == b ? PC = PC + ii ii |
|
||||
| C3 ab ii ii | CMPJUMP.NE | a != b ? PC = PC + ii ii |
|
||||
| C4 ab ii ii | CMPJUMP.LE | a <= b ? PC = PC + ii ii |
|
||||
| C5 ab ii ii | CMPJUMP.L | a < b ? PC = PC + ii ii |
|
||||
|-------------+-----------------------+-------------------------------------|
|
||||
| C0 ab ii ii | CMPJUMP.G a b ii ii | a > b ? PC = PC + ii ii |
|
||||
| C1 ab ii ii | CMPJUMP.GE a b ii ii | a >= b ? PC = PC + ii ii |
|
||||
| C2 ab ii ii | CMPJUMP.E a b ii ii | a == b ? PC = PC + ii ii |
|
||||
| C3 ab ii ii | CMPJUMP.NE a b ii ii | a != b ? PC = PC + ii ii |
|
||||
| C4 ab ii ii | CMPJUMP.LE a b ii ii | a <= b ? PC = PC + ii ii |
|
||||
| C5 ab ii ii | CMPJUMP.L a b ii ii | a < b ? PC = PC + ii ii |
|
||||
| C6 ab ii ii | Reserved | |
|
||||
| ... | Reserved | |
|
||||
| CF ab ii ii | Reserved | |
|
||||
| D0 ab ii ii | CMPJUMPU.G | a > b ? PC = PC + ii ii (unsigned) |
|
||||
| D1 ab ii ii | CMPJUMPU.GE | a >= b ? PC = PC + ii ii (unsigned) |
|
||||
| D0 ab ii ii | CMPJUMPU.G a b ii ii | a > b ? PC = PC + ii ii (unsigned) |
|
||||
| D1 ab ii ii | CMPJUMPU.GE a b ii ii | a >= b ? PC = PC + ii ii (unsigned) |
|
||||
| D2 ab ii ii | Reserved | |
|
||||
| D3 ab ii ii | Reserved | |
|
||||
| D4 ab ii ii | CMPJUMPU.LE | a <= b ? PC = PC + ii ii (unsigned) |
|
||||
| D5 ab ii ii | CMPJUMPU.L | a < b ? PC = PC + ii ii (unsigned) |
|
||||
| D4 ab ii ii | CMPJUMPU.LE a b ii ii | a <= b ? PC = PC + ii ii (unsigned) |
|
||||
| D5 ab ii ii | CMPJUMPU.L a b ii ii | a < b ? PC = PC + ii ii (unsigned) |
|
||||
| D6 ab ii ii | Reserved | |
|
||||
| ... | Reserved | |
|
||||
| DF ab ii ii | Reserved | |
|
||||
|
|
7
vm.h
7
vm.h
|
@ -214,7 +214,12 @@ void POP16(struct lilith* vm, struct Instruction* c);
|
|||
void POPU16(struct lilith* vm, struct Instruction* c);
|
||||
void POP32(struct lilith* vm, struct Instruction* c);
|
||||
void POPU32(struct lilith* vm, struct Instruction* c);
|
||||
|
||||
void ANDI(struct lilith* vm, struct Instruction* c);
|
||||
void ORI(struct lilith* vm, struct Instruction* c);
|
||||
void XORI(struct lilith* vm, struct Instruction* c);
|
||||
void NANDI(struct lilith* vm, struct Instruction* c);
|
||||
void NORI(struct lilith* vm, struct Instruction* c);
|
||||
void XNORI(struct lilith* vm, struct Instruction* c);
|
||||
|
||||
/* Prototypes for functions in vm_decode.c*/
|
||||
struct lilith* create_vm(size_t size);
|
||||
|
|
70
vm_decode.c
70
vm_decode.c
|
@ -1453,7 +1453,7 @@ bool eval_2OPI_Int(struct lilith* vm, struct Instruction* c)
|
|||
#endif
|
||||
|
||||
/* 0x0E ... 0x2B */
|
||||
/* 0xC0 ... 0xDF */
|
||||
/* 0xB0 ... 0xDF */
|
||||
switch(c->raw0)
|
||||
{
|
||||
case 0x0E: /* ADDI */
|
||||
|
@ -1643,6 +1643,72 @@ bool eval_2OPI_Int(struct lilith* vm, struct Instruction* c)
|
|||
STORE32(vm, c);
|
||||
break;
|
||||
}
|
||||
case 0xB0: /* ANDI */
|
||||
{
|
||||
#ifdef DEBUG
|
||||
strncpy(Name, "ANDI", 19);
|
||||
#elif TRACE
|
||||
record_trace("ANDI");
|
||||
#endif
|
||||
|
||||
ANDI(vm, c);
|
||||
break;
|
||||
}
|
||||
case 0xB1: /* ORI */
|
||||
{
|
||||
#ifdef DEBUG
|
||||
strncpy(Name, "ORI", 19);
|
||||
#elif TRACE
|
||||
record_trace("ORI");
|
||||
#endif
|
||||
|
||||
ORI(vm, c);
|
||||
break;
|
||||
}
|
||||
case 0xB2: /* XORI */
|
||||
{
|
||||
#ifdef DEBUG
|
||||
strncpy(Name, "XORI", 19);
|
||||
#elif TRACE
|
||||
record_trace("XORI");
|
||||
#endif
|
||||
|
||||
XORI(vm, c);
|
||||
break;
|
||||
}
|
||||
case 0xB3: /* NANDI */
|
||||
{
|
||||
#ifdef DEBUG
|
||||
strncpy(Name, "NANDI", 19);
|
||||
#elif TRACE
|
||||
record_trace("NANDI");
|
||||
#endif
|
||||
|
||||
NANDI(vm, c);
|
||||
break;
|
||||
}
|
||||
case 0xB4: /* NORI */
|
||||
{
|
||||
#ifdef DEBUG
|
||||
strncpy(Name, "NORI", 19);
|
||||
#elif TRACE
|
||||
record_trace("NORI");
|
||||
#endif
|
||||
|
||||
NORI(vm, c);
|
||||
break;
|
||||
}
|
||||
case 0xB5: /* XNORI */
|
||||
{
|
||||
#ifdef DEBUG
|
||||
strncpy(Name, "XNORI", 19);
|
||||
#elif TRACE
|
||||
record_trace("XNORI");
|
||||
#endif
|
||||
|
||||
XNORI(vm, c);
|
||||
break;
|
||||
}
|
||||
case 0xC0: /* CMPJUMP.G */
|
||||
{
|
||||
#ifdef DEBUG
|
||||
|
@ -2327,7 +2393,7 @@ void eval_instruction(struct lilith* vm, struct Instruction* current)
|
|||
break;
|
||||
}
|
||||
case 0x0E ... 0x2B: /* Integer 2OPI */
|
||||
case 0xC0 ... 0xDF:
|
||||
case 0xB0 ... 0xDF:
|
||||
{
|
||||
decode_2OPI(current);
|
||||
invalid = eval_2OPI_Int(vm, current);
|
||||
|
|
|
@ -1923,3 +1923,33 @@ void POPU32(struct lilith* vm, struct Instruction* c)
|
|||
vm->reg[c->reg0] = readin_Reg(vm, vm->reg[c->reg1]);
|
||||
writeout_Reg(vm, vm->reg[c->reg1], 0);
|
||||
}
|
||||
|
||||
void ANDI(struct lilith* vm, struct Instruction* c)
|
||||
{
|
||||
vm->reg[c->reg0] = vm->reg[c->reg1] & c->raw_Immediate;
|
||||
}
|
||||
|
||||
void ORI(struct lilith* vm, struct Instruction* c)
|
||||
{
|
||||
vm->reg[c->reg0] = vm->reg[c->reg1] | c->raw_Immediate;
|
||||
}
|
||||
|
||||
void XORI(struct lilith* vm, struct Instruction* c)
|
||||
{
|
||||
vm->reg[c->reg0] = vm->reg[c->reg1] ^ c->raw_Immediate;
|
||||
}
|
||||
|
||||
void NANDI(struct lilith* vm, struct Instruction* c)
|
||||
{
|
||||
vm->reg[c->reg0] = ~(vm->reg[c->reg1] & c->raw_Immediate);
|
||||
}
|
||||
|
||||
void NORI(struct lilith* vm, struct Instruction* c)
|
||||
{
|
||||
vm->reg[c->reg0] = ~(vm->reg[c->reg1] | c->raw_Immediate);
|
||||
}
|
||||
|
||||
void XNORI(struct lilith* vm, struct Instruction* c)
|
||||
{
|
||||
vm->reg[c->reg0] = ~(vm->reg[c->reg1] ^ c->raw_Immediate);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue