Hello Bob,
Did you sure that compiler *must* determine that for OR operation only
one byte changing and load only part of value instead of all 32 bits?
It's a simple optimization stuff according assemble set, but according
initial logical operation with 32bit value it's a correct code. Compiler
save at least 3 other 'ori' commands.
BTW, you simply could optimize your routie by doing OR command on MSB
byte only by itself.
01.03.2011 13:48, bob writes:
Hi,
I have a very time-critcal routine where a 32-bit value is read serially
(bit-shift).
The code is very simple (runs in Port Change interrupt):
if ((PINA& _BV(A2DDATA)) != 0)
result |= 0x80000000;
result>>= 1;
The disassembly of the OR however is:
if ((PINA& _BV(A2DDATA)) != 0)
622: 01 9b sbis 0x00, 1 ; 0
624: 11 c0 rjmp .+34 ; 0x648<__vector_4+0x42>
result |= 0x80000000;
626: 80 91 5a 02 lds r24, 0x025A
62a: 90 91 5b 02 lds r25, 0x025B
62e: a0 91 5c 02 lds r26, 0x025C
632: b0 91 5d 02 lds r27, 0x025D
636: b0 68 ori r27, 0x80 ; 128
638: 80 93 5a 02 sts 0x025A, r24
63c: 90 93 5b 02 sts 0x025B, r25
640: a0 93 5c 02 sts 0x025C, r26
644: b0 93 5d 02 sts 0x025D, r27
The compiler has loaded all 4 bytes of the uint32_t, but only operated
on one of them, so it seems 'clever' enough to see that the immediate
value is full of '0' and not bother to OR the lower bytes but still
loads and saves them.
I have:
OPTIMIZE = -Os -fno-inline
override CFLAGS = -g -Wall -Wno-main $(OPTIMIZE)
-mmcu=$(MCU_TARGET) $(DEFS)
in my Makefile.
Am I missing something?
Regards,
Bob
_______________________________________________
AVR-chat mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/avr-chat
_______________________________________________
AVR-chat mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/avr-chat