Hello, here is a small selfcontaining example to reproduce the "right shift by 16" no optimization problem. The not optimized lines: 198 ; tbasic.c: 53: t >>= 16; 00006C CDr00r00 [ 4] 199 call __mullong 00006F 5B 08 [ 2] 200 addw sp, #8 000071 1F 0D [ 2] 201 ldw (0x0d, sp), x 000073 17 0B [ 2] 202 ldw (0x0b, sp), y 000075 17 01 [ 2] 203 ldw (0x01, sp), y 000077 1E 0D [ 2] 204 ldw x, (0x0d, sp) 000079 07 01 [ 1] 205 sra (0x01, sp) 00007B 06 02 [ 1] 206 rrc (0x02, sp) 00007D 56 [ 2] 207 rrcw x 00007E...
Hello, here is the self contained code file, the list file and the make script. The not optimized lines are: 000021 C6 50 13 [ 1] 128 ld a, 0x5013 000024 A4 EF [ 1] 129 and a, #0xef 000026 C7 50 13 [ 1] 130 ld 0x5013, a
Hello, i think the linker memory check options exists and they should work. Of course has this bug not the highest priority.
Hello, this is the "bset bres" issue compiled by SDCC 4.4.0 with --fverbose-asm: 133 ; ----------------------------------------- 134 ; function i2c_init 135 ; ----------------------------------------- 136 ; Register assignment is optimal. 137 ; Stack space usage: 0 bytes. 00000A 138 _i2c_init: 139 ; tbasic.c: 51: *(uint8_t *)(SCL_BASE + P_DDR) |= SCL_MASK; // Set DDR to output 140 ; genPointerGet 141 ; genOr 142 ; genPointerSet 00000A 72 16 50 11 [ 1] 143 bset 0x5011, #3 144 ; peephole 202x replaced...
Hello, i investigated this further. The same behaviour happens on other places too. Please see the two indentical "t >>= 16" instructions in the following code. int32_t t; t = raw_temp; t *= 100; t *= 165; // t /= 65535; t >>= 16; t -= 40 * 100; thd->temperature = t; // Calculate temperature value uint16_t raw_hum = data[3]; raw_hum <<= 8; raw_hum |= data[4]; crc = htu31d_crc(raw_hum); // Serial.print("CRC: 0x"); Serial.println(crc, HEX); if (crc != data[5]) { sprintf(buffer, "H crc 0x%02X 0x%02X\r\n",...
Hello, thank you for the hint. I added the linker options -C -I and -X to the makefile, nothing happens, the code ist still compiled and linked without warning or error. E:\Projects\Microcontroller\stm8\tbasic\basic_ucnet2\basict - ram - bug>make.exe all "Cleaning done..." sdcc -lstm8 -mstm8 --std-c99 --opt-code-size -D__stm8s103f3__ -Wl-I1024,-X0,-C8192 -DF_CPU=16000000 -I./ -I../include -c tbasic.c -o tbasic.rel sdcc -lstm8 -mstm8 --std-c99 --opt-code-size -D__stm8s103f3__ -Wl-I1024,-X0,-C8192...
Hello, the optimization is done as soon the call to _i2c_set_sda is removed. But i can't see any reason for this behaviour. 112 ; ----------------------------------------- 113 ; function i2c_init 114 ; ----------------------------------------- 00000A 115 _i2c_init: 116 ; tbasic.c: 51: *(uint8_t *)(SCL_BASE + P_DDR) |= SCL_MASK; // Set DDR to output 00000A 72 16 50 11 [ 1] 117 bset 0x5011, #3 118 ; tbasic.c: 52: *(uint8_t *)(SCL_BASE + P_CR1) &= ~SCL_MASK; // Set CR1 to open-drain 00000E 72 17 50...
STM8S103F3 - RAM size not checked