Programs are now loaded with a function and not a member var
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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" +
|
||||
|
||||
Reference in New Issue
Block a user