diff options
| author | Xavier ASUS <xavi92psx@gmail.com> | 2019-10-18 00:31:54 +0200 |
|---|---|---|
| committer | Xavier ASUS <xavi92psx@gmail.com> | 2019-10-18 00:31:54 +0200 |
| commit | 268a53de823a6750d6256ee1fb1e7707b4b45740 (patch) | |
| tree | 42c1799a9a82b2f7d9790ee9fe181d72a7274751 /support/regression/tests/bug-2866.c | |
| download | sdcc-gas-268a53de823a6750d6256ee1fb1e7707b4b45740.tar.gz | |
sdcc-3.9.0 fork implementing GNU assembler syntax
This fork aims to provide better support for stm8-binutils
Diffstat (limited to 'support/regression/tests/bug-2866.c')
| -rw-r--r-- | support/regression/tests/bug-2866.c | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/support/regression/tests/bug-2866.c b/support/regression/tests/bug-2866.c new file mode 100644 index 0000000..d79c640 --- /dev/null +++ b/support/regression/tests/bug-2866.c @@ -0,0 +1,66 @@ +/* bug-2866.c + A bug in rematerialization in the z80 backend. + */ + +#include <testfwk.h> + +typedef unsigned char uint8; +typedef int int16; + +#define COL_MAX_HEIGHT 64 +#define COL_TEX_HEIGHT 32 + +#ifndef __SDCC_pdk14 // Lack of memory +uint8 single_column[COL_MAX_HEIGHT]; + +void initSingleColumn(int16 height) +{ + int16 y; + int16 y0; + int16 y1; + int16 dy; + int16 dv; + int16 v; + + y0 = (COL_MAX_HEIGHT - height) >> 1; + y1 = COL_MAX_HEIGHT - y0; + + dy = y1 - y0 - 1; + if (dy < 1) dy = 1; + dv = (COL_TEX_HEIGHT << 8) / dy; + v = 0; + + if (y0 < 0) + { + v -= y0 * dv; + y0 = 0; + } + if (y1 > COL_MAX_HEIGHT) y1 = COL_MAX_HEIGHT; + + for (y = 0; y<y0; y++) + { + single_column[y] = 128; + single_column[COL_MAX_HEIGHT - y - 1] = 64; // Bug resulted in wrong address calculation here. + } + + for (y = y0; y < y1; y++) + { + if (v > (31 << 8)) v = 31 << 8; + single_column[y] = (v >> 8); + v+=dv; + } +} +#endif + +void testBug(void) +{ +#ifndef __SDCC_pdk14 // Lack of memory + initSingleColumn (0); + + ASSERT (single_column[0x00] == 0x80); + ASSERT (single_column[0x1f] == 0x80); + ASSERT (single_column[0x20] == 0x40); + ASSERT (single_column[0x3f] == 0x40); +#endif +} + |
