From e8102339d718d0b5cd50010837d81f7b2b35cf50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juhani=20Krekel=C3=A4?= Date: Thu, 18 Aug 2022 14:51:47 +0300 Subject: [PATCH] Add stack underflow detection to popByte in calculator.asm --- calculator.asm | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/calculator.asm b/calculator.asm index 11ce5c2..30bdf8a 100644 --- a/calculator.asm +++ b/calculator.asm @@ -481,6 +481,13 @@ pushByte: popByte: load r0, SP+0 load r1, SP+1 + + load r2, SPStart+0 + load r3, SPStart+1 + brneq r0, r2, popByteNoUnderflow + breq r1, r3, error + +popByteNoUnderflow: cleq r0, r0, decWord store SP+0, r0 store SP+1, r1