ZigEmbeddedGroup / regz

Generate zig code from ATDF or SVD files for microcontrollers.
MIT License
82 stars 29 forks source link

Use a pointer instead of u32 for initial_stack_pointer #87

Open ikskuh opened 1 year ago

ikskuh commented 1 year ago

See this code:


extern var __microzig_end_of_stack: anyopaque;

const Table = extern struct {
    initial_stack_pointer: *anyopaque,
    reset: *const fn() callconv(.C) void,
    nmi: *const fn() callconv(.C) void,
};

export const vector_table: Table = .{
    .initial_stack_pointer = &__microzig_end_of_stack,
    .reset = _reset,
    .nmi = _nmi,
};

fn _reset() callconv(.C) void { }
fn _nmi() callconv(.C) void { }

which will then generate

example._nmi:
        ret

vector_table:
        .quad   __microzig_end_of_stack
        .quad   example._nmi
        .quad   example._nmi

as the generated assembly. this will allow us to fully configure the stack size and location from the linker script and don't require any weird shenanigans with address offsetting