Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nebula
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
exchain
nebula
Commits
3e1e76a9
Commit
3e1e76a9
authored
Sep 26, 2021
by
George Hotz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add tests passing
parent
971a7bde
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
3 deletions
+9
-3
MIPS.sol
contracts/MIPS.sol
+4
-1
main.go
mipsevm/main.go
+5
-2
No files found.
contracts/MIPS.sol
View file @
3e1e76a9
...
@@ -3,6 +3,7 @@ pragma solidity ^0.7.3;
...
@@ -3,6 +3,7 @@ pragma solidity ^0.7.3;
// https://inst.eecs.berkeley.edu/~cs61c/resources/MIPS_Green_Sheet.pdf
// https://inst.eecs.berkeley.edu/~cs61c/resources/MIPS_Green_Sheet.pdf
// https://uweb.engr.arizona.edu/~ece369/Resources/spim/MIPSReference.pdf
// https://uweb.engr.arizona.edu/~ece369/Resources/spim/MIPSReference.pdf
// https://en.wikibooks.org/wiki/MIPS_Assembly/Instruction_Formats
// This is a separate contract from the challenge contract
// This is a separate contract from the challenge contract
// Anyone can use it to validate a MIPS state transition
// Anyone can use it to validate a MIPS state transition
...
@@ -117,6 +118,8 @@ contract MIPS {
...
@@ -117,6 +118,8 @@ contract MIPS {
// TODO: replace with table
// TODO: replace with table
if (opcode == 8) { opcode = 0; func = 0x20; } // addi
if (opcode == 8) { opcode = 0; func = 0x20; } // addi
else if (opcode == 9) { opcode = 0; func = 0x21; } // addiu
else if (opcode == 9) { opcode = 0; func = 0x21; } // addiu
else if (opcode == 0xa) { opcode = 0; func = 0x2a; } // slti
else if (opcode == 0xb) { opcode = 0; func = 0x2B; } // sltiu
else if (opcode == 0xc) { opcode = 0; func = 0x24; } // andi
else if (opcode == 0xc) { opcode = 0; func = 0x24; } // andi
else if (opcode == 0xd) { opcode = 0; func = 0x25; } // ori
else if (opcode == 0xd) { opcode = 0; func = 0x25; } // ori
else if (opcode == 0xe) { opcode = 0; func = 0x26; } // xori
else if (opcode == 0xe) { opcode = 0; func = 0x26; } // xori
...
@@ -133,7 +136,7 @@ contract MIPS {
...
@@ -133,7 +136,7 @@ contract MIPS {
return rs-rt; // sub or subu
return rs-rt; // sub or subu
} else if (func == 0x2a) {
} else if (func == 0x2a) {
return int32(rs)<int32(rt) ? 1 : 0; // slt
return int32(rs)<int32(rt) ? 1 : 0; // slt
} else if (func == 0x2
6
) {
} else if (func == 0x2
B
) {
return rs<rt ? 1 : 0; // sltu
return rs<rt ? 1 : 0; // sltu
// Shift and ShiftV
// Shift and ShiftV
} else if (func == 0x00) { return rt << shamt; // sll
} else if (func == 0x00) { return rt << shamt; // sll
...
...
mipsevm/main.go
View file @
3e1e76a9
...
@@ -213,13 +213,16 @@ func main() {
...
@@ -213,13 +213,16 @@ func main() {
// 19.100079097s for 1_000_000 new steps
// 19.100079097s for 1_000_000 new steps
//steps := 1000000
//steps := 1000000
//debug = true
//debug = true
files
,
err
:=
ioutil
.
ReadDir
(
"test/bin"
)
files
,
err
:=
ioutil
.
ReadDir
(
"test/bin"
)
if
err
!=
nil
{
if
err
!=
nil
{
log
.
Fatal
(
err
)
log
.
Fatal
(
err
)
}
}
for
_
,
f
:=
range
files
{
for
_
,
f
:=
range
files
{
runTest
(
"test/bin/"
+
f
.
Name
(),
2
0
,
interpreter
,
bytecode
)
runTest
(
"test/bin/"
+
f
.
Name
(),
10
0
,
interpreter
,
bytecode
)
}
}
/*debug = true
runTest("test/bin/add.bin", 20, interpreter, bytecode)*/
}
}
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