mirror of
https://github.com/odin-lang/Odin.git
synced 2026-06-19 16:42:33 +00:00
Each ISA's hand-written ENCODING_TABLE (the single source of truth) now lives in a per-arch tablegen/ metaprogram that flattens it and serializes committed binary blobs; the library #loads those into @(rodata) at compile time rather than compiling a table body. No arch keeps encoding_table.odin or decoding_tables.odin -- only a generated tables.odin loader and tables/*.bin. * Two-stage, type-checked pipeline: tablegen Stage A emits human-readable generated Odin, which compiles and serializes the blobs in Stage B. * encode() goes through encoding_forms(m); decoders are unchanged apart from x86's flattened 2-D index. Decode tables are byte-identical to the old ones. * build.lua: a LuaJIT driver for the metaprograms, validations, and tests, with cross-platform gating and a clear report. * Docs refreshed; the obsolete forward-looking plan in cross_arch_design.md trimmed to what was actually built. * Attribution headers added to all rexcode source files; the generators emit them so generated files keep them.
32 lines
902 B
Odin
32 lines
902 B
Odin
// rexcode · Brendan Punsky (dotbmp@github), original author
|
|
|
|
package rexcode_mos6502
|
|
|
|
// =============================================================================
|
|
// MOS 6502 RELOCATIONS
|
|
// =============================================================================
|
|
//
|
|
// Per the cross-arch design (§2.4): each arch owns its own Relocation_Type
|
|
// enum and Relocation struct. The struct shape mirrors ELF rela so an
|
|
// object emitter can consume it unchanged.
|
|
//
|
|
// 6502 has just two relocation kinds:
|
|
// ABS16 — 16-bit little-endian absolute (JMP $nnnn, JSR $nnnn, LDA $nnnn, ...)
|
|
// REL8 — signed 8-bit PC-relative branch (BEQ/BNE/.../BBR/BBS)
|
|
|
|
Relocation_Type :: enum u8 {
|
|
NONE = 0,
|
|
ABS16,
|
|
REL8,
|
|
}
|
|
|
|
Relocation :: struct #packed {
|
|
offset: u32,
|
|
label_id: u32,
|
|
addend: i32,
|
|
type: Relocation_Type,
|
|
size: u8,
|
|
inst_idx: u16,
|
|
}
|
|
#assert(size_of(Relocation) == 16)
|