further optimize codesize
authorStephan Baerwolf <stephan.baerwolf@tu-ilmenau.de>
Sun, 5 May 2013 20:05:22 +0000 (22:05 +0200)
committerStephan Baerwolf <stephan.baerwolf@tu-ilmenau.de>
Sun, 5 May 2013 20:33:46 +0000 (20:33 +0000)
Signed-off-by: Stephan Baerwolf <stephan.baerwolf@tu-ilmenau.de>
firmware/Makefile
firmware/main.c

index 04bec88..df886aa 100644 (file)
@@ -19,7 +19,7 @@ include ../Makefile.inc
 
 # Remove the -fno-* options when you use gcc 3, it does not understand them
 CFLAGS = -Wall -Os -fno-move-loop-invariants -fno-tree-scev-cprop -fno-inline-small-functions -I. -mmcu=$(DEVICE) -DBOOTLOADER_ADDRESS=$(BOOTLOADER_ADDRESS) -DF_CPU=$(F_CPU) $(DEFINES)
-LDFLAGS = -Wl,--relax,--gc-sections -Wl,--section-start=.text=$(BOOTLOADER_ADDRESS)
+LDFLAGS = -Wl,--relax,--gc-sections -Wl,--section-start=.text=$(BOOTLOADER_ADDRESS) -Wl,--defsym=nullVector=0
 
 OBJECTS =  usbdrv/usbdrvasm.o usbdrv/oddebug.o main.o
 
index b8e17a0..2639644 100644 (file)
@@ -220,25 +220,21 @@ void __func_clearram(void) {
 }
 #endif
 
-#if (!USE_EXCESSIVE_ASSEMBLER) || (!(defined (__AVR_ATmega8__) || defined (__AVR_ATmega8A__) || defined (__AVR_ATmega8HVA__)))
 static void (*nullVector)(void) __attribute__((__noreturn__));
-#endif
 
-static void __attribute__((__noreturn__)) leaveBootloader()
-{
+static void __attribute__((naked)) __attribute__((__noreturn__)) leaveBootloader(void);
+static void leaveBootloader(void) {
 #if (USE_EXCESSIVE_ASSEMBLER) && (defined (__AVR_ATmega8__) || defined (__AVR_ATmega8A__) || defined (__AVR_ATmega8HVA__))
 asm  volatile  (
   "cli\n\t"
-  "clr         r30\n\t"
   "sbi         %[usbddr],      %[usbminus]\n\t"  
   "cbi         %[port],        %[bit]\n\t"
-  "out         %[usbintrenab], r30\n\t"
-  "out         %[usbintrcfg],  r30\n\t"
+  "out         %[usbintrenab], __zero_reg__\n\t"
+  "out         %[usbintrcfg],  __zero_reg__\n\t"
   "ldi         r31,            %[ivce]\n\t"
   "out         %[mygicr],      r31\n\t"
-  "out         %[mygicr],      r30\n\t"  
-  "clr         r31\n\t"
-  "icall\n\t"
+  "out         %[mygicr],      __zero_reg__\n\t"  
+  "rjmp                nullVector\n\t"
   :
   : [port]        "I" (_SFR_IO_ADDR(PIN_PORT(JUMPER_PORT))),
     [bit]         "I" (PIN(JUMPER_PORT, JUMPER_BIT)),