nes-proj/cpu
Benoît Thébaudeau 19fd7a3551 Use additive offsets
OR-ing an offset to a base address instead of adding it is dangerous
because it can only work if the base address is aligned enough for the
offset.

Moreover, if the base address or the offset has a value unknown at
compile time, then the assembly instructions dedicated to 'base +
offset' addressing on most CPUs can't be emitted by the compiler because
this would require the alignment of the base address against the offset
to be known in order to optimize 'base | offset' into 'base + offset'.
In that case, the compiler has to emit more instructions in order to
compute 'base | offset' on most CPUs, e.g. on ARM, which means larger
binary size and slower execution.

Hence, replace all occurrences of 'base | offset' with 'base + offset'.
This must become a coding rule.

Here are the results for the cc2538-demo example:
 - Compilation of uart_init():
    * before:
        REG(regs->base | UART_CC) = 0;
        200b78:	f446 637c 	orr.w	r3, r6, #4032	; 0xfc0
        200b7c:	f043 0308 	orr.w	r3, r3, #8
        200b80:	2200      	movs	r2, #0
        200b82:	601a      	str	r2, [r3, #0]

    * now:
        REG(regs->base + UART_CC) = 0;
        200b7a:	2300      	movs	r3, #0
        200b7c:	f8c4 3fc8 	str.w	r3, [r4, #4040]	; 0xfc8

 - Size of the .text section:
    * before:	0x4c7c
    * now:	0x4c28
    * saved:	84 bytes

Signed-off-by: Benoît Thébaudeau <benoit.thebaudeau.dev@gmail.com>
2015-03-28 17:28:15 +01:00
..
6502 Network layer configuration: replace UIP_CONF_* with NETSTACK_CONF_WITH_* 2014-12-01 21:02:57 +01:00
arm Fix aducrf101 builds with GCC 4.9+ 2015-02-16 14:52:05 -05:00
avr Fix clock.h warnings caused by multiple, conflicting documentation blocks of clock functions 2015-02-15 21:48:30 +01:00
cc26xx Use additive offsets 2015-03-28 17:28:15 +01:00
cc253x Fix clock.h warnings caused by multiple, conflicting documentation blocks of clock functions 2015-02-15 21:48:30 +01:00
cc2430 Fix clock.h warnings caused by multiple, conflicting documentation blocks of clock functions 2015-02-15 21:48:30 +01:00
cc2538 Use additive offsets 2015-03-28 17:28:15 +01:00
mc1322x Fix clock.h warnings caused by multiple, conflicting documentation blocks of clock functions 2015-02-15 21:48:30 +01:00
msp430 Merge pull request #845 from alignan/fix_region 2015-03-10 22:04:38 +00:00
native Network layer configuration: replace UIP_CONF_* with NETSTACK_CONF_WITH_* 2014-12-01 21:02:57 +01:00
pic32 [cpu/pic32] Removed excess end group 2014-11-10 23:53:33 +01:00
rl78 Added stub for extended radio API for rl78 2014-04-03 13:38:28 +02:00
stm32w108 Use additive offsets 2015-03-28 17:28:15 +01:00
x86 A massive all-tree automated update of all double inclusion guard #defines that changes from using two underscores as a prefix, which are reserved, to not using two underscores as a prefix 2013-11-24 20:20:11 +01:00