1 /** Check stack restore optimizations for STM8.
2 Should work ok for all other ports as long as enough memory is available for the tests.
3 Check with all levels of optimization (speed, size and balanced).
15 #define OPT_SIZE ({optSize})
18 #pragma opt_code_speed
22 #pragma opt_code_balanced
26 // Test for size = 1 byte
27 // It must assign global variable from input param and return 0
28 // The case for STM8 can be triggered by a local array of size 1 or a local volatile
29 static volatile char globalValue
;
31 stack_restore_test_byte(const char s
)
36 //volatile char dummy;
42 #if !defined(__SDCC_mcs51) && !defined(__SDCC_pdk14) && !defined(__SDCC_pdk15) && !defined(__SDCC_pic14) // Lack of memory
43 #if !( (defined (__SDCC_mos6502) || defined(__SDCC_mos65c02 )) && defined(__SDCC_STACK_AUTO) ) // stack too msall
44 // Test for size = 2 bytes
45 // Big stack needed (>256 bytes)
46 // Should assert ok 256 times
47 // Returns number of cases ok for double check
48 #define stack_restore_test_word test_stack_restore_word
51 stack_restore_test_word(void)
57 for (i
= 0; i
< 256; i
++)
61 for (i
= 0; i
< 256; i
++)
72 testStackRestore(void)
75 ASSERT(stack_restore_test_byte(0x5C) == 0);
76 ASSERT(globalValue
== 0x5C);
78 #ifdef stack_restore_test_word
79 ASSERT(stack_restore_test_word() == 256);