Reducing source code: weak+alias values in array
Jens Bauer via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Mon Apr 27 10:49:19 PDT 2015
I was wondering if there's a way to reduce my bulky startup files
a bit.
If using the GNU Assembler (GAS), then one can reduce the code
using a macro like this:
/* The EXC macro makes a weak+alias for the
* symbol 'value', then it stores the value in memory: */
.macro EXC value,defaultValue
.ifnb \defaultValue
.weakref \value,\defaultValue
.else
.weakref \value,defaultExceptionVector
.endif
.4byte \value
.endm
/* The exception vector now looks quite simple: */
isr_vector:
.4byte _stack
EXC Reset_Handler,defaultResetHandler
EXC NMI_Handler
EXC HardFault_Handler
EXC MemManage_Handler
EXC BusFault_Handler
EXC UsageFault_Handler
.4byte 0
.4byte 0
.4byte 0
.4byte 0
EXC SVC_Handler
EXC DebugMon_Handler
.4byte 0
EXC PendSV_Handler
EXC SysTick_Handler
An example on one of my bulky startup files:
https://github.com/jens-gpio/MCU/blob/master/startup/stm/stm32f439_startup.d
I was thinking about alias (Tuple) or similar, but I'm not sure
it would work if not declaring the label weak+alias in advance.
Any thoughts ?
(Other suggestions on how to reduce the source code size are also
welcome).
More information about the Digitalmars-d-learn
mailing list