zl程序教程

您现在的位置是:首页 >  其他

当前栏目

浅谈DeFi质押流动性挖矿项目系统开发方案(技术详情)分析逻辑

2023-03-07 09:02:58 时间

区块链代码计算函数方式

继续往下看

/**
 * @brief  This is the code that gets called when the processor receives an 
 *         unexpected interrupt.  This simply enters an infinite loop, preserving
 *         the system state for examination by a debugger.
 * @param  None     
 * @retval None       
*/
    .section  .text.Default_Handler,"ax",%progbits
Default_Handler:
Infinite_Loop:
  b  Infinite_Loop
  .size  Default_Handler, .-Default_Handler
  • 注释说明如果处理器收到一个未预料的中断,将会进入这个死循环中,即Default_Handler
  • .section .text.Reset_Handler这里表示定义的是.text段中的Reset_Handler段,ax表示权限,ax是 allocation execute的缩写,表示该节区可分配并且可执行,progbits是type,详细定义为.section section_name [, “flags”[, %type[,flag_specific_arguments]]] 这里不具体解释。

中断向量表和服务函数

这部分主要是中断向量表的定义,摘抄部分如下:

/******************************************************************************
*
* The minimal vector table for a Cortex M3. Note that the proper constructs
* must be placed on this to ensure that it ends up at physical address
* 0x0000.0000.
* 
*******************************************************************************/
   .section  .isr_vector,"a",%progbits
  .type  g_pfnVectors, %object
  .size  g_pfnVectors, .-g_pfnVectors
    
    
g_pfnVectors:
  .word  _estack
  .word  Reset_Handler
  .word  NMI_Handler
  .word  HardFault_Handler
  /*省略*/
  
  /* External Interrupts */
  .word     WWDG_IRQHandler                   /* Window WatchDog              */                                        
  .word     PVD_IRQHandler                    /* PVD through EXTI Line detection */                        
  .word     TAMP_STAMP_IRQHandler             /* Tamper and TimeStamps through the EXTI line */            
  .word     RTC_WKUP_IRQHandler               /* RTC Wakeup through the EXTI line */                      
  .word     FLASH_IRQHandler                  /* FLASH                        */                                          
  .word     RCC_IRQHandler                    /* RCC                          */                                            
  /*省略*/                
/*******************************************************************************
*
* Provide weak aliases for each Exception handler to the Default_Handler. 
* As they are weak aliases, any function with the same name will override 
* this definition.
* 
*******************************************************************************/
   .weak      NMI_Handler
   .thumb_set NMI_Handler,Default_Handler
  
   .weak      HardFault_Handler
   .thumb_set HardFault_Handler,Default_Handler
  
   /*省略*/

/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
  • 注释部分,表明中断向量表需要在物理地址0x00000000的位置上,如果是IAP当然可以通过程序后续配置调整地址大小,但是第一次启动必然要从0开始
  • .section .isr_vector,"a",%progbits定义中断向量段和它的类型,a表示可分配,%progbits表示段内包含数据。
  • .type g_pfnVectors, %object段符号名为g_pfnVectors,%object表示符号为数据对象。
  • .size g_pfnVectors, .-g_pfnVectors表示g_pfnVectors的大小是从当前位置-定义位置。
  • .word _estack在当前位置放置一个word型的值,这个值为_estack;后面同理。
  • .thumb_set NMI_Handler,Default_Handler等效于.set指令,因为它创建了一个符号,该符号是另一个符号的别名(可能尚未定义)。 该指令还具有添加的属性,因为它以.thumb_func指令相同的方式将别名符号标记为thumb函数入口点。即NMI_Handler默认用Default_Handler替代,但同时NMI_Handler还是个若引用,因此当我们在程序里定义了这个中断服务函数的时候,就会替代这里。