Pick three bugfixes from next branch to trunk for inclusion in 4.5.0 RC2, as discusse...
[sdcc.git] / sdcc / support / regression / tests / bug-3685.c
blobd96dcbf92422c572e9143564c6341f27074326d5
1 /* bug-3685.c
2 Wrong code was generated for an addition involving an operand using exactly one byte of iy.
3 */
5 // Based on code by "Under4Mhz" licensed under GPL 2.0 or later
7 #include <testfwk.h>
9 #pragma disable_warning 85
11 #include <stdint.h>
12 #include <stdbool.h>
14 typedef struct {
16 uint8_t page;
18 } VduTileData;
20 VduTileData vduTileData;
22 inline uint16_t vdu_tile_page_address( uint8_t page ) {
24 return page == 1 ? 0x9000 : 0x9800;
27 inline uint16_t vdu_tile_page_address_get_fast( void ) {
29 return vdu_tile_page_address( vduTileData.page );
32 void vdu_tiles_put( uint16_t offset, const uint8_t *pixels, const uint8_t *colours ) {
34 static uint16_t o;
35 ASSERT (offset == o);
36 o += 256;
39 uint16_t decompress_vdu(const uint8_t *compressed_data, uint16_t dest ) {}
41 ///< Render image to screen
42 void vdu_image_put( const uint8_t **pixels, const uint8_t **colours, const uint8_t *index ) {
44 ///< Load data
45 uint16_t segmentOffset = 0;
46 for( uint8_t segment = 0; segment < 3; segment++ ) {
48 vdu_tiles_put( segmentOffset, pixels[segment], colours[segment] );
49 segmentOffset += 256; // 256
52 // Write index table
53 if ( index ) {
55 decompress_vdu( index, vdu_tile_page_address_get_fast() );
59 void
60 testBug(void)
63 vduTileData.page = 0;
65 const uint8_t *const pixels[] = { 0, 0, 0 };
66 const uint8_t *const colours[] = { 0, 0, 0 };
67 const uint8_t index[] = { 0 };
69 vdu_image_put( pixels, colours, index );
72 extern uint16_t vdu_tile_page_address( uint8_t page );
74 extern uint16_t vdu_tile_page_address_get_fast( void );