From b584449c7e3f33ca281f83ec7baa00649f04d361 Mon Sep 17 00:00:00 2001 From: iximeow Date: Mon, 2 Mar 2026 04:07:03 +0000 Subject: this might actually work omggggg --- src/long_mode/behavior.rs | 14 +++++++++++--- src/long_mode/mod.rs | 7 +++++++ 2 files changed, 18 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/long_mode/behavior.rs b/src/long_mode/behavior.rs index 12886c2..845f908 100644 --- a/src/long_mode/behavior.rs +++ b/src/long_mode/behavior.rs @@ -103,6 +103,11 @@ impl Exception { const fn vector(vector: u8) -> Self { Self { vector } } + + /// convert this `Exception` to an index into an x86 IDT. + pub const fn to_u8(&self) -> u8 { + self.vector + } } impl ExceptionInfo { @@ -261,7 +266,8 @@ pub struct OperandIter<'inst> { /// this is (maybe surprisingly, compared to the rest of the isa) relatively tiny: the only /// implicit operands to date are register reads/writes, and simple dereference of a register (such /// as `[rsp - 8] = ...` in a push). -struct ImplicitOperand { +// TODO: this needs accessors for the elements or something. +pub struct ImplicitOperand { spec: OperandSpec, reg: RegSpec, disp: i32, @@ -442,7 +448,7 @@ impl<'inst> InstBehavior<'inst> { OperandSpec::ImmInDispField => { // no register/memory access to report. } - other => { + _other => { // compute effective address... let addr = compute_addr(v, &self.inst, op_spec); let size = self.inst.mem_size().expect("memory operand implies memory access size") @@ -483,7 +489,7 @@ impl<'inst> InstBehavior<'inst> { OperandSpec::ImmInDispField => { // no register/memory access to report. } - other => { + _other => { // compute effective address... let addr = compute_addr(v, &self.inst, op_spec); let size = self.inst.mem_size().expect("memory operand implies memory access size") @@ -555,6 +561,8 @@ pub struct BehaviorDigest { extra: u16, } +// TODO: the various `set_pl*()` are not actually used yet.. +#[allow(dead_code)] impl BehaviorDigest { const fn empty() -> BehaviorDigest { BehaviorDigest { diff --git a/src/long_mode/mod.rs b/src/long_mode/mod.rs index 4168864..dc54506 100644 --- a/src/long_mode/mod.rs +++ b/src/long_mode/mod.rs @@ -325,6 +325,13 @@ impl RegSpec { r12b => 12, r13b => 13, r14b => 14, r15b => 15 ); + register!(CR, + cr0 => 0, cr1 => 1, cr2 => 2, cr3 => 3, + cr4 => 4, cr5 => 5, cr6 => 6, cr7 => 7, + cr8 => 8, cr9 => 9, cr10 => 10, cr11 => 11, + cr12 => 12, cr13 => 13, cr14 => 14, cr15 => 15 + ); + #[inline] pub const fn zmm0() -> RegSpec { RegSpec { bank: RegisterBank::Z, num: 0 } -- cgit v1.1