DBYTE32 ABI + ELF contract
This page consolidates the contracts that were split between v11.0 DBYTE_NATIVE.md, v11.1 DBYTE_NATIVE_LINK.md, and later interrupt/entry metadata.
Compilation path§
.dby -> shared lexer / parser / AST -> systems type checking -> typed native IR -> bounded i686 encoder -> ELF32 ET_REL object -> DByte in-process static linker -> ELF32 ET_EXEC -> Multiboot entry
DBYTE32 calling convention§
| Property | Contract |
|---|---|
| Argument evaluation | left to right |
| Argument slot | one 32-bit stack word per scalar argument |
| Parameter location | [EBP + 8 + 4 * (N - 1 - i)] before copy to local slot |
| Stack cleanup | caller removes argument words after call |
| Scalar result | EAX |
| Caller-saved | EAX ECX EDX |
| Preserved when used | EBX ESI EDI EBP |
| Frame pointer | EBP |
| Return invariant | generated return restores ESP and EBP exactly |
Systems type layout§
| Type | Size | Alignment | Signedness |
|---|---|---|---|
bool | 1 | 1 | no |
i8 / u8 | 1 | 1 | type-dependent |
i16 / u16 | 2 | 2 | type-dependent |
i32 / u32 | 4 | 4 | type-dependent |
usize | 4 | 4 | no |
ptr[T] | 4 | 4 | no |
- Arithmetic wraps at the declared integer width.
- Mixed-width arithmetic and implicit narrowing are rejected.
- Explicit
ascasts are required. - Only
usizemay convert explicitly to or from a pointer. array[T,N]uses declaration-order elements andT's alignment.- Literal out-of-range array indices are compile errors; dynamic indexing in the low-level profile is intentionally unchecked at runtime.
- Normal structs use natural alignment plus tail padding.
packed structhas alignment one and no inserted padding.
ET_REL object contract§
CLASS ELFCLASS32
ENDIAN LITTLE
TYPE ET_REL
MACHINE EM_386
SECTIONS .text .rodata .data .bss .symtab .strtab .shstrtab .rel.*
RELOCS R_386_PC32 cross-object relative calls
R_386_32 absolute addresses
ADDENDS stored in relocated bytes
ORDERING canonical / source-independent
The linker validates object class, machine, sections, string/symbol tables, relocation indices, relocation offsets, arithmetic and final layout bounds before output is replaced.
Symbol model§
import "relative.dby" as nameis compile-time, relative to the importing file, filesystem-only, cycle checked and deterministically ordered.pub fn,pub staticandpub constare visible across modules.- Unqualified definitions remain object-local.
- Duplicate strong exports and unresolved final symbols are link errors.
- Weak symbols, dynamic symbols, network package lookup and runtime module loading are outside the profile.
Executable contract§
TYPE ELF32 ET_EXEC / EM_386 LOAD BASE 1 MiB foundation contract BOOT Multiboot v1 START linker-synthesized _start STACK bounded bootstrap stack RETURN cli / hlt permanent loop DYNAMIC none LIBC none DLL IMPORTS none
Interrupt entry ABI§
interrupt(no_error_code) fn handler(frame: ptr[InterruptFrame]) interrupt(error_code) fn handler(frame: ptr[InterruptFrame], error_code: u32)
The compiler-generated entry stub saves interrupted general registers, normalizes the CPL0 frame, enters a DBYTE32 body, restores registers, performs class-specific stack cleanup and emits iretd. Handler address-taking is through interrupt_address(vector, handler), with compile-time vector/class checks.
Scheduler resume image§
+00 EDI +04 ESI +08 EBP +0C ignored PUSHAD ESP +10 EBX +14 EDX +18 ECX +1C EAX +20 EIP +24 CS +28 EFLAGS
v11.5 reuses the CPU/PUSHAD image directly rather than introducing a second register-context structure. Later blocking and IRQ I/O milestones preserve this context ABI.
Output replacement law§
Compilation/link failures use a temporary sibling and leave an existing output unchanged. --dump-ir, --dump-machine-code and post-emission disassembly are inspection surfaces; they are not code generators in the native pipeline.