Skip to content

Support labels and assembler directives #5

@kevinamccorvon

Description

@kevinamccorvon

The example programs have labels like fib: and fib_loop: plus directives like .section .text and .global fib but none of this works so the examples can't be assembled. Need labels for function entries and loop targets, section directives (.section .text/.data/.rodata), symbol directives (.global/.local), and label resolution so when you write beq x1, x2, loop or jal fib it computes the right offset or target address.

Probably need two-pass assembly - first pass collects all labels and addresses, second pass encodes instructions and resolves label references. Need a symbol table to map names to addresses, handle forward references (using a label before defining it), catch undefined/duplicate label errors. Branch offsets (B-type) and jump offsets (J-type) are relative to PC so gotta compute the difference correctly.

Look at zkir-assembler/src/parser.rs, zkir-assembler/src/lib.rs, and the example programs. Needs parser, pseudo-instructions, and encoder working first.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions