/// Define a Register with a given name and size. This will
/// create a Register in the NAMED_REGISTERS map with the
/// value of REGISTER_POINTER as the Register's address.
Define a Register with a given name and size. This will
create a Register in the NAMED_REGISTERS map with the
value of REGISTER_POINTER as the Register's address.
Define a Register with a given name and size . This will create a Register in the NAMED_REGISTERS map with the value of REGISTER_POINTER as the Register ' s address .
pub fn define(name: impl fmt::Display, size: usize) -> Self {
        // The pointer to where this register will be stored
        let mut rptr = REGISTER_POINTER.lock();
        // The map of defined registers
        let mut registers = NAMED_REGISTERS.lock();
        // This register
        let result = Self::Named {
            name: name.to_string(),
            size,
            addr: *rptr,
        };
        // Increment the register pointer so that the next
        // defined register will not overwrite this register
        *rptr += size;
        // Insert this register into the map
        registers.insert(name.to_string(), result.clone());
        // Return this register
        result
    }
pub fn define ( name : impl fmt :: Display , size : usize ) -> Self { // The pointer to where this register will be stored let mut rptr = REGISTER_POINTER . lock ( ) ; // The map of defined registers let mut registers = NAMED_REGISTERS . lock ( ) ; // This register let result = Self :: Named { name : name . to_string ( ) , size , addr : * rptr , } ; // Increment the register pointer so that the next // defined register will not overwrite this register * rptr += size ; // Insert this register into the map registers . insert ( name . to_string ( ) , result . clone ( ) ) ; // Return this register result }
Define a Register with a given name and size.
Define a Register with a given name and size .
name
impl fmt::Display
size
usize