const main = @import("main.zig"); extern const __data_flash: u32; extern const __data: u32; extern const __data_size: u32; extern const __bss: u32; extern const __bss_size: u32; comptime { asm ( \\.extern _start \\.extern _tstack \\ \\.section .vector_table \\.global init_vector_table \\init_vector_table: \\ .word _tstack \\ .word _start \\ .skip 4 * 14 ); } inline fn zero_bss() void { const bss: [*]volatile u8 = @ptrFromInt(@intFromPtr(&__bss)); @memset(bss[0..@intFromPtr(&__bss_size)], 0); } inline fn copy_data() void { const data_flash: [*]volatile u8 = @ptrFromInt(@intFromPtr(&__data_flash)); const data: [*]volatile u8 = @ptrFromInt(@intFromPtr(&__data)); const data_size = @intFromPtr(&__data_size); @memcpy(data[0..data_size], data_flash[0..data_size]); } export fn _start() callconv(.C) noreturn { zero_bss(); copy_data(); main.main(); while (true) {} }