Index: compiler/fpcdefs.inc
===================================================================
--- compiler/fpcdefs.inc	(revision 18784)
+++ compiler/fpcdefs.inc	(working copy)
@@ -33,7 +33,7 @@
   $define FPC_HAS_SYSTEMS_INTERRUPT_TABLE
   to fpcdefs.inc to reactivate
   the corresponding code }
-{$undef FPC_HAS_SYSTEMS_INTERRUPT_TABLE}
+{$define FPC_HAS_SYSTEMS_INTERRUPT_TABLE}
 
 { This fake CPU is used to allow incorporation of globtype unit
   into utils/ppudump without any CPU specific code PM }
Index: compiler/ncgutil.pas
===================================================================
--- compiler/ncgutil.pas	(revision 18784)
+++ compiler/ncgutil.pas	(working copy)
@@ -3197,7 +3197,30 @@
               end;
             hp:=tused_unit(hp.next);
           end;
+        for i := 0 to current_module.symlist.Count-1 do
+          begin
+            sym:=tsym(current_module.symlist[i]);
+            if not assigned(sym) then
+              continue;
+            if sym.typ = procsym then
+              begin
+                for i2 := 0 to tprocsym(sym).ProcdefList.Count-1 do
+                  begin
+                    pd:=tprocdef(tprocsym(sym).ProcdefList[i2]);
+                    if pd.interruptvector >= 0 then
+                      begin
+                        if pd.interruptvector > high(interruptTable) then
+                          Internalerror(2011030602);
+                        if interruptTable[pd.interruptvector] <> nil then
+                          internalerror(2011030601);
 
+                        interruptTable[pd.interruptvector]:=pd;
+                        break;
+                      end;
+                  end;
+              end;
+          end;
+
         new_section(current_asmdata.asmlists[al_globals],sec_init,'VECTORS',sizeof(pint));
         current_asmdata.asmlists[al_globals].concat(Tai_symbol.Createname_global('VECTORS',AT_DATA,0));
 {$IFDEF arm}
Index: compiler/pdecsub.pas
===================================================================
--- compiler/pdecsub.pas	(revision 18784)
+++ compiler/pdecsub.pas	(working copy)
@@ -2308,7 +2308,7 @@
       idtok:_INTERRUPT;
       pd_flags : [pd_implemen,pd_body,pd_notobject,pd_notobjintf,pd_notrecord,pd_nothelper];
       handler  : @pd_interrupt;
-      pocall   : pocall_oldfpccall;
+      pocall   : pocall_interrupt;
       pooption : [po_interrupt];
       mutexclpocall : [pocall_internproc,pocall_cdecl,pocall_cppdecl,pocall_stdcall,
                        pocall_pascal,pocall_far16,pocall_oldfpccall];
Index: compiler/systems.pas
===================================================================
--- compiler/systems.pas	(revision 18784)
+++ compiler/systems.pas	(working copy)
@@ -286,7 +286,7 @@
          $define FPC_HAS_SYSTEMS_INTERRUPT_TABLE
          to fpcdefs.inc to reactivate
          the corresponding code }
-       systems_interrupt_table = [{system_arm_embedded}];
+       systems_interrupt_table = [system_arm_embedded];
        {$endif FPC_HAS_SYSTEMS_INTERRUPT_TABLE}
 
        { all systems for which istack must be at a 16 byte boundary
Index: rtl/embedded/arm/stm32f103.pp
===================================================================
--- rtl/embedded/arm/stm32f103.pp	(revision 18784)
+++ rtl/embedded/arm/stm32f103.pp	(working copy)
@@ -134,11 +134,14 @@
   CNTR, res1,
   ISTR, res2,
   FNR, res3: Word;
-  DADDR: byte; res4: word; res5: byte;
+  DADDR, res5: word;
   BTABLE: Word;
  end;
 
- TUSBMem = packed array[0..511] of byte;
+ TUSBMem = array[0..127] of record
+  Data,
+  Nothing: Word;
+ end;
 
  TCANMailbox = record
   IR,
@@ -416,7 +419,7 @@
 
  { USB }
  USB: TUSBRegisters			absolute (APB1Base+$5C00);
- USBMem: TUSBMem				absolute (APB1Base+$5C00);
+ USBMem: TUSBMem				absolute (APB1Base+$6000);
 
  { CAN }
  CAN: TCANRegisters			absolute (APB1Base+$6800);
@@ -472,17 +475,6 @@
  { NVIC }
  NVIC: TNVICRegisters      absolute (SCS_BASE+$0100);
 
-var
-	NMI_Handler,
-	HardFault_Handler,
-	MemManage_Handler,
-	BusFault_Handler,
-	UsageFault_Handler,
-	SWI_Handler,
-	DebugMonitor_Handler,
-	PendingSV_Handler,
-	Systick_Handler: pointer;
-
 implementation
 
 var
@@ -501,143 +493,17 @@
 	b .Lhalt
 end;
 
-procedure _FPC_start; assembler; nostackframe;
-label _start;
+procedure DefaultHandler; assembler; nostackframe; public name 'DefaultHandler';
 asm
-	.init
-	.balign 16
-	
-	.long _stack_top	 			// First entry in NVIC table is the new stack pointer
-	.long _start+1
-	//b   _start					// Reset
-	.long _start+1
-	//b	 .LNMI_Addr				// Non maskable interrupt. The RCC Clock Security System (CSS) is linked to the NMI vector.
-	.long _start+1
-	//b	 .LHardFault_Addr		// All class of fault
-	.long _start+1
-	//b	 .LMemManage_Addr		// Memory management
-	.long _start+1
-	//b	 .LBusFault_Addr		// Pre-fetch fault, memory access fault
-	.long _start+1
-	//b	 .LUsageFault_Addr	// Undefined instruction or illegal state
-	.long _start+1
-	//nop							// Reserved
-	.long _start+1
-	//nop							// Reserved
-	.long _start+1
-	//nop							// Reserved
-	.long _start+1
-	//nop							// Reserved
-	.long _start+1
-	//b	 .LSWI_Addr				// Software Interrupt vector
-	.long _start+1
-	//b	 .LDebugMonitor_Addr	// Debug Monitor
-	.long _start+1
-	//nop							// Reserved
-	.long _start+1
-	//b	 .LPendingSV_Addr		//	Pendable request for system service
-	.long _start+1
-	//b	 .LSystick_Addr		// System tick timer
-	//17
-	.long .LDefaultHandler+1
-	.long .LDefaultHandler+1
-	.long .LDefaultHandler+1
-	//20
-	.long .LDefaultHandler+1
-	.long .LDefaultHandler+1
-	.long .LDefaultHandler+1
-	.long .LDefaultHandler+1
-	.long .LDefaultHandler+1
-	.long .LDefaultHandler+1
-	.long .LDefaultHandler+1
-	.long .LDefaultHandler+1
-	.long .LDefaultHandler+1
-	.long .LDefaultHandler+1
-	
-	.long .LDefaultHandler+1
-	.long .LDefaultHandler+1
-	.long .LDefaultHandler+1
-	.long .LDefaultHandler+1
-	.long .LDefaultHandler+1
-	.long .LDefaultHandler+1
-	.long .LDefaultHandler+1
-	.long .LDefaultHandler+1
-	.long .LDefaultHandler+1
-	.long .LDefaultHandler+1
-	
-	.long .LDefaultHandler+1
-	.long .LDefaultHandler+1
-	.long .LDefaultHandler+1
-	.long .LDefaultHandler+1
-	.long .LDefaultHandler+1
-	.long .LDefaultHandler+1
-	.long .LDefaultHandler+1
-	.long .LDefaultHandler+1
-	.long .LDefaultHandler+1
-	.long .LDefaultHandler+1
-	
-	.long .LDefaultHandler+1
-	.long .LDefaultHandler+1
-	.long .LDefaultHandler+1
-	.long .LDefaultHandler+1
-	.long .LDefaultHandler+1
-	.long .LDefaultHandler+1
-	.long .LDefaultHandler+1
-	.long .LDefaultHandler+1
-	.long .LDefaultHandler+1
-	.long .LDefaultHandler+1
+.LDefaultLoop:
+	b .LDefaultLoop
+end;
 
-.LNMI_Addr:
-	ldr r0,.L1
-	ldr pc,[r0]
-.LHardFault_Addr:
-	ldr r0,.L2
-	ldr pc,[r0]
-.LMemManage_Addr:
-	ldr r0,.L3
-	ldr pc,[r0]
-.LBusFault_Addr:
-	ldr r0,.L4
-	ldr pc,[r0]
-.LUsageFault_Addr:
-	ldr r0,.L5
-	ldr pc,[r0]
-.LSWI_Addr:
-	ldr r0,.L6
-	ldr pc,[r0]
-.LDebugMonitor_Addr:
-	ldr r0,.L7
-	ldr pc,[r0]
-.LPendingSV_Addr:
-	ldr r0,.L8
-	ldr pc,[r0]
-.LSystick_Addr:
-	ldr r0,.L9
-	ldr pc,[r0]
-
-.L1:
-	.long NMI_Handler
-.L2:
-	.long HardFault_Handler
-.L3:
-	.long MemManage_Handler
-.L4:
-	.long BusFault_Handler
-.L5:
-	.long UsageFault_Handler
-.L6:
-	.long SWI_Handler
-.L7:
-	.long DebugMonitor_Handler
-.L8:
-	.long PendingSV_Handler
-.L9:
-	.long Systick_Handler
-
-	.globl _start
-	.text
+procedure _FPC_start; assembler; nostackframe; interrupt 0;
+label _start;
+asm
+  .globl _start
 _start:
-	
 	// Copy initialized data to ram
 	ldr r1,.L_etext
 	ldr r2,.L_data
@@ -672,11 +538,6 @@
 	.long _data
 .L_edata:
 	.long _edata
-.LDefaultHandlerAddr:
-	.long .LDefaultHandler
-	// default irq handler just returns
-.LDefaultHandler:
-	mov pc,r14
 end;
 
 end.
