Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Shen, Siran
arm11_
Commits
442454c2
Commit
442454c2
authored
May 31, 2020
by
sea19
Browse files
decode testing
parent
de38530f
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/emulate.c
View file @
442454c2
#include <stdlib.h>
#include <stdio.h>
#include <assert.h>
#include <math.h>
int
*
readFile
(
char
*
filename
)
{
int
*
objectCode
=
calloc
(
16384
,
sizeof
(
int
));
//Creates a pointer with allocated space of 64KB
...
...
@@ -29,19 +29,31 @@ void initialiseRegisters(int *registers) {
}
}
/*
void decode(int instruction, int programcounter) { //Decode started but not working yet
void
decode
(
int
instruction
,
int
programcounter
)
{
//Decode started but not working yet
enum
instrSet
{
dataProcess
,
mul
,
singleData
,
branch
};
enum
instrSet
instrType
;
if ((2^27 + 2^26) & instruction == 0) {
int
bit26and27
=
134217728
+
67108864
;
if
((
bit26and27
&
instruction
)
==
0
)
{
instrType
=
dataProcess
;
}
else
if
((
bit26and27
&
instruction
)
==
67108864
)
{
instrType
=
singleData
;
}
else
if
((
bit26and27
&
instruction
)
==
134217728
)
{
instrType
=
branch
;
}
switch (instrType) {
/*switch (instrType) {
case dataProcess:
decodeDataProcess(instruction, programcounter);
break;
}
}/*
}*/
}
void
decodeBranch
(
int
instruction
,
int
pc
)
{
int
cond
=
(
instruction
&
-
268435456
)
/
26843546
;
printf
(
"%d
\n
"
,
cond
);
}
/*void decodeDataProcess(int instruction, int pc, char* decodedData) {
int opcode = ((2^24 + 2^23 + 2^22 + 2^21) & instruction) / (2^21)
...
...
@@ -72,17 +84,20 @@ void initialiseRegisters(int *registers) {
void
startCycle
(
int
*
objectcode
,
int
*
registers
)
{
int
pc
=
registers
[
15
];
//pc takes the value of the program counter
int
fetchedInstr
=
NULL
;
char
*
decodedInstr
=
NULL
;
if
(
pc
==
0
)
{
fetch
(
objectcode
,
pc
);
fetchedInstr
=
fetch
(
objectcode
,
pc
);
pc
=
pc
+
4
;
}
else
if
(
pc
==
4
)
{
fetch
(
objectcode
,
pc
/
4
);
decode
(
objectcode
,
(
pc
/
4
-
1
));
fetch
(
objectcode
,
pc
/
4
);
pc
=
pc
+
4
;
}
else
{
//execute(objectcode, (pc/4 - 2));
decode
(
objectcode
,
(
pc
/
4
-
1
));
fetch
(
objectcode
,
pc
/
4
);
decode
(
objectcode
,
(
pc
/
4
-
1
));
execute
(
objectcode
,
(
pc
/
4
-
2
));
pc
=
pc
+
4
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment