except.c
来自「《嵌入式固件开发》一书的源码」· C语言 代码 · 共 68 行
C
68 行
/* except.c: This code handles exceptions that are caught by the exception vectors that have been installed by the monitor through vinit(). 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)*/#include "config.h"#include "cpu.h"#include "cpuio.h"#include "genlib.h"#include "stddefs.h"#include "monapp.h"ulong ExceptionAddr;int ExceptionType;extern int getreg(), putreg();extern void putsr(ushort);voidexception(void){ ulong vnum, pc; putsr(0x2700); getreg("D0",&vnum); vnum &= 0xff; getreg("PC",&pc); ExceptionAddr = pc; ExceptionType = vnum; monrestart(EXCEPTION);}voidvinit(){ extern void vbase(), vnext(); extern ulong resetPC, resetSP; ulong *vtab; ulong vfunc; int i, delta; /* Vector table is first 0x400 bytes of RAM starting at zero... */ vtab = (ulong *)0; /* Special case for vtab[0] and vtab[1]: */ vtab[0] = resetSP; vtab[1] = resetPC; vfunc = (ulong)vbase; delta = (ulong)vnext - (ulong)vbase; for(i=2;i<256;i++) { vtab[i] = (ulong)vfunc; vfunc += delta; }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?