本帖最后由 askhua520 于 2013-10-30 21:04 编辑
整理一下,不知理解对不对;
/* BASIC INTERRUPT VECTOR TABLE FOR STM8 devices
* Copyright (c) 2007 STMicroelectronics
*/
//typedef void (*)void,;定义一个类型(指向函数的指针)取得void类型函数的函数入口地址指针
typedef void @far (*interrupt_handler_t)(void);
//定义一个结构体类型存放{中断指令,中断处理程序名(即中断函数入口指针)}
struct interrupt_vector {
unsigned char interrupt_instruction;
interrupt_handler_t interrupt_handler;
};
//定义一个空中断函数,执行后直接返回主函数
@far @interrupt void NonHandledInterrupt (void)
{
/* in order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction
*/
return;
}
//声明启动初始化程序,_stext()程序在别处定义
extern void _stext(); /* startup routine */
//定义一个二维数组成对存放中断指令和中断函数入口地址指针,
//MCU根据第二下标值[2,32]执行0x82指令"跳转"相应的中断程序入口地址
//数组存放位置在const关键值标定的起始地址0x8000,即_vectab代表起始地址0x8000
//1、struct interrupt_vector const _vectab[]={}
//2、+seg .const -b 0x8000 -k
//CALL与RET成对,而这个0x82指令与IRET成对
struct interrupt_vector const _vectab[] = {
//将_stext强制转化为interrupt_handler_t类型
{0x82, (interrupt_handler_t)_stext}, /* reset */
{0x82, NonHandledInterrupt}, /* trap */
{0x82, NonHandledInterrupt}, /* irq0 */
{0x82, NonHandledInterrupt}, /* irq1 */
{0x82, NonHandledInterrupt}, /* irq2 */
{0x82, NonHandledInterrupt}, /* irq3 */
{0x82, NonHandledInterrupt}, /* irq4 */
{0x82, NonHandledInterrupt}, /* irq5 */
{0x82, NonHandledInterrupt}, /* irq6 */
{0x82, NonHandledInterrupt}, /* irq7 */
{0x82, NonHandledInterrupt}, /* irq8 */
{0x82, NonHandledInterrupt}, /* irq9 */
{0x82, NonHandledInterrupt}, /* irq10 */
{0x82, NonHandledInterrupt}, /* irq11 */
{0x82, NonHandledInterrupt}, /* irq12 */
{0x82, NonHandledInterrupt}, /* irq13 */
{0x82, NonHandledInterrupt}, /* irq14 */
{0x82, NonHandledInterrupt}, /* irq15 */
{0x82, NonHandledInterrupt}, /* irq16 */
{0x82, NonHandledInterrupt}, /* irq17 */
{0x82, NonHandledInterrupt}, /* irq18 */
{0x82, NonHandledInterrupt}, /* irq19 */
{0x82, NonHandledInterrupt}, /* irq20 */
{0x82, NonHandledInterrupt}, /* irq21 */
{0x82, NonHandledInterrupt}, /* irq22 */
{0x82, NonHandledInterrupt}, /* irq23 */
{0x82, NonHandledInterrupt}, /* irq24 */
{0x82, NonHandledInterrupt}, /* irq25 */
{0x82, NonHandledInterrupt}, /* irq26 */
{0x82, NonHandledInterrupt}, /* irq27 */
{0x82, NonHandledInterrupt}, /* irq28 */
{0x82, NonHandledInterrupt}, /* irq29 */
};
|