Skip to content

Symbols / Linking #18

@stefandrissen

Description

@stefandrissen

I'm just thinking out loud here and would appreciate any input.

pyz80 has global symbols and local symbols (@-prefix).

global: equ 1
@local: equ 2

Global symbols can be exported (--exportfile) and imported (--importfile) allowing linker-type sharing between programs.

When used for linking, a further distinction may be useful to only export external entry points / labels.

For using a multi-purpose include file, the global symbol is unusable since it can only be set once and the local symbol has no effect:

; progA.s
section: equ "A"
include "section.i"
; prog B.s
section: equ "B"
include "section.i"
; section.i
if section == "A" then
    ...   
else
    ...
endif

In the above example both progs can be assembled, but if the symbols of A are exported and imported when assembling B, assembly will fail since the section symbol is being redefined with a different value than the existing definition.

Additionally (or alternatively) an undefine symbol could help, this would allow including section.i multiple times within the same source with different parameters.

Alternatively (again) local symbols could be passed in with the include, something like:

include "section.i" @section="A"

Which would define local section for the scope of that section.i only.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions