Make 'pop' operation safe

This commit is contained in:
Dominic Grimm 2023-03-31 14:36:00 +02:00
parent 5b5886a2f2
commit 804da393a8
Signed by: dergrimm
GPG key ID: 12EFFCAEA9E620BF
3 changed files with 9 additions and 0 deletions

View file

@ -131,4 +131,7 @@ return_call_stack_jump:
.std_alu CORE_ALU_GT
tlr CORE_REG_A
.std_cond_jump loop_strings_1
dbg
pop
dbg
.std_stop

View file

@ -2,3 +2,5 @@
." test\n"
." jdsafhjfnjfn\n"
debug drop debug

View file

@ -247,7 +247,11 @@ impl Emulator {
self.reg_sp = self.reg_sp.wrapping_add(1);
}
0x02 => {
let before = self.reg_sp;
self.reg_sp = self.reg_sp.wrapping_sub(1);
if before < self.reg_sp {
self.reg_sp = 0;
}
}
0x03 => {
self.tmp = self.reg_arg;