blob: 691a37e02208a717439e6db7522892750710c017 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
/* bug-3406.c
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).
*/
#include <testfwk.h>
#pragma disable_warning 85
#ifndef __SDCC_z80
#define __banked
#endif
// GPL Version 2.0
#include <stdint.h>
uint8_t KeyMenuWait();
///< Show product menu
uint16_t SelectAmount(uint16_t amount, uint8_t step, const char *post) __banked {
char text[8];
for( ;; ) {
*text = 0;
uint8_t key = KeyMenuWait();
switch( key ) {
// More
case 0:
if ( amount < 1000 ) amount += step;
break;
// Less
case 1:
if ( amount > step ) amount -= step;
break;
case 2:
case 3:
return 0; // cancel
case 4:
case 5:
return amount;
}
}
}
void testBug(void) {
ASSERT(SelectAmount(0, 1, 0) == 0);
}
uint8_t KeyMenuWait() {
static uint8_t i;
return i++;
}
#ifdef __SDCC_z80
void dummy (void) __naked
{
__asm
get_bank::
set_bank::
ret
__endasm;
}
#endif
|