Skip to content

Commit

Permalink
regs: add convenience getter methods for a registers
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-orlovsky committed Oct 18, 2024
1 parent 7adf61d commit b9a2312
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/reg/core_regs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,17 @@ impl CoreRegs {
}
}

/// Get value from `a8` register.
pub fn a8(&self, idx: impl Into<Reg32>) -> Option<u8> { self.a8[idx.into().to_usize()] }

Check warning on line 215 in src/reg/core_regs.rs

View check run for this annotation

Codecov / codecov/patch

src/reg/core_regs.rs#L215

Added line #L215 was not covered by tests
/// Get value from `a16` register.
pub fn a16(&self, idx: impl Into<Reg32>) -> Option<u16> { self.a16[idx.into().to_usize()] }

Check warning on line 217 in src/reg/core_regs.rs

View check run for this annotation

Codecov / codecov/patch

src/reg/core_regs.rs#L217

Added line #L217 was not covered by tests
/// Get value from `a32` register.
pub fn a32(&self, idx: impl Into<Reg32>) -> Option<u32> { self.a32[idx.into().to_usize()] }

Check warning on line 219 in src/reg/core_regs.rs

View check run for this annotation

Codecov / codecov/patch

src/reg/core_regs.rs#L219

Added line #L219 was not covered by tests
/// Get value from `a64` register.
pub fn a64(&self, idx: impl Into<Reg32>) -> Option<u64> { self.a64[idx.into().to_usize()] }

Check warning on line 221 in src/reg/core_regs.rs

View check run for this annotation

Codecov / codecov/patch

src/reg/core_regs.rs#L221

Added line #L221 was not covered by tests
/// Get value from `a128` register.
pub fn a128(&self, idx: impl Into<Reg32>) -> Option<u128> { self.a128[idx.into().to_usize()] }

Check warning on line 223 in src/reg/core_regs.rs

View check run for this annotation

Codecov / codecov/patch

src/reg/core_regs.rs#L223

Added line #L223 was not covered by tests

/// Extracts value for any type of registers
pub fn get(&self, reg: impl Into<Reg>) -> RegValue {
match reg.into() {
Expand Down

0 comments on commit b9a2312

Please sign in to comment.