Lo stack non può andare sotto zero

This commit is contained in:
Giulio De Pasquale 2017-07-08 23:27:38 +02:00
parent 6746d96fd4
commit 16c84948c2

View File

@ -617,6 +617,10 @@ bool VM::execPOOP(void) {
dst = as.code[regs[IP] + 1];
DBG_INFO(("POOP %s\n", getRegName(dst)));
if (regs[SP] - sizeof(uint16_t) < 0) {
DBG_ERROR(("Stack is going below 0!\n"));
return false;
}
regs[SP] -= sizeof(uint16_t);
memcpy(&regs[dst], &as.stack[regs[SP]], sizeof(uint16_t));
return true;