/
Trap.c
76 lines (67 loc) · 1.25 KB
/
Trap.c
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 <stdint.h>
#include <inttypes.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "32016.h"
#include "mem32016.h"
#include "defs.h"
#include "Trap.h"
#include "Profile.h"
uint32_t TrapFlags;
const char TrapText[TrapCount][40] =
{
"Break Point Hit",
"Break Point Trap",
"Reserved Addressing Mode",
"Unknown Format",
"Unknown Instruction",
"Divide By Zero",
"Illegal Immediate",
"Illegal DoubleIndexing",
"Illegal SpecialReading",
"Illegal SpecialWriting",
"Illegal Writing Immediate",
"Flag Instuction",
"Privileged Instruction"
};
void ShowTraps(void)
{
if (TrapFlags)
{
uint32_t Count, Pattern = BIT(0);
for (Count = 0; Count < TrapCount; Count++, Pattern <<= 1)
{
if (TrapFlags & Pattern)
{
TrapTRACE("%s\n", TrapText[Count]);
}
}
}
}
void Dump(void)
{
n32016_ShowRegs(0xFF);
ShowTraps();
TrapTRACE("\n");
ProfileDump();
}
void n32016_dumpregs(char* pMessage)
{
TrapTRACE("%s\n", pMessage);
Dump();
#ifdef PC_SIMULATION
#ifdef TRACE_TO_FILE
printf("\n");
#endif
#ifdef WIN32
system("pause");
#endif
CloseTrace();
exit(1);
#endif
}
void HandleTrap(void)
{
n32016_dumpregs("HandleTrap() called");
}