instruction_pointer_operations 0.1.0

A simple crate that allows users to manipulate the value of the instruction pointer without needing to write inline assembly.
Documentation
  • Coverage
  • 66.67%
    2 out of 3 items documented0 out of 2 items with examples
  • Size
  • Source code size: 3.01 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 483.17 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Links
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • WebAppEnjoyer

I don't really know what to write for this readme.

So here is the entirity of this library's source code:

#![no_std]
use core::arch::asm;
/// Gets the instruction pointer to the exact next instruction.
#[inline(always)]
pub fn get_ip() -> usize {
    let ip: usize;
    unsafe {
        asm!(
            "lea {0}, [rip]", 
            out(reg) ip
        );
    }
    ip
}
/// Sets the current value of the instruction pointer to addr.
#[inline(always)]
pub unsafe fn set_ip(addr: usize) -> ! {
    unsafe{
        asm!(
        "jmp {0}",
        in(reg) addr,
        options(noreturn)
        );
    }
}