📄 vectors.s
字号:
.file "vectors.s"/* General notice: * This code is part of a boot-monitor package developed as a generic base * platform for embedded system designs. As such, it is likely to be * distributed to various projects beyond the control of the original * author. Please notify the author of any enhancements made or bugs found * so that all may benefit from the changes. In addition, notification back * to the author will allow the new user to pick up changes that may have * been made by other users after this version of the code was distributed. * * Author: Ed Sutter * email: esutter@lucent.com (home: lesutter@worldnet.att.net) * phone: 908-582-2351 (home: 908-889-5161) */ .import _regtbl .import _exception .import _exceptionCause .import _MonStackEnd .globl _resume .globl _gotoexception .text/***************************************************************************** * * gotoexception: * When this code is executed as part of the exception processing, * it is assumed that R0 contains the vector number and the actual * value that was in R0 prior to the exception has been pushed onto * the stack. * The general exception handling process within the monitor is that any * exception taken will cause some kind of entry into the monitor code * with the array regtbl[] filled with the CPU context at the time of the * exception. When the monitor determines (either internally or through a * command issued by the user) that it is to return control to the application, * it calls resume() to load all of the registers with the values stored in * regtbl[]. */gotoexception: mov.l r0,@-r15 /* Push R0 onto stack so that it can be used */ mov.l p_regtbl,r0 /* to point to the register store table. */ mov.l r1,@(4,r0) /* Save R1 */ mov.l r2,@(8,r0) /* Save R2 */ mov.l r3,@(12,r0) /* Save R3 */ mov.l r4,@(16,r0) /* Save R4 */ mov.l r5,@(20,r0) /* Save R5 */ mov.l r6,@(24,r0) /* Save R6 */ mov.l r7,@(28,r0) /* Save R7 */ mov.l r8,@(32,r0) /* Save R8 */ mov.l r9,@(36,r0) /* Save R9 */ mov.l r10,@(40,r0) /* Save R10 */ mov.l r11,@(44,r0) /* Save R11 */ mov.l r12,@(48,r0) /* Save R12 */ mov.l r13,@(52,r0) /* Save R13 */ mov.l r14,@(56,r0) /* Save R14 */ mov.l @r15+,r0 /* Pull vector number off stack and put it */ mov.l p_exceptionCause,r1 /* into the ExceptionCause variable. */ mov.l r0,@r1 mov.l @r15+,r0 /* Pull R0 off stack and now use R1 to point */ mov.l p_regtbl,r1 /* to register store table. */ mov.l r0,@r1 /* Save R0 */ mov.l r15,@(60,r1) /* Save R15 */ mov.l @r15,r0 /* Pull PC off stack and put it in register */ add #64,r1 /* store table. */ mov.l r0,@r1 mov.l @(4,r15),r0 /* Pull SR off stack and put it in register */ add #4,r1 /* store table. */ mov.l r0,@r1 add #4,r1 /* Save PR */ sts pr,r8 mov.l r8,@r1 mov.l p_MonStackEnd,r8 /* Load the monitor's stack poniter. */ mov.l @r8,r15 mov.l p_exception,r8 /* Jump to C-level exception handler. */ jmp @r8 nop/***************************************************************************** * * resume: * This function basically does just the opposite of what gotoexception does. * It loads each of the registers with what has been loaded into the regtbl[] * array and does an rte to load the PC and SR. * NOT WORKING YET!!! */_resume: mov.l p_regtbl,r0 /* Load R0 with regtbl[PC]. */ add #64,r0 mov.l @r0,r0 mov.l p_regtbl,r1 /* Load R1 with regtbl[SP]. */ mov.l @(60,r1),r1 mov.l r0,@r1 /* Place the regtbl[PC] value at the location */ /* pointed to be regtbl[SP]. */ mov.l p_regtbl,r0 /* Load R0 with regtbl[SR]. */ add #68,r0 mov.l @r0,r0 mov.l r0,@(4,r1) /* Place the regtbl[SR] value at the location */ /* pointed to be regtbl[SP] + 4. */ mov.l p_regtbl,r0 /* Load R0 with regtbl[PR]. */ add #72,r0 /* Restore PR */ mov.l @r0,r0 lds r0,pr /* At this point, the new stack is prepared for the rte. * Now just transfer all registers from regtbl[] to the actual registers... */ mov.l p_regtbl,r0 /* Load R0 with pointer regtbl[]. */ mov.l @(4,r0),r1 /* Restore R1 */ mov.l @(8,r0),r2 /* Restore R2 */ mov.l @(12,r0),r3 /* Restore R3 */ mov.l @(16,r0),r4 /* Restore R4 */ mov.l @(20,r0),r5 /* Restore R5 */ mov.l @(24,r0),r6 /* Restore R6 */ mov.l @(28,r0),r7 /* Restore R7 */ mov.l @(32,r0),r8 /* Restore R8 */ mov.l @(36,r0),r9 /* Restore R9 */ mov.l @(40,r0),r10 /* Restore R10 */ mov.l @(44,r0),r11 /* Restore R11 */ mov.l @(48,r0),r12 /* Restore R12 */ mov.l @(52,r0),r13 /* Restore R13 */ mov.l @(56,r0),r14 /* Restore R14 */ mov.l @(60,r0),r15 /* Restore R15 */ mov.l @r0,r0 /* Restore R0 */ rte nop .align 2p_regtbl: .long _regtblp_exception: .long _exceptionp_exceptionCause: .long _exceptionCausep_MonStackEnd: .long _MonStackEnd/*************************************************************************** * * Vector[4-255]: * At reset, the VBR points to address 0. At this location there is a minimum * vector table containing the PC/SP for a manual and power-on reset. * The function vinit() (C code) re-establishes the VBR and loads one of these * exception handlers for each vector table entry. They are all identical * except that after pushing R0 onto the stack, they load R0 with the * vector number. */ .globl _Vector4_Vector4: mov.l r0,@-r15 /* Push R0 onto the stack. */ bra gotoexception /* Branch to the main exception handler with the */ mov #4,r0 /* delay slot loading R0 with the vector number. */ .globl _Vector5_Vector5: mov.l r0,@-r15 bra gotoexception mov #5,r0 .globl _Vector6_Vector6: mov.l r0,@-r15 bra gotoexception mov #6,r0 .globl _Vector7_Vector7: mov.l r0,@-r15 bra gotoexception mov #7,r0 .globl _Vector8_Vector8: mov.l r0,@-r15 bra gotoexception mov #8,r0 .globl _Vector9_Vector9: mov.l r0,@-r15 bra gotoexception mov #9,r0 .globl _Vector10_Vector10: mov.l r0,@-r15 bra gotoexception mov #10,r0 .globl _Vector11_Vector11: mov.l r0,@-r15 bra gotoexception mov #11,r0 .globl _Vector12_Vector12: mov.l r0,@-r15 bra gotoexception mov #12,r0 .globl _Vector13_Vector13: mov.l r0,@-r15 bra gotoexception mov #13,r0 .globl _Vector14_Vector14: mov.l r0,@-r15 bra gotoexception mov #14,r0 .globl _Vector15_Vector15: mov.l r0,@-r15 bra gotoexception mov #15,r0 .globl _Vector16_Vector16: mov.l r0,@-r15 bra gotoexception mov #16,r0 .globl _Vector17_Vector17: mov.l r0,@-r15 bra gotoexception mov #17,r0 .globl _Vector18_Vector18: mov.l r0,@-r15 bra gotoexception mov #18,r0 .globl _Vector19_Vector19: mov.l r0,@-r15 bra gotoexception mov #19,r0 .globl _Vector20_Vector20: mov.l r0,@-r15 bra gotoexception mov #20,r0 .globl _Vector21_Vector21: mov.l r0,@-r15 bra gotoexception mov #21,r0 .globl _Vector22_Vector22: mov.l r0,@-r15 bra gotoexception mov #22,r0 .globl _Vector23_Vector23: mov.l r0,@-r15 bra gotoexception mov #23,r0 .globl _Vector24_Vector24: mov.l r0,@-r15 bra gotoexception mov #24,r0 .globl _Vector25_Vector25: mov.l r0,@-r15 bra gotoexception mov #25,r0 .globl _Vector26_Vector26: mov.l r0,@-r15 bra gotoexception mov #26,r0 .globl _Vector27_Vector27: mov.l r0,@-r15 bra gotoexception mov #27,r0 .globl _Vector28_Vector28: mov.l r0,@-r15 bra gotoexception mov #28,r0 .globl _Vector29_Vector29: mov.l r0,@-r15 bra gotoexception mov #29,r0 .globl _Vector30_Vector30: mov.l r0,@-r15 bra gotoexception mov #30,r0 .globl _Vector31_Vector31: mov.l r0,@-r15 bra gotoexception mov #31,r0 .globl _Vector32_Vector32: mov.l r0,@-r15 bra gotoexception mov #32,r0 .globl _Vector33_Vector33: mov.l r0,@-r15 bra gotoexception mov #33,r0 .globl _Vector34_Vector34: mov.l r0,@-r15 bra gotoexception mov #34,r0 .globl _Vector35_Vector35: mov.l r0,@-r15 bra gotoexception mov #35,r0 .globl _Vector36_Vector36: mov.l r0,@-r15 bra gotoexception mov #36,r0 .globl _Vector37_Vector37: mov.l r0,@-r15 bra gotoexception mov #37,r0 .globl _Vector38_Vector38: mov.l r0,@-r15 bra gotoexception mov #38,r0 .globl _Vector39_Vector39: mov.l r0,@-r15 bra gotoexception mov #39,r0 .globl _Vector40_Vector40: mov.l r0,@-r15 bra gotoexception mov #40,r0 .globl _Vector41_Vector41: mov.l r0,@-r15 bra gotoexception mov #41,r0 .globl _Vector42_Vector42: mov.l r0,@-r15 bra gotoexception mov #42,r0 .globl _Vector43_Vector43: mov.l r0,@-r15 bra gotoexception mov #43,r0 .globl _Vector44_Vector44: mov.l r0,@-r15 bra gotoexception mov #44,r0 .globl _Vector45_Vector45: mov.l r0,@-r15 bra gotoexception mov #45,r0 .globl _Vector46_Vector46: mov.l r0,@-r15 bra gotoexception mov #46,r0 .globl _Vector47_Vector47: mov.l r0,@-r15 bra gotoexception mov #47,r0 .globl _Vector48_Vector48: mov.l r0,@-r15 bra gotoexception mov #48,r0 .globl _Vector49_Vector49: mov.l r0,@-r15 bra gotoexception mov #49,r0 .globl _Vector50_Vector50: mov.l r0,@-r15 bra gotoexception mov #50,r0 .globl _Vector51_Vector51: mov.l r0,@-r15 bra gotoexception mov #51,r0 .globl _Vector52_Vector52: mov.l r0,@-r15 bra gotoexception mov #52,r0 .globl _Vector53_Vector53: mov.l r0,@-r15 bra gotoexception mov #53,r0 .globl _Vector54_Vector54: mov.l r0,@-r15 bra gotoexception mov #54,r0 .globl _Vector55_Vector55: mov.l r0,@-r15 bra gotoexception mov #55,r0 .globl _Vector56_Vector56: mov.l r0,@-r15 bra gotoexception mov #56,r0 .globl _Vector57_Vector57: mov.l r0,@-r15 bra gotoexception mov #57,r0 .globl _Vector58_Vector58: mov.l r0,@-r15 bra gotoexception mov #58,r0 .globl _Vector59_Vector59: mov.l r0,@-r15 bra gotoexception mov #59,r0 .globl _Vector60_Vector60: mov.l r0,@-r15 bra gotoexception mov #60,r0 .globl _Vector61_Vector61: mov.l r0,@-r15 bra gotoexception mov #61,r0 .globl _Vector62_Vector62: mov.l r0,@-r15 bra gotoexception mov #62,r0 .globl _Vector63_Vector63: mov.l r0,@-r15 bra gotoexception mov #63,r0 .globl _Vector64_Vector64: mov.l r0,@-r15 bra gotoexception mov #64,r0 .globl _Vector65_Vector65: mov.l r0,@-r15 bra gotoexception mov #65,r0 .globl _Vector66_Vector66: mov.l r0,@-r15 bra gotoexception mov #66,r0 .globl _Vector67_Vector67: mov.l r0,@-r15 bra gotoexception mov #67,r0 .globl _Vector68_Vector68: mov.l r0,@-r15 bra gotoexception mov #68,r0 .globl _Vector69_Vector69: mov.l r0,@-r15 bra gotoexception mov #69,r0 .globl _Vector70
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -