struct / union in initializer, RFE #901.
[sdcc.git] / sdcc / support / regression / tests / bug-3090.c
blob86e3c8a990b369b075b93cc6b46587815acd50c4
1 /* bug-3090.c
2 A bug in gbz80 code generation for 16-bit addition with operands allocated to bc and de, result spilt.
3 */
5 #include <testfwk.h>
7 #define UINT8 unsigned char
8 #define specialchar_nl '\n'
10 #define buffer_length (16)
11 UINT8 buffer[buffer_length];
13 UINT8 smart_write(const UINT8 y, const UINT8 height, char *str){
14 UINT8 length;
15 UINT8 run = 1;
16 UINT8 tmp_y = y;
17 UINT8 jump_back = 0;
18 UINT8 ret = 0;
19 // string pointer
20 char *str_ptr = str;
21 while(run){
22 for(length = 0; length < 16; ++length){
23 if(*str_ptr == specialchar_nl || *str_ptr == '\0'){
24 buffer[length] = '\0';
25 break;
27 buffer[length] = *str_ptr;
28 ++str_ptr;
29 if(jump_back != 0){
30 --jump_back;
33 if(*str_ptr == '\0'){
34 run = 0;
35 } else {
36 if(*str_ptr == specialchar_nl)
37 ++str_ptr;
38 tmp_y += 1;
40 if(tmp_y >= y+height){ // Wrong code generated for addition here.
41 tmp_y = y;
42 ++ret;
45 return ret;
48 void
49 testBug(void){
50 ASSERT(smart_write(1, 20, "test\n") == 0);