feature. See also
. The project being documented here (as the example) is the Zig library itself.
cpu_context.Arm
const Arm = struct
File
Code
const Arm = struct {
r: [16]Gpr,
pub const Gpr = u32;
pub inline fn current() Arm {
var ctx: Arm = undefined;
asm volatile (
\\ // For compatibility with Thumb, we can't write r13 (sp) or r15 (pc) with stm.
\\ stm r0, {r0-r12}
\\ str r13, [r0, #0x34]
\\ str r14, [r0, #0x38]
\\ str r15, [r0, #0x3c]
:
: [r] "{r0}" (&ctx.r),
: .{ .memory = true });
return ctx;
}
pub fn getFp(ctx: *const Arm) usize {
return ctx.r[11];
}
pub fn getPc(ctx: *const Arm) usize {
return ctx.r[15];
}
pub fn dwarfRegisterBytes(ctx: *Arm, register_num: u16) DwarfRegisterError![]u8 {
switch (register_num) {
0...15 => return @ptrCast(&ctx.r[register_num]),
64...95 => return error.UnsupportedRegister,
96...103 => return error.UnsupportedRegister,
104...111 => return error.UnsupportedRegister,
112...127 => return error.UnsupportedRegister,
128 => return error.UnsupportedRegister,
129 => return error.UnsupportedRegister,
130 => return error.UnsupportedRegister,
131 => return error.UnsupportedRegister,
132 => return error.UnsupportedRegister,
133 => return error.UnsupportedRegister,
134...142 => return error.UnsupportedRegister,
143 => return error.UnsupportedRegister,
144...150 => return error.UnsupportedRegister,
151...157 => return error.UnsupportedRegister,
158...159 => return error.UnsupportedRegister,
160...161 => return error.UnsupportedRegister,
162...163 => return error.UnsupportedRegister,
164...165 => return error.UnsupportedRegister,
166...191 => return error.UnsupportedRegister,
192...199 => return error.UnsupportedRegister,
200...255 => return error.UnsupportedRegister,
256...287 => return error.UnsupportedRegister,
288...319 => return error.UnsupportedRegister,
320 => return error.UnsupportedRegister,
321 => return error.UnsupportedRegister,
322 => return error.UnsupportedRegister,
323 => return error.UnsupportedRegister,
324...8191 => return error.UnsupportedRegister,
8192...16383 => return error.UnsupportedRegister,
else => return error.InvalidRegister,
}
}
}