Incorporated Additional Push and Pop instructions
This commit is contained in:
parent
918dc95bdb
commit
da69a3c18b
|
@ -268,6 +268,17 @@ void assemble(struct Token* p)
|
|||
setExpression(p, "MOVE", "090005", 4);
|
||||
setExpression(p, "BRANCH", "090100", 4);
|
||||
setExpression(p, "CALL", "090101", 4);
|
||||
setExpression(p, "PUSHR", "090200", 4);
|
||||
setExpression(p, "PUSH8", "090201", 4);
|
||||
setExpression(p, "PUSH16", "090202", 4);
|
||||
setExpression(p, "PUSH32", "090203", 4);
|
||||
setExpression(p, "POPR", "090280", 4);
|
||||
setExpression(p, "POP8", "090281", 4);
|
||||
setExpression(p, "POPU8", "090282", 4);
|
||||
setExpression(p, "POP16", "090283", 4);
|
||||
setExpression(p, "POPU16", "090284", 4);
|
||||
setExpression(p, "POP32", "090285", 4);
|
||||
setExpression(p, "POPU32", "090286", 4);
|
||||
|
||||
/* 1OP Group */
|
||||
setExpression(p, "READPC", "0D00000", 4);
|
||||
|
|
|
@ -552,6 +552,61 @@ void decode_Integer_2OP(struct Instruction* c)
|
|||
strncpy(Name, "CALL", 19);
|
||||
break;
|
||||
}
|
||||
case 0x0200: /* PUSHR */
|
||||
{
|
||||
strncpy(Name, "PUSHR", 19);
|
||||
break;
|
||||
}
|
||||
case 0x0201: /* PUSH8 */
|
||||
{
|
||||
strncpy(Name, "PUSH8", 19);
|
||||
break;
|
||||
}
|
||||
case 0x0202: /* PUSH16 */
|
||||
{
|
||||
strncpy(Name, "PUSH16", 19);
|
||||
break;
|
||||
}
|
||||
case 0x0203: /* PUSH32 */
|
||||
{
|
||||
strncpy(Name, "PUSH32", 19);
|
||||
break;
|
||||
}
|
||||
case 0x0280: /* POPR */
|
||||
{
|
||||
strncpy(Name, "POPR", 19);
|
||||
break;
|
||||
}
|
||||
case 0x0281: /* POP8 */
|
||||
{
|
||||
strncpy(Name, "POP8", 19);
|
||||
break;
|
||||
}
|
||||
case 0x0282: /* POPU8 */
|
||||
{
|
||||
strncpy(Name, "POPU8", 19);
|
||||
break;
|
||||
}
|
||||
case 0x0283: /* POP16 */
|
||||
{
|
||||
strncpy(Name, "POP16", 19);
|
||||
break;
|
||||
}
|
||||
case 0x0284: /* POPU16 */
|
||||
{
|
||||
strncpy(Name, "POPU16", 19);
|
||||
break;
|
||||
}
|
||||
case 0x0285: /* POP32 */
|
||||
{
|
||||
strncpy(Name, "POP32", 19);
|
||||
break;
|
||||
}
|
||||
case 0x0286: /* POPU32 */
|
||||
{
|
||||
strncpy(Name, "POPU32", 19);
|
||||
break;
|
||||
}
|
||||
default: /* Unknown 2OP*/
|
||||
{
|
||||
break;
|
||||
|
|
|
@ -218,10 +218,28 @@
|
|||
| 09 01 00 ab | BRANCH a b | MEM[b] = PC; PC = a |
|
||||
| 09 01 01 ab | CALL a b | MEM[b] = PC; b = b + (register size in bytes); PC = a |
|
||||
|
||||
**** Stack group
|
||||
| Hex | Name | Comment |
|
||||
|-------------+------------+-----------------------------------------------------------|
|
||||
| 09 02 00 ab | PUSHR a b | MEM[b] = a; b = b + (register size in bytes) |
|
||||
| 09 02 01 ab | PUSH8 a b | MEM[b] = bottom_8_bits(a); b = b + 1 |
|
||||
| 09 02 02 ab | PUSH16 a b | MEM[b] = bottome_16_bits(a); b = b + 2 |
|
||||
| 09 02 03 ab | PUSH32 a b | MEM[b] = bottome_32_bits(a); b = b + 4 |
|
||||
| 09 02 04 xx | Reserved | |
|
||||
| ... | Reserved | |
|
||||
| 09 02 7F xx | Reserved | |
|
||||
| 09 02 80 ab | POPR a b | a = MEM[b]; MEM[b] = 0; b = b - (register size in bytes) |
|
||||
| 09 02 81 ab | POP8 a b | a = MEM[b] (signed); MEM[b] = 0; b = b - 1 |
|
||||
| 09 02 82 ab | POPU8 a b | a = MEM[b] (unsigned); MEM[b] = 0; b = b - 1 |
|
||||
| 09 02 83 ab | POP16 a b | a = MEM[b] (signed); MEM[b] = 0; b = b - 2 |
|
||||
| 09 02 84 ab | POPU16 a b | a = MEM[b] (unsigned); MEM[b] = 0; b = b - 2 |
|
||||
| 09 02 85 ab | POP32 a b | a = MEM[b] (signed); MEM[b] = 0; b = b - 4 |
|
||||
| 09 02 86 ab | POPU32 a b | a = MEM[b] (signed); MEM[b] = 0; b = b - 4 |
|
||||
|
||||
**** Reserved Block 1
|
||||
| Hex | Name |
|
||||
|-------------+----------|
|
||||
| 09 01 02 xx | Reserved |
|
||||
| 09 02 87 xx | Reserved |
|
||||
| ... | Reserved |
|
||||
| 09 FF FF xx | Reserved |
|
||||
|
||||
|
|
12
vm.h
12
vm.h
|
@ -203,6 +203,18 @@ 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 PUSHR(struct lilith* vm, struct Instruction* c);
|
||||
void PUSH8(struct lilith* vm, struct Instruction* c);
|
||||
void PUSH16(struct lilith* vm, struct Instruction* c);
|
||||
void PUSH32(struct lilith* vm, struct Instruction* c);
|
||||
void POPR(struct lilith* vm, struct Instruction* c);
|
||||
void POP8(struct lilith* vm, struct Instruction* c);
|
||||
void POPU8(struct lilith* vm, struct Instruction* c);
|
||||
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);
|
||||
|
||||
|
||||
/* Prototypes for functions in vm_decode.c*/
|
||||
struct lilith* create_vm(size_t size);
|
||||
|
|
99
vm_decode.c
99
vm_decode.c
|
@ -1026,6 +1026,105 @@ bool eval_2OP_Int(struct lilith* vm, struct Instruction* c)
|
|||
CALL(vm, c);
|
||||
break;
|
||||
}
|
||||
case 0x0200: /* PUSHR */
|
||||
{
|
||||
#ifdef DEBUG
|
||||
strncpy(Name, "PUSHR", 19);
|
||||
#endif
|
||||
|
||||
PUSHR(vm, c);
|
||||
break;
|
||||
}
|
||||
case 0x0201: /* PUSH8 */
|
||||
{
|
||||
#ifdef DEBUG
|
||||
strncpy(Name, "PUSH8", 19);
|
||||
#endif
|
||||
|
||||
PUSH8(vm, c);
|
||||
break;
|
||||
}
|
||||
case 0x0202: /* PUSH16 */
|
||||
{
|
||||
#ifdef DEBUG
|
||||
strncpy(Name, "PUSH16", 19);
|
||||
#endif
|
||||
|
||||
PUSH16(vm, c);
|
||||
break;
|
||||
}
|
||||
case 0x0203: /* PUSH32 */
|
||||
{
|
||||
#ifdef DEBUG
|
||||
strncpy(Name, "PUSH32", 19);
|
||||
#endif
|
||||
|
||||
PUSH32(vm, c);
|
||||
break;
|
||||
}
|
||||
case 0x0280: /* POPR */
|
||||
{
|
||||
#ifdef DEBUG
|
||||
strncpy(Name, "POPR", 19);
|
||||
#endif
|
||||
|
||||
POPR(vm, c);
|
||||
break;
|
||||
}
|
||||
case 0x0281: /* POP8 */
|
||||
{
|
||||
#ifdef DEBUG
|
||||
strncpy(Name, "POP8", 19);
|
||||
#endif
|
||||
|
||||
POP8(vm, c);
|
||||
break;
|
||||
}
|
||||
case 0x0282: /* POPU8 */
|
||||
{
|
||||
#ifdef DEBUG
|
||||
strncpy(Name, "POPU8", 19);
|
||||
#endif
|
||||
|
||||
POPU8(vm, c);
|
||||
break;
|
||||
}
|
||||
case 0x0283: /* POP16 */
|
||||
{
|
||||
#ifdef DEBUG
|
||||
strncpy(Name, "POP16", 19);
|
||||
#endif
|
||||
|
||||
POP16(vm, c);
|
||||
break;
|
||||
}
|
||||
case 0x0284: /* POPU16 */
|
||||
{
|
||||
#ifdef DEBUG
|
||||
strncpy(Name, "POPU16", 19);
|
||||
#endif
|
||||
|
||||
POPU16(vm, c);
|
||||
break;
|
||||
}
|
||||
case 0x0285: /* POP32 */
|
||||
{
|
||||
#ifdef DEBUG
|
||||
strncpy(Name, "POP32", 19);
|
||||
#endif
|
||||
|
||||
POP32(vm, c);
|
||||
break;
|
||||
}
|
||||
case 0x0286: /* POPU32 */
|
||||
{
|
||||
#ifdef DEBUG
|
||||
strncpy(Name, "POPU32", 19);
|
||||
#endif
|
||||
|
||||
POPU32(vm, c);
|
||||
break;
|
||||
}
|
||||
default: return true;
|
||||
}
|
||||
#ifdef DEBUG
|
||||
|
|
|
@ -1858,3 +1858,66 @@ void CMPSKIPU_L(struct lilith* vm, struct Instruction* c)
|
|||
vm->ip = vm->ip + 4;
|
||||
}
|
||||
}
|
||||
|
||||
void PUSHR(struct lilith* vm, struct Instruction* c)
|
||||
{
|
||||
writeout_Reg(vm, vm->reg[c->reg1], vm->reg[c->reg0]);
|
||||
vm->reg[c->reg1] = vm->reg[c->reg1] + 4;
|
||||
}
|
||||
void PUSH8(struct lilith* vm, struct Instruction* c)
|
||||
{
|
||||
writeout_byte(vm, vm->reg[c->reg1] , vm->reg[c->reg0]);
|
||||
vm->reg[c->reg1] = vm->reg[c->reg1] + 1;
|
||||
}
|
||||
void PUSH16(struct lilith* vm, struct Instruction* c)
|
||||
{
|
||||
writeout_doublebyte(vm, vm->reg[c->reg1] , vm->reg[c->reg0]);
|
||||
vm->reg[c->reg1] = vm->reg[c->reg1] + 2;
|
||||
}
|
||||
void PUSH32(struct lilith* vm, struct Instruction* c)
|
||||
{
|
||||
writeout_Reg(vm, vm->reg[c->reg1] , vm->reg[c->reg0]);
|
||||
vm->reg[c->reg1] = vm->reg[c->reg1] + 4;
|
||||
}
|
||||
void POPR(struct lilith* vm, struct Instruction* c)
|
||||
{
|
||||
vm->reg[c->reg1] = vm->reg[c->reg1] - 4;
|
||||
vm->reg[c->reg0] = readin_Reg(vm, vm->reg[c->reg1]);
|
||||
writeout_Reg(vm, vm->reg[c->reg1], 0);
|
||||
}
|
||||
void POP8(struct lilith* vm, struct Instruction* c)
|
||||
{
|
||||
vm->reg[c->reg1] = vm->reg[c->reg1] - 1;
|
||||
vm->reg[c->reg0] = readin_byte(vm, vm->reg[c->reg1], true);
|
||||
writeout_byte(vm, vm->reg[c->reg1], 0);
|
||||
}
|
||||
void POPU8(struct lilith* vm, struct Instruction* c)
|
||||
{
|
||||
vm->reg[c->reg1] = vm->reg[c->reg1] - 1;
|
||||
vm->reg[c->reg0] = readin_byte(vm, vm->reg[c->reg1], false);
|
||||
writeout_byte(vm, vm->reg[c->reg1], 0);
|
||||
}
|
||||
void POP16(struct lilith* vm, struct Instruction* c)
|
||||
{
|
||||
vm->reg[c->reg1] = vm->reg[c->reg1] - 2;
|
||||
vm->reg[c->reg0] = readin_doublebyte(vm, vm->reg[c->reg1], true);
|
||||
writeout_doublebyte(vm, vm->reg[c->reg1], 0);
|
||||
}
|
||||
void POPU16(struct lilith* vm, struct Instruction* c)
|
||||
{
|
||||
vm->reg[c->reg1] = vm->reg[c->reg1] - 2;
|
||||
vm->reg[c->reg0] = readin_doublebyte(vm, vm->reg[c->reg1], false);
|
||||
writeout_doublebyte(vm, vm->reg[c->reg1], 0);
|
||||
}
|
||||
void POP32(struct lilith* vm, struct Instruction* c)
|
||||
{
|
||||
vm->reg[c->reg1] = vm->reg[c->reg1] - 4;
|
||||
vm->reg[c->reg0] = readin_Reg(vm, vm->reg[c->reg1]);
|
||||
writeout_Reg(vm, vm->reg[c->reg1], 0);
|
||||
}
|
||||
void POPU32(struct lilith* vm, struct Instruction* c)
|
||||
{
|
||||
vm->reg[c->reg1] = vm->reg[c->reg1] - 4;
|
||||
vm->reg[c->reg0] = readin_Reg(vm, vm->reg[c->reg1]);
|
||||
writeout_Reg(vm, vm->reg[c->reg1], 0);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue