1.中断向量表
#pragma DATA_SECTION("vectors") uVectorEntry g_pfnVectors[32] = { ISR_Reset(), //reset 0x0080 #0 HotBIOS_ISR(Tsk_F_isr, 0, 1), //nmi 0x0084 #1 HotBIOS_ISR(Tsk_F_isr, 0, 2), //sint17 0x0088 #2 HotBIOS_ISR(Tsk_F_isr, 0, 3), //sint18 0x008c #3 HotBIOS_ISR(Tsk_F_isr, 0, 4), //sint19 0x0090 #4 HotBIOS_ISR(Tsk_F_isr, 0, 5), //sint20 0x0094 #5 HotBIOS_ISR(Tsk_F_isr, 0, 6), //sint21 0x0098 #6 HotBIOS_ISR(Tsk_F_isr, 0, 7), //sint22 0x009c #7 HotBIOS_ISR(Tsk_F_isr, 0, 8), //sint23 0x00a0 #8 HotBIOS_ISR(Tsk_F_isr, 0, 9), //sint24 0x00a4 #9 HotBIOS_ISR(Tsk_F_isr, 0,10), //sint25 0x00a8 #10 HotBIOS_ISR(Tsk_F_isr, 0,11), //sint26 0x00ac #11 HotBIOS_ISR(Tsk_F_isr, 0,12), //sint27 0x00b0 #12 HotBIOS_ISR(Tsk_F_isr, 0,13), //sint28 0x00b4 #13 HotBIOS_ISR(Tsk_F_isr, 0,14), //sint29 0x00b8 #14 HotBIOS_ISR(Tsk_F_isr, 0,15), //sint30 0x00bc #15 HotBIOS_ISR(Tsk_F_isr, 0,16), //int0 0x00c0 #16 HotBIOS_ISR(Tsk_F_isr, 0,17), //int1 0x00c4 #17 HotBIOS_ISR(Tsk_F_isr, 0,18), //int2 0x00c8 #18 HotBIOS_ISR(Tsk_F_isr, 0,19), //tint 0x00cc #19 HotBIOS_ISR(Tsk_F_isr, 0,20), //rint0 0x00d0 #20 HotBIOS_ISR(Tsk_F_isr, 0,21), //xint0 0x00d4 #21 HotBIOS_ISR(Tsk_F_isr, 0,22), //rint1 0x00d8 #22 HotBIOS_ISR(Tsk_F_isr, 0,23), //xint1 0x00dc #23 HotBIOS_ISR(Tsk_F_isr, 0,24), //int3 0x00e0 #24 HotBIOS_ISR(Tsk_F_isr, 0,25), //hpint 0x00e4 #25 HotBIOS_ISR(Tsk_F_isr, 0,26), // 0x00e8 #26 HotBIOS_ISR(Tsk_F_isr, 0,27), // 0x00ec #27 HotBIOS_ISR(Tsk_F_isr, 0,28), // 0x00f0 #28 HotBIOS_ISR(Tsk_F_isr, 0,29), // 0x00f4 #29 HotBIOS_ISR(Tsk_F_isr, 0,30), // 0x00f8 #30 HotBIOS_ISR(Tsk_F_isr, 0,31) // 0x00fc #31 };
#define ISR_Reset() { ASMCodeArrayAEx(ASMCODE_BD_K, (pfnVectorEntry)c_int00), ASMCodeArrayEx(ASMCODE_LD_K_SP, 0x200u) }
#define ISR_Return() { ASMCode16i(ASMCODE_RETE), ASMCode16((pfnVectorEntry)ASMCODE_NOP), ASMCode16i(ASMCODE_NOP), ASMCode16i(ASMCODE_NOP) }
#define ISR_Default() { ASMCodeArrayAEx(ASMCODE_BD_K, (pfnVectorEntry)DefaultIsr), ASMCode16i(ASMCODE_NOP), ASMCode16i(ASMCODE_NOP) } #define ISR(addr) { ASMCodeArrayAEx(ASMCODE_BD_K, (pfnVectorEntry)addr), ASMCode16i(ASMCODE_NOP), ASMCode16i(ASMCODE_NOP) } 2.数组汇编
/*------------------------------------------------------------------------*/ typedef void (*ASMCodeArray_FPtr)(void);//定义数组可执行汇编的函数指针
int main(void) { HotBIOS_State iState; TI_IREG AsmCodeArray_IsrFunction[]=//汇编数组首地址实际为汇编入口地址 {//下面的"数据"实际为汇编代码 ASMCode16i(ASMCODE_POPM_A),//psha // ASMCodeArrayEx(ASMCODE_B_K, Tsk_F_isr),//b Tsk_F_isr __asm_goto__(Tsk_F_isr), ASMCodeArray(ASMCODE_LD_k_A, 0x01u),//ld #1, a }; TI_IREG AsmCodeArray_Function[]=//汇编数组首地址实际为汇编入口地址 {//下面的"数据"实际为汇编代码 ASMCode16i(ASMCODE_PSHM_A),//psha //bd xxxh ->loop // ASMCodeArrayEx(ASMCODE_BD_K, &AsmCodeArray_IsrFunction[1]),//bd AsmCodeArray_IsrFunction
// ASMCodeArrayEx(ASMCODE_B_K, &AsmCodeArray_IsrFunction[1]),//bd AsmCodeArray_IsrFunction __asm_goto__(&AsmCodeArray_IsrFunction[1]), ASMCodeArray(ASMCODE_LD_k_A, 0x01u),//ld #1, a };
//声明函数指针ASMCodeExec来实际运行数组内的汇编代码
ASMCodeArray_FPtr ASMCodeExec = (ASMCodeArray_FPtr)AsmCodeArray_Function; ASMCodeExec();//调用数组内的汇编代码
3.在MCU/ARM/DSP上实现动态链接
哈哈~~数组要比代码好管理(删除,移动,变换,加密等等)的多~~~
|