Programs are now loaded with a function and not a member var

This commit is contained in:
Sasha Koshka
2022-09-08 14:41:50 -04:00
parent 3be08736b4
commit b0068336cd
4 changed files with 20 additions and 13 deletions

View File

@@ -9,7 +9,8 @@ func main () {
// this is a simple echo program. it will take in input indefinetly and
// repeat it. due to line buffering in the terminal however, it will
// only print output once you have pressed enter.
machine := cre.Machine[int] { Program: []int {
machine := cre.Machine[int] {}
machine.LoadProgram([]int {
cre.PUSH, 0,
cre.CAL,
@@ -19,7 +20,7 @@ func main () {
cre.PUSH, 1,
cre.PUSH, 0,
cre.JMP,
}}
})
machine.Register (0, read)
machine.Register (1, write)

View File

@@ -20,7 +20,8 @@ func main () {
responseStart := 71
responseLoopStart := 50
machine := cre.Machine[int] { Program: []int {
machine := cre.Machine[int] {}
machine.LoadProgram([]int {
// reset x
cre.PUSH, introStart,
cre.PUSH, x,
@@ -108,7 +109,7 @@ func main () {
cre.PUSH, 1,
cre.PUSH, responseLoopStart,
cre.JMP,
}}
})
stringData := []byte (
"\x00" +