Removed pack/unpack instructions to simplify deployment of VM
This commit is contained in:
parent
e3299acbd2
commit
b7f25ea1d9
|
@ -243,14 +243,6 @@ void assemble(struct Token* p)
|
|||
setExpression(p, "MAXU", "05011", 4);
|
||||
setExpression(p, "MIN", "05012", 4);
|
||||
setExpression(p, "MINU", "05013", 4);
|
||||
setExpression(p, "PACK", "05014", 4);
|
||||
setExpression(p, "UNPACK", "05015", 4);
|
||||
setExpression(p, "PACK8.CO", "05016", 4);
|
||||
setExpression(p, "PACK8U.CO", "05017", 4);
|
||||
setExpression(p, "PACK16.CO", "05018", 4);
|
||||
setExpression(p, "PACK16U.CO", "05019", 4);
|
||||
setExpression(p, "PACK32.CO", "0501A", 4);
|
||||
setExpression(p, "PACK32U.CO", "0501B", 4);
|
||||
setExpression(p, "AND", "05020", 4);
|
||||
setExpression(p, "OR", "05021", 4);
|
||||
setExpression(p, "XOR", "05022", 4);
|
||||
|
|
|
@ -72,14 +72,6 @@ DEFINE MAX 05010
|
|||
DEFINE MAXU 05011
|
||||
DEFINE MIN 05012
|
||||
DEFINE MINU 05013
|
||||
DEFINE PACK 05014
|
||||
DEFINE UNPACK 05015
|
||||
DEFINE PACK8.CO 05016
|
||||
DEFINE PACK8U.CO 05017
|
||||
DEFINE PACK16.CO 05018
|
||||
DEFINE PACK16U.CO 05019
|
||||
DEFINE PACK32.CO 0501A
|
||||
DEFINE PACK32U.CO 0501B
|
||||
DEFINE AND 05020
|
||||
DEFINE OR 05021
|
||||
DEFINE XOR 05022
|
||||
|
|
|
@ -317,43 +317,15 @@ void decode_Integer_3OP(struct Instruction* c)
|
|||
break;
|
||||
}
|
||||
case 0x014: /* PACK */
|
||||
{
|
||||
strncpy(Name, "PACK", 19);
|
||||
break;
|
||||
}
|
||||
case 0x015: /* UNPACK */
|
||||
{
|
||||
strncpy(Name, "UNPACK", 19);
|
||||
break;
|
||||
}
|
||||
case 0x016: /* PACK8.CO */
|
||||
{
|
||||
strncpy(Name, "PACK8.CO", 19);
|
||||
break;
|
||||
}
|
||||
case 0x017: /* PACK8U.CO */
|
||||
{
|
||||
strncpy(Name, "PACK8U.CO", 19);
|
||||
break;
|
||||
}
|
||||
case 0x018: /* PACK16.CO */
|
||||
{
|
||||
strncpy(Name, "PACK16.CO", 19);
|
||||
break;
|
||||
}
|
||||
case 0x019: /* PACK16U.CO */
|
||||
{
|
||||
strncpy(Name, "PACK16.CO", 19);
|
||||
break;
|
||||
}
|
||||
case 0x01A: /* PACK32.CO */
|
||||
{
|
||||
strncpy(Name, "PACK32.CO", 19);
|
||||
break;
|
||||
}
|
||||
case 0x01B: /* PACK32U.CO */
|
||||
{
|
||||
strncpy(Name, "PACK32U.CO", 19);
|
||||
strncpy(Name, "ILLEGAL_INSTRUCTION", 19);
|
||||
break;
|
||||
}
|
||||
case 0x020: /* AND */
|
||||
|
|
|
@ -111,20 +111,14 @@
|
|||
| 05 01 3a bc | MINU a b c | a = MIN(b, c) [unsigned] |
|
||||
|
||||
**** Binary packing group
|
||||
| Hex | Name | Comment |
|
||||
|-------------+------------------+--------------------------------------|
|
||||
| 05 01 4a bc | PACK a b c | a = PACK(b, c) [[./img/pack.gif]] |
|
||||
| 05 01 5a bc | UNPACK a b c | a = UNPACK(b, c) [[./img/unpack.gif]] |
|
||||
| 05 01 6a bc | PACK8.CO a b c | a = PACK(b) c = Overload? [signed] |
|
||||
| 05 01 7a bc | PACK8U.CO a b c | a = PACK(b) c = Overload? [unsigned] |
|
||||
| 05 01 8a bc | PACK16.CO a b c | a = PACK(b) c = Overload? [signed] |
|
||||
| 05 01 9a bc | PACK16U.CO a b c | a = PACK(b) c = Overload? [unsigned] |
|
||||
| 05 01 Aa bc | PACK32.CO a b c | a = PACK(b) c = Overload? [signed] |
|
||||
| 05 01 Ba bc | PACK32U.CO a b c | a = PACK(b) c = Overload? [unsigned] |
|
||||
| 05 01 Ca bc | Reserved | |
|
||||
| 05 01 Da bc | Reserved | |
|
||||
| 05 01 Ex xx | Reserved | |
|
||||
| 05 01 Fx xx | Reserved | |
|
||||
Due to the complexity of building/programming the pack instructions, the have been removed to simplify the porting task.
|
||||
The Opcodes will be preserved should we wish in the future to be binary compatable with the Knight specification.
|
||||
|
||||
| Hex | Name | Comment |
|
||||
|-------------+----------+---------|
|
||||
| 05 01 4a bc | Reserved | |
|
||||
| ... | Reserved | |
|
||||
| 05 01 Fx xx | Reserved | |
|
||||
|
||||
**** Logical group
|
||||
| Hex | Name | Comment |
|
||||
|
|
BIN
img/pack.gif
BIN
img/pack.gif
Binary file not shown.
Before Width: | Height: | Size: 4.3 KiB |
BIN
img/unpack.gif
BIN
img/unpack.gif
Binary file not shown.
Before Width: | Height: | Size: 4.2 KiB |
8
vm.h
8
vm.h
|
@ -96,14 +96,6 @@ void MAX(struct lilith* vm, struct Instruction* c);
|
|||
void MAXU(struct lilith* vm, struct Instruction* c);
|
||||
void MIN(struct lilith* vm, struct Instruction* c);
|
||||
void MINU(struct lilith* vm, struct Instruction* c);
|
||||
void PACK(struct lilith* vm, struct Instruction* c);
|
||||
void UNPACK(struct lilith* vm, struct Instruction* c);
|
||||
void PACK8_CO(struct lilith* vm, struct Instruction* c);
|
||||
void PACK8U_CO(struct lilith* vm, struct Instruction* c);
|
||||
void PACK16_CO(struct lilith* vm, struct Instruction* c);
|
||||
void PACK16U_CO(struct lilith* vm, struct Instruction* c);
|
||||
void PACK32_CO(struct lilith* vm, struct Instruction* c);
|
||||
void PACK32U_CO(struct lilith* vm, struct Instruction* c);
|
||||
void AND(struct lilith* vm, struct Instruction* c);
|
||||
void OR(struct lilith* vm, struct Instruction* c);
|
||||
void XOR(struct lilith* vm, struct Instruction* c);
|
||||
|
|
76
vm_decode.c
76
vm_decode.c
|
@ -732,91 +732,21 @@ bool eval_3OP_Int(struct lilith* vm, struct Instruction* c)
|
|||
break;
|
||||
}
|
||||
case 0x014: /* PACK */
|
||||
{
|
||||
#ifdef DEBUG
|
||||
strncpy(Name, "PACK", 19);
|
||||
#elif TRACE
|
||||
record_trace("PACK");
|
||||
#endif
|
||||
|
||||
PACK(vm, c);
|
||||
break;
|
||||
}
|
||||
case 0x015: /* UNPACK */
|
||||
{
|
||||
#ifdef DEBUG
|
||||
strncpy(Name, "UNPACK", 19);
|
||||
#elif TRACE
|
||||
record_trace("UNPACK");
|
||||
#endif
|
||||
|
||||
UNPACK(vm, c);
|
||||
break;
|
||||
}
|
||||
case 0x016: /* PACK8.CO */
|
||||
{
|
||||
#ifdef DEBUG
|
||||
strncpy(Name, "PACK8.CO", 19);
|
||||
#elif TRACE
|
||||
record_trace("PACK8.CO");
|
||||
#endif
|
||||
|
||||
PACK8_CO(vm, c);
|
||||
break;
|
||||
}
|
||||
case 0x017: /* PACK8U.CO */
|
||||
{
|
||||
#ifdef DEBUG
|
||||
strncpy(Name, "PACK8U.CO", 19);
|
||||
#elif TRACE
|
||||
record_trace("PACK8U.CO");
|
||||
#endif
|
||||
|
||||
PACK8U_CO(vm, c);
|
||||
break;
|
||||
}
|
||||
case 0x018: /* PACK16.CO */
|
||||
{
|
||||
#ifdef DEBUG
|
||||
strncpy(Name, "PACK16.CO", 19);
|
||||
#elif TRACE
|
||||
record_trace("PACK16.CO");
|
||||
#endif
|
||||
|
||||
PACK16_CO(vm, c);
|
||||
break;
|
||||
}
|
||||
case 0x019: /* PACK16U.CO */
|
||||
{
|
||||
#ifdef DEBUG
|
||||
strncpy(Name, "PACK16U.CO", 19);
|
||||
#elif TRACE
|
||||
record_trace("PACK16U.CO");
|
||||
#endif
|
||||
|
||||
PACK16U_CO(vm, c);
|
||||
break;
|
||||
}
|
||||
case 0x01A: /* PACK32.CO */
|
||||
{
|
||||
#ifdef DEBUG
|
||||
strncpy(Name, "PACK32.CO", 19);
|
||||
#elif TRACE
|
||||
record_trace("PACK32.CO");
|
||||
#endif
|
||||
|
||||
PACK32_CO(vm, c);
|
||||
break;
|
||||
}
|
||||
case 0x01B: /* PACK32U.CO */
|
||||
{
|
||||
#ifdef DEBUG
|
||||
strncpy(Name, "PACK32U.CO", 19);
|
||||
strncpy(Name, "ILLEGAL INSTRUCTION", 19);
|
||||
#elif TRACE
|
||||
record_trace("PACK32U.CO");
|
||||
record_trace("ILLEGAL_INSTRUCTION");
|
||||
#endif
|
||||
|
||||
PACK32U_CO(vm, c);
|
||||
exit(EXIT_FAILURE);
|
||||
break;
|
||||
}
|
||||
case 0x020: /* AND */
|
||||
|
|
|
@ -903,143 +903,6 @@ void MINU(struct lilith* vm, struct Instruction* c)
|
|||
}
|
||||
}
|
||||
|
||||
void PACK(struct lilith* vm, struct Instruction* c)
|
||||
{
|
||||
uint8_t i;
|
||||
bool bit1, bit2;
|
||||
vm->reg[c->reg0] = 0;
|
||||
|
||||
for(i = 31; i > 0; i = i - 1)
|
||||
{
|
||||
bit1 = (vm->reg[c->reg1] >> i) & 1;
|
||||
bit2 = (vm->reg[c->reg2] >> i) & 1;
|
||||
|
||||
if(bit1)
|
||||
{
|
||||
if(bit2)
|
||||
{
|
||||
vm->reg[c->reg0] = vm->reg[c->reg0] * 2 + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
vm->reg[c->reg0] = vm->reg[c->reg0] * 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void UNPACK(struct lilith* vm, struct Instruction* c)
|
||||
{
|
||||
uint8_t i;
|
||||
bool bit1, bit2;
|
||||
|
||||
vm->reg[c->reg0] = 0;
|
||||
for(i = 0; i < 32; i = i + 1)
|
||||
{
|
||||
bit1 = (vm->reg[c->reg1] >> (31 - i)) & 1;
|
||||
bit2 = (vm->reg[c->reg2] >> (31 - i)) & 1;
|
||||
|
||||
if(bit1)
|
||||
{
|
||||
vm->reg[c->reg0] = vm->reg[c->reg0] * 2 + bit2;
|
||||
}
|
||||
else
|
||||
{
|
||||
vm->reg[c->reg0] = vm->reg[c->reg0] * 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void PACK8_CO(struct lilith* vm, struct Instruction* c)
|
||||
{
|
||||
if(0x7F < (int32_t)(vm->reg[c->reg1]))
|
||||
{
|
||||
/* Saturate in the event of Overflow */
|
||||
vm->reg[c->reg0] = 0x7F;
|
||||
vm->reg[c->reg2] = vm->reg[c->reg2] | Overflow;
|
||||
}
|
||||
else if (-128 > (int32_t)(vm->reg[c->reg1]))
|
||||
{
|
||||
/* Saturate in the event of Underflow */
|
||||
vm->reg[c->reg0] = 0x80;
|
||||
vm->reg[c->reg2] = vm->reg[c->reg2] | Overflow;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Unset Overflow bit if set */
|
||||
vm->reg[c->reg0] = vm->reg[c->reg1];
|
||||
vm->reg[c->reg2] = vm->reg[c->reg2] & ~(Overflow);
|
||||
}
|
||||
}
|
||||
|
||||
void PACK8U_CO(struct lilith* vm, struct Instruction* c)
|
||||
{
|
||||
if(0xFF < vm->reg[c->reg1])
|
||||
{
|
||||
/* Saturate in the event of Overflow */
|
||||
vm->reg[c->reg0] = 0xFF;
|
||||
vm->reg[c->reg2] = vm->reg[c->reg2] | Overflow;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Unset Overflow bit if set */
|
||||
vm->reg[c->reg0] = vm->reg[c->reg1];
|
||||
vm->reg[c->reg2] = vm->reg[c->reg2] & ~(Overflow);
|
||||
}
|
||||
}
|
||||
|
||||
void PACK16_CO(struct lilith* vm, struct Instruction* c)
|
||||
{
|
||||
if(0x7FFF < (int32_t)(vm->reg[c->reg1]))
|
||||
{
|
||||
/* Saturate in the event of Overflow */
|
||||
vm->reg[c->reg0] = 0x7FFF;
|
||||
vm->reg[c->reg2] = vm->reg[c->reg2] | Overflow;
|
||||
}
|
||||
else if (-32768 > (int32_t)(vm->reg[c->reg1]))
|
||||
{
|
||||
/* Saturate in the event of Underflow */
|
||||
vm->reg[c->reg0] = 0x8000;
|
||||
vm->reg[c->reg2] = vm->reg[c->reg2] | Overflow;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Unset Overflow bit if set */
|
||||
vm->reg[c->reg0] = vm->reg[c->reg1];
|
||||
vm->reg[c->reg2] = vm->reg[c->reg2] & ~(Overflow);
|
||||
}
|
||||
}
|
||||
|
||||
void PACK16U_CO(struct lilith* vm, struct Instruction* c)
|
||||
{
|
||||
if(0xFFFF < vm->reg[c->reg1])
|
||||
{
|
||||
/* Saturate in the event of Overflow */
|
||||
vm->reg[c->reg0] = 0xFFFF;
|
||||
vm->reg[c->reg2] = vm->reg[c->reg2] | Overflow;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Unset Overflow bit if set */
|
||||
vm->reg[c->reg0] = vm->reg[c->reg1];
|
||||
vm->reg[c->reg2] = vm->reg[c->reg2] & ~(Overflow);
|
||||
}
|
||||
}
|
||||
|
||||
void PACK32_CO(struct lilith* vm, struct Instruction* c)
|
||||
{
|
||||
/* Unset Overflow bit if set */
|
||||
vm->reg[c->reg0] = vm->reg[c->reg1];
|
||||
vm->reg[c->reg2] = vm->reg[c->reg2] & ~(Overflow);
|
||||
}
|
||||
|
||||
void PACK32U_CO(struct lilith* vm, struct Instruction* c)
|
||||
{
|
||||
/* Unset Overflow bit if set */
|
||||
vm->reg[c->reg0] = vm->reg[c->reg1];
|
||||
vm->reg[c->reg2] = vm->reg[c->reg2] & ~(Overflow);
|
||||
}
|
||||
|
||||
void AND(struct lilith* vm, struct Instruction* c)
|
||||
{
|
||||
vm->reg[c->reg0] = vm->reg[c->reg1] & vm->reg[c->reg2];
|
||||
|
|
Loading…
Reference in New Issue