juls0730

io.rs

Jun 22nd, 2023
1,312
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Rust 0.31 KB | None | 0 0
  1. use core::arch::asm;
  2.  
  3. pub fn outb(port: u16, value: u8) {
  4.     unsafe {
  5.         asm!(
  6.             "out dx, al",
  7.             in("dx") port,
  8.             in("al") value,
  9.         );
  10.     }
  11. }
  12.  
  13. pub fn inb(port: u16) -> u8 {
  14.     let mut value: u8;
  15.     unsafe {
  16.         asm!(
  17.             "in al, dx",
  18.             out("al") value,
  19.             in("dx") port,
  20.         );
  21.     }
  22.     return value;
  23. }
Advertisement
Add Comment
Please, Sign In to add comment