Pick three bugfixes from next branch to trunk for inclusion in 4.5.0 RC2, as discusse...
[sdcc.git] / sdcc / support / regression / tests / bug-3733.c
blob1078d0776c616a7f02d2733f8c783691f8a4890e
1 /** A bad z80 peephole optimizer rule created invalid asm
2 */
4 // Based on code sample under GPL 2.0 or later
5 #include <stdio.h>
6 #include <stdint.h>
7 #include <stdbool.h>
9 #include <testfwk.h>
11 #pragma disable_warning 85
13 void vdu_sprite_position_set16( uint8_t id, uint8_t tile, uint8_t x, uint8_t y, uint8_t colour ) {}
15 ///< Show patch - set tiles
16 uint8_t vdu_patch_crop_impl( uint8_t id, int8_t col, int8_t row,
17 int8_t width, int8_t offset, const uint8_t *counts, const uint8_t *colours,
18 int8_t cols, int8_t rows, uint8_t tile_offset, bool zoom ) {
20 int16_t px = col;
21 int16_t py = rows;
23 do {
25 uint8_t x = cols;
26 do {
28 uint8_t count = 1;
30 do {
31 vdu_sprite_position_set16( id++, tile_offset, px, py, *colours++ ); // The bad asm happened in code for passing parameters here.
33 } while ( --count );
35 px++;
36 counts++;
38 } while( --x );
40 } while ( --rows );
42 return 0;
45 void
46 testBug(void)
48 uint8_t c = 0;
49 vdu_patch_crop_impl(0, 0, 0, 0, 0, &c, &c, 1, 1, 0, 0);