-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdebugsc11.c
More file actions
137 lines (119 loc) · 5.24 KB
/
debugsc11.c
File metadata and controls
137 lines (119 loc) · 5.24 KB
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
//*******************************************************************************************************
//*******************************************************************************************************
//
// Name: DebugSc11.C
// Purpose: Debug Screen Display (TMS1100)
// Author: Paul Robson
// Date: 2nd February 2014
//
//*******************************************************************************************************
//*******************************************************************************************************
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "general.h"
#include "core11.h"
#include "hardware.h"
#include "hwinterface.h"
#include "debugsc11.h"
static void DB11_PrintString(int x,int y,char *text,int fgr);
static void DB11_PrintHex(int x,int y,int n,int fgr,int w);
static int currentAddress = 0x3C0;
#include "mnemonics11.h"
//*******************************************************************************************************
// Draw the debugger screen
//*******************************************************************************************************
void DB11_Draw()
{
char *labels[] = { "A","X","Y","XY","M","ST","O","CL","SL","CT","DB",
"CA","PA","PC","CB","CS","PB","SR","LP","DC","PO","BK",NULL };
int i = 0;
while (labels[i] != NULL)
{
DB11_PrintString(12+(i/11)*6,i % 11,labels[i],i == 19 ? 5 : 2);
i++;
}
C11_STATUS *s = C11_GetStatus(NULL);
DB11_PrintHex(15,0,s->a,3,1);
DB11_PrintHex(15,1,s->x,3,1);
DB11_PrintHex(15,2,s->y,3,1);
DB11_PrintHex(15,3,s->xy,3,2);
DB11_PrintHex(15,4,s->memxy,3,1);
DB11_PrintHex(15,5,s->status,3,1);
DB11_PrintHex(15,6,s->o,3,2);
DB11_PrintHex(15,7,s->cl,3,1);
DB11_PrintHex(15,8,s->sl,3,1);
DB11_PrintHex(21,0,s->ca,3,1);
DB11_PrintHex(21,1,s->pa,3,1);
DB11_PrintHex(21,2,s->pc,3,2);
DB11_PrintHex(21,3,s->cb,3,1);
DB11_PrintHex(21,4,s->cs,3,1);
DB11_PrintHex(21,5,s->pb,3,1);
DB11_PrintHex(21,6,s->sr,3,2);
DB11_PrintHex(21,10,s->breakPoint,3,3);
HWI_STATUS *s2 = HWIGetStatus(NULL);
DB11_PrintHex(15,9,s2->addressedLatchCounter,3,1);
DB11_PrintHex(15,10,s2->dataBus,3,1);
DB11_PrintHex(21,7,s2->latchPulse,3,1);
DB11_PrintHex(21,8,s2->notDataClock,3,1);
DB11_PrintString(21,9,s2->polarity ? "+":"-",3);
i = s2->polaritySwitchFrequency;if (i > 99) i = 99;
DB11_PrintHex(26,10,i,3,3);
DB11_PrintString(30,10,"Hz",3);
for (i = 0;i <= 22;i++) {
int addr = (currentAddress + i - 4) & 0x7FF;
int opcode = s->codeMemory[addr];
DB11_PrintHex(0,i,addr,(addr == s->pctr) ? 3 : 2,3);
if (i == 4) DB11_PrintString(3,i,":",2);
DB11_PrintString(4,i,_mnemonics[opcode],(addr == s->pctr) ? 3 : 2);
}
for (i = 0;i < 16;i++) {
DB11_PrintHex(15+i,12,i,2,1);
if (i < 8) DB11_PrintHex(12,i+15,i*16,2,2);
if (i <= 7) DB11_PrintHex(15+i,13,s2->addressedLatches[i],(i == s2->addressedLatchCounter) ? 3 : 6,1);
if (i <= 10) DB11_PrintHex(15+i,14,s->rLatches[i] ? 1 : 0,(i == s->y) ? 3 : 6,1);
}
for (i = 0;i < 128;i++) {
DB11_PrintHex(15+i%16,15+i/16,s->dataMemory[i],(i == s->xy) ? 3 : 6,1);
}
DB11_PrintString(12,14,"RL",2);
DB11_PrintString(12,13,"AL",2);
}
//*******************************************************************************************************
// Print a string
//*******************************************************************************************************
static void DB11_PrintString(int x,int y,char *text,int fgr)
{
while (*text != '\0')
{
IF_Write(x++,y,*text++,fgr);
}
}
//*******************************************************************************************************
// Print a hexadecimal constant
//*******************************************************************************************************
static void DB11_PrintHex(int x,int y,int n,int fgr,int w)
{
char buffer[9];
sprintf(buffer,"%0*x",w,n);
ASSERT(strlen(buffer) <= 8);
DB11_PrintString(x,y,buffer,fgr);
}
//*******************************************************************************************************
// Set Display Address
//*******************************************************************************************************
void DB11_SetAddress(int addr) {
currentAddress = addr;
}
//*******************************************************************************************************
// Get Display Address
//*******************************************************************************************************
int DB11_GetAddress() {
return currentAddress;
}
//*******************************************************************************************************
// Shift digit into current address
//*******************************************************************************************************
void DB11_UpdateAddress(int digit) {
currentAddress = ((currentAddress << 4) | digit) & 0x7FF;
}