Zig 0.17.0-dev (Split by item)

Shortcut keys
?
Show these tips
S
Focus search field
Esc
Clear focus & close tips
U
Jump to source code
↑
Move up in search results
↓
Move down in search results
↵
Go to active search result
This is an example of documentation generated by ZigDoc, an alternative to Zig's built-in Auto Doc feature. See also examples in other modes/formats. The project being documented here (as the example) is the Zig standard library. Private Struct

M68k

Private Struct
std.debug.cpu_context.M68k
const M68k = extern struct

This is an extern struct so that inline assembly in current can use field offsets.

Fields

d: [8]Gpr

The numbered data registers d0 - d7.

a: [8]Gpr

The numbered address registers a0 - a7.

pc: Gpr

Values

Functions

pub inline fn current() M68k
pub fn getFp(ctx: *const M68k) usize
pub fn getPc(ctx: *const M68k) usize
pub fn dwarfRegisterBytes(ctx: *M68k, register_num: u16) DwarfRegisterError![]u8

File

debug/cpu_context.zig:883
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
const M68k = extern struct {
    /// The numbered data registers d0 - d7.
    d: [8]Gpr,
    /// The numbered address registers a0 - a7.
    a: [8]Gpr,
    pc: Gpr,

    pub const Gpr = u32;

    pub inline fn current() M68k {
        var ctx: M68k = undefined;
        asm volatile (
            \\ movem.l %%d0 - %%a7, (%%a0)
            \\ lea.l (%%pc), %%a1
            \\ move.l %%a1, (%%a0, 64)
            :
            : [ctx] "{a0}" (&ctx),
            : .{ .a1 = true, .memory = true });
        return ctx;
    }

    pub fn getFp(ctx: *const M68k) usize {
        return ctx.a[6];
    }
    pub fn getPc(ctx: *const M68k) usize {
        return ctx.pc;
    }

    pub fn dwarfRegisterBytes(ctx: *M68k, register_num: u16) DwarfRegisterError![]u8 {
        switch (register_num) {
            0...7 => return @ptrCast(&ctx.d[register_num]),
            8...15 => return @ptrCast(&ctx.a[register_num - 8]),
            26 => return @ptrCast(&ctx.pc),

            16...23 => return error.UnsupportedRegister, // fp0 - fp7
            24...25 => return error.UnsupportedRegister, // Return columns in GCC...?

            else => return error.InvalidRegister,
        }
    }
}