Merge branch 'master' into forth

This commit is contained in:
Jeremiah Orians 2016-10-29 14:52:56 -04:00
commit c3e1b423ba
No known key found for this signature in database
GPG Key ID: 7457821534D2ACCD
1 changed files with 26 additions and 9 deletions

View File

@ -1298,11 +1298,14 @@ void PUSHPC(struct lilith* vm, struct Instruction* c)
void POPPC(struct lilith* vm, struct Instruction* c) void POPPC(struct lilith* vm, struct Instruction* c)
{ {
/* Update our index */
vm->reg[c->reg0] = vm->reg[c->reg0] - 4;
/* Read in the new PC */ /* Read in the new PC */
vm->ip = readin_Reg(vm, vm->reg[c->reg0]); vm->ip = readin_Reg(vm, vm->reg[c->reg0]);
/* Update our index */ /* Clear memory where PC was */
vm->reg[c->reg0] = vm->reg[c->reg0] - 4; writeout_Reg(vm, vm->reg[c->reg0], 0);
} }
void ADDI(struct lilith* vm, struct Instruction* c) void ADDI(struct lilith* vm, struct Instruction* c)
@ -1883,45 +1886,59 @@ void PUSH32(struct lilith* vm, struct Instruction* c)
} }
void POPR(struct lilith* vm, struct Instruction* c) void POPR(struct lilith* vm, struct Instruction* c)
{ {
uint32_t tmp;
vm->reg[c->reg1] = vm->reg[c->reg1] - 4; vm->reg[c->reg1] = vm->reg[c->reg1] - 4;
vm->reg[c->reg0] = readin_Reg(vm, vm->reg[c->reg1]); tmp = readin_Reg(vm, vm->reg[c->reg1]);
writeout_Reg(vm, vm->reg[c->reg1], 0); writeout_Reg(vm, vm->reg[c->reg1], 0);
vm->reg[c->reg0] = tmp;
} }
void POP8(struct lilith* vm, struct Instruction* c) void POP8(struct lilith* vm, struct Instruction* c)
{ {
int8_t tmp;
vm->reg[c->reg1] = vm->reg[c->reg1] - 1; vm->reg[c->reg1] = vm->reg[c->reg1] - 1;
vm->reg[c->reg0] = readin_byte(vm, vm->reg[c->reg1], true); tmp = readin_byte(vm, vm->reg[c->reg1], true);
writeout_byte(vm, vm->reg[c->reg1], 0); writeout_byte(vm, vm->reg[c->reg1], 0);
vm->reg[c->reg0] = tmp;
} }
void POPU8(struct lilith* vm, struct Instruction* c) void POPU8(struct lilith* vm, struct Instruction* c)
{ {
uint8_t tmp;
vm->reg[c->reg1] = vm->reg[c->reg1] - 1; vm->reg[c->reg1] = vm->reg[c->reg1] - 1;
vm->reg[c->reg0] = readin_byte(vm, vm->reg[c->reg1], false); tmp = readin_byte(vm, vm->reg[c->reg1], false);
writeout_byte(vm, vm->reg[c->reg1], 0); writeout_byte(vm, vm->reg[c->reg1], 0);
vm->reg[c->reg0] = tmp;
} }
void POP16(struct lilith* vm, struct Instruction* c) void POP16(struct lilith* vm, struct Instruction* c)
{ {
int16_t tmp;
vm->reg[c->reg1] = vm->reg[c->reg1] - 2; vm->reg[c->reg1] = vm->reg[c->reg1] - 2;
vm->reg[c->reg0] = readin_doublebyte(vm, vm->reg[c->reg1], true); tmp = readin_doublebyte(vm, vm->reg[c->reg1], true);
writeout_doublebyte(vm, vm->reg[c->reg1], 0); writeout_doublebyte(vm, vm->reg[c->reg1], 0);
vm->reg[c->reg0] = tmp;
} }
void POPU16(struct lilith* vm, struct Instruction* c) void POPU16(struct lilith* vm, struct Instruction* c)
{ {
uint16_t tmp;
vm->reg[c->reg1] = vm->reg[c->reg1] - 2; vm->reg[c->reg1] = vm->reg[c->reg1] - 2;
vm->reg[c->reg0] = readin_doublebyte(vm, vm->reg[c->reg1], false); tmp = readin_doublebyte(vm, vm->reg[c->reg1], false);
writeout_doublebyte(vm, vm->reg[c->reg1], 0); writeout_doublebyte(vm, vm->reg[c->reg1], 0);
vm->reg[c->reg0] = tmp;
} }
void POP32(struct lilith* vm, struct Instruction* c) void POP32(struct lilith* vm, struct Instruction* c)
{ {
int32_t tmp;
vm->reg[c->reg1] = vm->reg[c->reg1] - 4; vm->reg[c->reg1] = vm->reg[c->reg1] - 4;
vm->reg[c->reg0] = readin_Reg(vm, vm->reg[c->reg1]); tmp = readin_Reg(vm, vm->reg[c->reg1]);
writeout_Reg(vm, vm->reg[c->reg1], 0); writeout_Reg(vm, vm->reg[c->reg1], 0);
vm->reg[c->reg0] = tmp;
} }
void POPU32(struct lilith* vm, struct Instruction* c) void POPU32(struct lilith* vm, struct Instruction* c)
{ {
uint32_t tmp;
vm->reg[c->reg1] = vm->reg[c->reg1] - 4; vm->reg[c->reg1] = vm->reg[c->reg1] - 4;
vm->reg[c->reg0] = readin_Reg(vm, vm->reg[c->reg1]); tmp = readin_Reg(vm, vm->reg[c->reg1]);
writeout_Reg(vm, vm->reg[c->reg1], 0); writeout_Reg(vm, vm->reg[c->reg1], 0);
vm->reg[c->reg0] = tmp;
} }
void ANDI(struct lilith* vm, struct Instruction* c) void ANDI(struct lilith* vm, struct Instruction* c)