Added code to check the 6502 stack

git-svn-id: svn://svn.cc65.org/cc65/trunk@638 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
cuz
2001-03-20 22:34:08 +00:00
parent fb76e97575
commit 9528c379c1
5 changed files with 61 additions and 30 deletions

View File

@@ -2515,6 +2515,14 @@ void g_space (int space)
void g_cstackcheck (void)
/* Check for a C stack overflow */
{
AddCodeLine ("\tjsr\tcstkchk");
}
void g_stackcheck (void)
/* Check for a stack overflow */
{

View File

@@ -371,6 +371,9 @@ void g_falsejump (unsigned flags, unsigned label);
void g_space (int space);
/* Create or drop space on the stack */
void g_cstackcheck (void);
/* Check for a C stack overflow */
void g_stackcheck (void);
/* Check for a stack overflow */

View File

@@ -42,6 +42,7 @@
#include "codegen.h"
#include "error.h"
#include "funcdesc.h"
#include "global.h"
#include "litpool.h"
#include "locals.h"
#include "scanner.h"
@@ -229,6 +230,11 @@ void NewFunc (SymEntry* Func)
g_usecode ();
g_defgloblabel (Func->Name);
/* If stack cehcking code is requested, emit a call to the helper routine */
if (CheckStack) {
g_stackcheck ();
}
/* Generate function entry code if needed */
g_enter (TypeOf (Func->Type), GetParamSize (CurrentFunc));
@@ -254,7 +260,7 @@ void NewFunc (SymEntry* Func)
RestoreRegVars (0);
Flags = HasVoidReturn (CurrentFunc)? CF_NONE : CF_REG;
g_leave (Flags, 0);
g_leave (Flags, 0);
}
/* Dump literal data created by the function */

View File

@@ -378,7 +378,7 @@ void DeclareLocals (void)
* the stack checking routine if stack checks are enabled.
*/
if (CheckStack && InitialStack != oursp) {
g_stackcheck ();
g_cstackcheck ();
}
}