On Mon, 2009-02-16 at 23:37 +0100, Georg-Johann Lay wrote: > distance = =895*distance;
See my followup message about the typo. distance = 895*distance. > > [...] > > > 895*distance generates a call to __mulsi3, multiplying r25:22 by r21:18 > > and returning the result in r25:22. > > > > However, I cannot find where r21:18 are set in the code. Looking at the > > output of avr-gcc -S, I cannot find any of r18:21. > > The compilable source is 3700 lines. I can post it if necessary. I think the following will demo the problem 1. Create the two files, as below. 2. Compile with avr-gcc -mmcu=atmega32 -Wall -Wmissing-prototypes -Os \ -fno-strict-aliasing range.c global_var.c -o range.elf 3. avr-objdump -d range.elf ===== range.c ======================= #include <avr/io.h> // port definitions #include <inttypes.h> extern volatile uint8_t range_new; extern volatile uint8_t range_local; extern volatile uint8_t range_count; extern volatile uint8_t range_local_ovfl; extern volatile uint8_t disp_range_count; extern volatile uint8_t disp_range_ovfl; extern volatile uint8_t range_ovfl; int main() { while(1) { // if we have new range data, process it if (range_new == 1) { { uint32_t distance = range_local_ovfl<<8; distance += (uint32_t)range_count; distance = 2345*distance; distance = distance >> 16; range_local = (uint8_t)(distance - 4)&0xff; } disp_range_count = range_count; disp_range_ovfl = range_ovfl; } return 0; } } ==== global_var.c =================== #include <avr/io.h> // port definitions #include <inttypes.h> volatile uint8_t range_new; volatile uint8_t range_local; volatile uint8_t range_count; volatile uint8_t range_local_ovfl; volatile uint8_t disp_range_count; volatile uint8_t disp_range_ovfl; volatile uint8_t range_ovfl; _______________________________________________ AVR-GCC-list mailing list AVR-GCC-list@nongnu.org http://lists.nongnu.org/mailman/listinfo/avr-gcc-list