-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Simple file read, color print, include interception
- Loading branch information
DerelictDrone
committed
Nov 16, 2023
1 parent
ab77d1e
commit c2e89b5
Showing
13 changed files
with
119 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
CPUTest = {} | ||
|
||
function CPUTest:RunTest(VM,TestSuite) | ||
CPUTest.VM = VM | ||
CPUTest.TestSuite = TestSuite | ||
-- Loads a file from the testing directory and returns it as a str | ||
local src = TestSuite:LoadFile("file_example.txt") | ||
TestSuite.Compile(src,nil,CPUTest.RunCPU,CPUTest.CompileError) | ||
end | ||
|
||
function CPUTest.RunCPU() | ||
CPUTest.TestSuite.FlashData(CPUTest.VM,CPUTest.TestSuite.GetCompileBuffer()) -- upload compiled to virtual cpu | ||
CPUTest.VM.Clk = 1 | ||
for i=0,4096 do | ||
CPUTest.VM:RunStep() | ||
end | ||
-- False = no error, True = error | ||
if CPUTest.VM.R0 == 4096 then | ||
CPUTest.TestSuite.FinishTest(false) | ||
else | ||
print("R0 is not 4096! R0 is "..tostring(CPUTest.VM.R0)) | ||
CPUTest.TestSuite.FinishTest(true) | ||
end | ||
end | ||
|
||
function CPUTest.CompileError() | ||
print('hit a compile time error') | ||
CPUTest.TestSuite.FinishTest(true) | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
x: | ||
INC R0 | ||
JMP x |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
CPUTest = {} | ||
|
||
function CPUTest:RunTest(VM,TestSuite) | ||
CPUTest.VM = VM | ||
CPUTest.TestSuite = TestSuite | ||
-- Loads a file from the testing directory and returns it as a str | ||
local src = TestSuite:LoadFile("includes_1.txt") | ||
TestSuite.Compile(src,nil,CPUTest.RunCPU,CPUTest.CompileError) | ||
end | ||
|
||
function CPUTest.RunCPU() | ||
CPUTest.TestSuite.FlashData(CPUTest.VM,CPUTest.TestSuite.GetCompileBuffer()) -- upload compiled to virtual cpu | ||
CPUTest.VM.Clk = 1 | ||
for i=0,16 do | ||
CPUTest.VM:RunStep() | ||
end | ||
-- False = no error, True = error | ||
if CPUTest.VM.R0 == 2 then | ||
CPUTest.TestSuite.FinishTest(false) | ||
else | ||
print("R0 is not 2! R0 is "..tostring(CPUTest.VM.R0)) | ||
CPUTest.TestSuite.FinishTest(true) | ||
end | ||
end | ||
|
||
function CPUTest.CompileError(msg) | ||
CPUTest.TestSuite.Error('hit a compile time error '..msg) | ||
CPUTest.TestSuite.FinishTest(true) | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#include <includes_2.txt> | ||
ADD R0,1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
MOV R0,1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters