struct / union in initializer, RFE #901.
[sdcc.git] / sdcc / support / regression / tests / bug-3406.c
blob691a37e02208a717439e6db7522892750710c017
1 /* bug-3406.c
2 A bug in z80 subtraction codegen attempting to use iyl as right operand even on argets where this is not possible (triggering an assettion in codegen).
3 */
5 #include <testfwk.h>
7 #pragma disable_warning 85
9 #ifndef __SDCC_z80
10 #define __banked
11 #endif
13 // GPL Version 2.0
14 #include <stdint.h>
15 uint8_t KeyMenuWait();
17 ///< Show product menu
18 uint16_t SelectAmount(uint16_t amount, uint8_t step, const char *post) __banked {
20 char text[8];
22 for( ;; ) {
24 *text = 0;
26 uint8_t key = KeyMenuWait();
28 switch( key ) {
30 // More
31 case 0:
32 if ( amount < 1000 ) amount += step;
33 break;
35 // Less
36 case 1:
37 if ( amount > step ) amount -= step;
38 break;
40 case 2:
41 case 3:
42 return 0; // cancel
44 case 4:
45 case 5:
46 return amount;
51 void testBug(void) {
52 ASSERT(SelectAmount(0, 1, 0) == 0);
55 uint8_t KeyMenuWait() {
56 static uint8_t i;
57 return i++;
60 #ifdef __SDCC_z80
61 void dummy (void) __naked
63 __asm
64 get_bank::
65 set_bank::
66 ret
67 __endasm;
69 #endif