Skip to content

Commit 867b778

Browse files
committed
Incresed kernal registers
1 parent a70b402 commit 867b778

File tree

7 files changed

+401
-263
lines changed

7 files changed

+401
-263
lines changed

Diff for: .gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
*~
2+
xsm

Diff for: data.h

+29-21
Original file line numberDiff line numberDiff line change
@@ -17,29 +17,37 @@
1717
#define R6 6
1818
#define R7 7
1919

20-
#define R8 8
21-
#define R9 9
22-
#define R10 10
23-
#define R11 11
24-
#define R12 12
25-
#define R13 13
26-
#define R14 14
27-
#define R15 15
28-
29-
#define T0 16
30-
#define T1 17
31-
#define T2 18
32-
#define T3 19
33-
34-
#define BP_REG 20
35-
#define IP_REG 21
36-
#define SP_REG 22
37-
#define PTBR_REG 23
38-
#define PTLR_REG 24
39-
#define EFR_REG 25
20+
#define S0 8
21+
#define S1 9
22+
#define S2 10
23+
#define S3 11
24+
#define S4 12
25+
#define S5 13
26+
#define S6 14
27+
#define S7 15
28+
#define S8 16
29+
#define S9 17
30+
#define S10 18
31+
#define S11 19
32+
#define S12 20
33+
#define S13 21
34+
#define S14 22
35+
#define S15 23
36+
37+
#define T0 24
38+
#define T1 25
39+
#define T2 26
40+
#define T3 27
41+
42+
#define BP_REG 28
43+
#define IP_REG 29
44+
#define SP_REG 30
45+
#define PTBR_REG 31
46+
#define PTLR_REG 32
47+
#define EFR_REG 33
4048

4149
#define NO_USER_REG 8
42-
#define NO_SYS_REG 8
50+
#define NO_SYS_REG 16
4351
#define NO_TEMP_REG 4
4452
#define NO_SPECIAL_REG 6
4553

Diff for: decode.lex

+65-8
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
result = len; \
1212
}
1313
char tempbuf[16];
14+
int tempnum;
1415
void get_lexdata(char buf1[],char buf2[]);
1516
%}
1617

@@ -55,8 +56,30 @@ IP { yylval.flag=IP; yylval.flag2=0; return(0); }
5556
PTBR { yylval.flag=PTBR; yylval.flag2=0; return(0); }
5657
PTLR { yylval.flag=PTLR; yylval.flag2=0; return(0); }
5758
EFR { yylval.flag=EFR; yylval.flag2=0; return(0); }
58-
R[0-9]+ { yylval.flag=REG; yylval.flag2=0; yytext++; return(atoi(yytext)); }
59-
T[0-9]+ { yylval.flag=REG; yylval.flag2=0; yytext++; return(atoi(yytext) + T0); }
59+
R[0-9]+ {
60+
yylval.flag=REG; yylval.flag2=0;
61+
yytext++;
62+
tempnum = atoi(yytext);
63+
if(tempnum > 7)
64+
return ILLREG;
65+
return(tempnum + R0);
66+
}
67+
S[0-9]+ {
68+
yylval.flag=REG; yylval.flag2=0;
69+
yytext++;
70+
tempnum = atoi(yytext);
71+
if(tempnum > 15)
72+
return ILLREG;
73+
return(tempnum + S0);
74+
}
75+
T[0-9]+ {
76+
yylval.flag=REG; yylval.flag2=0;
77+
yytext++;
78+
tempnum = atoi(yytext);
79+
if(tempnum > 3)
80+
return ILLREG;
81+
return(tempnum + T0);
82+
}
6083
\[SP\] { yylval.flag=MEM_SP; yylval.flag2=0; return(0); }
6184
\[BP\] { yylval.flag=MEM_BP; yylval.flag2=0; return(0); }
6285
\[IP\] { yylval.flag=MEM_IP; yylval.flag2=0; return(0); } //error: Is this needed.
@@ -67,13 +90,28 @@ T[0-9]+ { yylval.flag=REG; yylval.flag2=0; yytext++; return(atoi(yytext) + T0);
6790
yylval.flag=MEM_REG; yylval.flag2=0;
6891
yytext[yyleng-1]='\0';
6992
yytext=yytext+2;
70-
return(atoi(yytext));
71-
}
93+
tempnum = atoi(yytext);
94+
if(tempnum > 7)
95+
return ILLREG;
96+
return(tempnum + R0);
97+
}
98+
\[S[0-9]+\] {
99+
yylval.flag=MEM_REG; yylval.flag2=0;
100+
yytext[yyleng-1]='\0';
101+
yytext=yytext+2;
102+
tempnum = atoi(yytext);
103+
if(tempnum > 15)
104+
return ILLREG;
105+
return(tempnum + S0);
106+
}
72107
\[T[0-9]+\] {
73108
yylval.flag=MEM_REG; yylval.flag2=0;
74109
yytext[yyleng-1]='\0';
75110
yytext=yytext+2;
76-
return(atoi(yytext) + T0);
111+
tempnum = atoi(yytext);
112+
if(tempnum > 3)
113+
return ILLREG;
114+
return(tempnum + T0);
77115
}
78116
-?[0-9]+ { yylval.flag=NUM; yylval.flag2=0; return(atoi(yytext)); }
79117
\[[0-9]+\] {
@@ -86,14 +124,33 @@ T[0-9]+ { yylval.flag=REG; yylval.flag2=0; yytext++; return(atoi(yytext) + T0);
86124
yylval.flag=MEM_DIR_REG;
87125
yytext++;
88126
get_lexdata(yytext,tempbuf); //Not at all tested. Vulnerable ***
89-
yylval.flag2=atoi(tempbuf);
127+
tempnum = atoi(tempbuf);
128+
if(tempnum > 7)
129+
yylval.flag2 = ILLREG;
130+
else
131+
yylval.flag2= tempnum + R0;
132+
return(atoi(yytext));
133+
}
134+
\[-?[0-9]+\]S[0-9]+ {
135+
yylval.flag=MEM_DIR_REG;
136+
yytext++;
137+
get_lexdata(yytext,tempbuf); //Not at all tested. Vulnerable ***
138+
tempnum = atoi(tempbuf);
139+
if(tempnum > 15)
140+
yylval.flag2 = ILLREG;
141+
else
142+
yylval.flag2= tempnum + S0;
90143
return(atoi(yytext));
91144
}
92145
\[-?[0-9]+\]T[0-9]+ {
93146
yylval.flag=MEM_DIR_REG;
94147
yytext++;
95148
get_lexdata(yytext,tempbuf); //Not at all tested. Vulnerable ***
96-
yylval.flag2=atoi(tempbuf) + T0;
149+
tempnum = atoi(tempbuf);
150+
if(tempnum > 3)
151+
yylval.flag2 = ILLREG;
152+
else
153+
yylval.flag2= tempnum + T0;
97154
return(atoi(yytext));
98155
}
99156
\[-?[0-9]+\]SP {
@@ -175,7 +232,7 @@ void get_lexdata(char buf1[],char buf2[]) //Not at all tested. Vulnerable ***
175232
flag = 1;
176233
j=0;
177234
buf1[i]='\0';
178-
if(buf1[i+1] == 'R' || buf1[i+1] == 'T')
235+
if(buf1[i+1] == 'R' || buf1[i+1] == 'S' || buf1[i+1] == 'T')
179236
{
180237
i++;
181238
buf1[i]='\0';

Diff for: instr.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,4 @@
6666
#define MEM_DIR_EFR 62
6767
#define MEM_DIR_IN 63
6868

69-
69+
#define ILLREG 64

0 commit comments

Comments
 (0)