1
0
mirror of https://github.com/cc65/cc65.git synced 2026-04-20 17:20:49 +00:00

Merge pull request #2776 from colinleroy/optimize-incdecsp-further

Further optimize inc/decsp
This commit is contained in:
Bob Andrews
2025-07-10 17:02:32 +02:00
committed by GitHub
3 changed files with 83 additions and 30 deletions
+32
View File
@@ -0,0 +1,32 @@
#include "unittest.h"
int func(int expr)
{
{
int i = 5;
return i;
}
}
static size_t c_sp_before, c_sp_after;
TEST
{
int a = 11;
int b;
__asm__("lda c_sp");
__asm__("ldx c_sp+1");
c_sp_before = __AX__;
b = func(a);
__asm__("lda c_sp");
__asm__("ldx c_sp+1");
c_sp_after = __AX__;
ASSERT_IsTrue(c_sp_before == c_sp_after, "Unexpected stack pointer");
ASSERT_IsTrue(b == 5, "Wrong value for b");
ASSERT_IsTrue(a == 11, "Wrong value for a");
}
ENDTEST