From 748e8ba9e9afd67695ca62f3b691970f943071a6 Mon Sep 17 00:00:00 2001 From: Astatin Date: Tue, 24 Sep 2024 15:01:58 +0900 Subject: Add labels in go assembler --- instructions.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'instructions.go') 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 } -- cgit v1.2.3-70-g09d2