fengb / fundude

Gameboy emulator: Zig -> wasm
https://fengb.github.io/fundude/
MIT License
181 stars 8 forks source link

Experiment with branchless logic #49

Open fengb opened 4 years ago

fengb commented 4 years ago

https://stackoverflow.com/a/5432624

This is leveraging modern CPU designs:

We will need a strong microp architecture:

fengb commented 4 years ago
const Offset = magic_numbers(u17) {
    0x0_0000: null,
    0x0_100*: temp, // first microp can store here and be consumed by the second
    0x1_FFF*: registers,
    0x1_****: mmu,
};

const Microp = struct {
    id: enum { add, sub, cp },
    dst: Offset,
    args: [2]Offset,
};

const Op = struct {
    code: u8,
    length: u8,
    durations: [2]u8,
    id: Id,
    microps: [2]Microp,
    flag: enum{}
};