This repository has been archived by the owner on Jul 16, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
exec.S
77 lines (65 loc) · 2.19 KB
/
exec.S
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#include <defBF532.h> // includes also "def_LPBlackfin.h"
.data
.section .rodata
exec: .string "Exception!!!\r\nSEQSTAT = ";
.string "RETX = ";
.text
// write own exception routine to EVT
.global initexec;
initexec: [--SP] = RETS;
[--SP] = (P5:4);
P5.H = HI(EVT3); // write exception service routine to EVT3
P5.L = LO(EVT3);
P4.H = excephndler;
P4.L = excephndler;
[P5] = P4;
(P5:4) = [SP++];
RETS = [SP++];
RTS;
// catch exception, print out SEQSTAT and RETX
excephndler:[--SP] = RETS;
[--SP] = (R7:6, P5:5);
[--SP] = P0;
[--SP] = R0;
// save return address, this is the address where the exception
// occured
R6 = RETX;
// write information to terminal
P0.L = exec;
P0.H = exec;
CALL txstr;
R0 = SEQSTAT;
CALL txhex;
CALL txbr;
P0 += 1;
CALL txstr;
R0 = R6;
CALL txhex;
CALL txbr;
// set return adress to excepwait
P5.H = exceccrash;
P5.L = exceccrash;
RETX = P5;
R0 = [SP++];
P0 = [SP++];
(R7:6, P5:5) = [SP++];
RETS = [SP++];
// return to excepwait
RTX;
// in order for the information to be printed we have to leave the exceptino
// routine since the writing to uart is interrupt driven, but the exception has
// the highest priority, hence as long as we are in the exception handler
// nothing will be sent to the UART.
// Here we wait one second to allow UART to send the information, then close the
// console and loop forever until the user pushes the reset button
exceccrash:
P0.H = 0x16E3; # 1s @384.000MHz
P0.L = 0x6000;
LC0 = P0;
LOOP delay1 LC0;
LOOP_BEGIN delay1;
NOP; # Programming Manual S. 16-25
LOOP_END delay1;
R0 = 27 (X);
CALL txchr;
JUMP exceccrash;