Parcourir la source

Add a function to `Sstatus` to update fs field (#3)

LoGin il y a 1 an
Parent
commit
01fc40df94
1 fichiers modifiés avec 9 ajouts et 0 suppressions
  1. 9 0
      riscv/src/register/sstatus.rs

+ 9 - 0
riscv/src/register/sstatus.rs

@@ -51,6 +51,15 @@ impl Sstatus {
         }
         }
     }
     }
 
 
+    /// Update the status of the floating-point unit
+    /// 
+    /// Note: This function only updates the FS field.
+    #[inline]
+    pub fn update_fs(&mut self, fs: FS) {
+        self.bits &= !(0x3 << 13); // clear previous value
+        self.bits |= (fs as usize) << 13;
+    }
+
     /// The status of additional user-mode extensions
     /// The status of additional user-mode extensions
     /// and associated state
     /// and associated state
     #[inline]
     #[inline]