From b5b9637ff2d222841632b8644b94835ec1c93359 Mon Sep 17 00:00:00 2001 From: Astatin Date: Tue, 7 Jan 2025 16:20:52 +0900 Subject: Add label offset + allow to use labels with .DB macro + relative labels --- instructions.go | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'instructions.go') diff --git a/instructions.go b/instructions.go index 59daa3a..ddcb833 100644 --- a/instructions.go +++ b/instructions.go @@ -8,10 +8,11 @@ import ( type ParamType func(labels *Labels, defs *Definitions, param string) (uint16, error) type InstructionParams struct { - Types []ParamType - Assembler func(currentAddress uint16, args []uint16) ([]uint8, error) - Wildcard bool - MacroForbidden bool + Types []ParamType + Assembler func(currentAddress uint16, args []uint16) ([]uint8, error) + Wildcard bool + MacroForbidden bool + LabelsBeforeOnly bool } type InstructionSet map[string][]InstructionParams @@ -503,6 +504,7 @@ func (set InstructionSet) Parse( labels *Labels, defs *Definitions, isMacro bool, + isFirstPass bool, currentAddress uint16, line string, ) ([]byte, error) { @@ -534,7 +536,12 @@ instruction_param_loop: paramType = instrParam.Types[i] } - parsed, err := paramType(labels, defs, params[i]) + accessibleLabels := labels + + if isFirstPass && !instrParam.LabelsBeforeOnly { + accessibleLabels = nil + } + parsed, err := paramType(accessibleLabels, defs, params[i]) if err != nil { continue instruction_param_loop } -- cgit v1.2.3-70-g09d2