Make 'pop' operation safe
This commit is contained in:
parent
5b5886a2f2
commit
804da393a8
3 changed files with 9 additions and 0 deletions
|
@ -131,4 +131,7 @@ return_call_stack_jump:
|
||||||
.std_alu CORE_ALU_GT
|
.std_alu CORE_ALU_GT
|
||||||
tlr CORE_REG_A
|
tlr CORE_REG_A
|
||||||
.std_cond_jump loop_strings_1
|
.std_cond_jump loop_strings_1
|
||||||
|
dbg
|
||||||
|
pop
|
||||||
|
dbg
|
||||||
.std_stop
|
.std_stop
|
||||||
|
|
|
@ -2,3 +2,5 @@
|
||||||
|
|
||||||
." test\n"
|
." test\n"
|
||||||
." jdsafhjfnjfn\n"
|
." jdsafhjfnjfn\n"
|
||||||
|
|
||||||
|
debug drop debug
|
||||||
|
|
|
@ -247,7 +247,11 @@ impl Emulator {
|
||||||
self.reg_sp = self.reg_sp.wrapping_add(1);
|
self.reg_sp = self.reg_sp.wrapping_add(1);
|
||||||
}
|
}
|
||||||
0x02 => {
|
0x02 => {
|
||||||
|
let before = self.reg_sp;
|
||||||
self.reg_sp = self.reg_sp.wrapping_sub(1);
|
self.reg_sp = self.reg_sp.wrapping_sub(1);
|
||||||
|
if before < self.reg_sp {
|
||||||
|
self.reg_sp = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
0x03 => {
|
0x03 => {
|
||||||
self.tmp = self.reg_arg;
|
self.tmp = self.reg_arg;
|
||||||
|
|
Loading…
Reference in a new issue