aboutsummaryrefslogtreecommitdiff
path: root/instructions.go
diff options
context:
space:
mode:
authorAstatin <[email protected]>2024-09-24 15:01:58 +0900
committerAstatin <astatin@redacted>2024-09-24 15:01:58 +0900
commit748e8ba9e9afd67695ca62f3b691970f943071a6 (patch)
tree0bc707517ca95fe02e046a11616b18fbd685aa1f /instructions.go
parent1680bc5146b25d3631e6b7bfee3946ef59d906fd (diff)
Add labels in go assembler
Diffstat (limited to 'instructions.go')
-rw-r--r--instructions.go9
1 files changed, 6 insertions, 3 deletions
diff --git a/instructions.go b/instructions.go
index e78dbab..32e2794 100644
--- a/instructions.go
+++ b/instructions.go
@@ -5,7 +5,7 @@ import (
"strings"
)
-type ParamType func(param string) (uint16, error)
+type ParamType func(state *ProgramState, param string) (uint16, error)
type InstructionParams struct {
Types []ParamType
@@ -392,7 +392,10 @@ func InstructionSetNew() InstructionSet {
return result
}
-func (set InstructionSet) Parse(line string) ([]byte, error) {
+func (set InstructionSet) Parse(
+ state *ProgramState,
+ line string,
+) ([]byte, error) {
words := strings.Fields(strings.ReplaceAll(strings.Trim(line, " \t\n"), ",", " "))
if len(words) < 1 {
@@ -414,7 +417,7 @@ instruction_param_loop:
parsed_params := make([]uint16, len(params))
for i, paramType := range instrParam.Types {
- parsed, err := paramType(params[i])
+ parsed, err := paramType(state, params[i])
if err != nil {
continue instruction_param_loop
}