From a4ba2403fe4ff27679e77962e5a2a6ea96c07795 Mon Sep 17 00:00:00 2001 From: Stephen Heumann Date: Tue, 28 Mar 2023 18:52:14 -0500 Subject: [PATCH] Call atexit functions with correct data bank in large memory model Previously, the functions registered with atexit() would be called with data bank corresponding to the blank segment, which is correct in the small memory model but not necessarily in the large memory model. This could cause memory corruption or misbehavior for certain operations accessing global variables. --- cc.asm | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/cc.asm b/cc.asm index 5b9bf44..d0301bc 100644 --- a/cc.asm +++ b/cc.asm @@ -522,10 +522,7 @@ ptr equ 3 pointer to exit routines ; ; Set up our stack frame ; - phb - phk - plb - ph4 ~ExitList set up our stack frame + ph4 >~ExitList set up our stack frame phd tsc tcd @@ -574,7 +571,6 @@ lb3 lda >stderr+6 while there is a next file lb4 pld return pla pla - plb rts end @@ -592,10 +588,7 @@ ptr equ 3 pointer to exit routines ; ; Set up our stack frame ; - phb - phk - plb - ph4 ~QuickExitList set up our stack frame + ph4 >~QuickExitList set up our stack frame phd tsc tcd @@ -632,7 +625,6 @@ lb2 ldy #2 dereference the pointer lb3 pld return pla pla - plb rts end