Address

Struct Address 

Source
pub struct Address(Unsigned18Bit);
Expand description

An address has 17 normal value bits. There are 18 bits for the operand base address in the instruction word, but the topmost bit signals a deferred (i.e. indirect) access, so we should never see a memory access to an address with the 0o400_000 bit set.

The program counter can also have its top bit set. This signals that in the TX-2 hardware, the associated sequence should be traced via Trap 42.

The Xj (index) registers form an 18-bit ring and are described on page 3-68 of the User Handbook (section 3-3.1) as being signed integers. Yet P (which also holds an address) is described on the same page as being a positive integer. Therefore when performing address arithmetic, we sometimes need to convert index register values to the Signed18Bit type.

Tuple Fields§

§0: Unsigned18Bit

Implementations§

Source§

impl Address

Source

pub const ZERO: Address

Source

pub const MAX: Address

Source

pub const fn new(a: Unsigned18Bit) -> Address

Source

pub const fn and(&self, mask: u32) -> Address

Apply a bitmask to an address. This could also be done via std::ops::BitAnd, but trait implementations cannot be const. Implementing this const methods allows us to form address constants at compile time with code like Address::MAX & 0o03400.

Source

pub fn mark_bit(&self) -> Unsigned18Bit

Extract the placeholder mark bit.

Source

pub fn is_marked_placeholder(&self) -> bool

The placeholder phrasing here comes from the “TRAP 42” features. But the high bit in the operand address field in an instruction also marks the operand as using deferred addressing. We should choose more neutral naming to avoid confusion.

Source

pub fn split(&self) -> (Unsigned18Bit, bool)

Split an address into its bottom 17 bits (which corresponds to an actual memory register on the TX-2) and a “mark” bit. The “mark” bit is variously used to signal deferred addressing when fetching operands, and to flag a sequence for tracing with trap 42 (in this context is is called a “placeholder mark bit”). The split method is the opposite of join.

Source

pub fn join(addr: Unsigned18Bit, mark: bool) -> Address

Form an address from the bottom 17 bits of addr and a possilbe mark bit, mark. If mark is false, the resulting address will have a zero-valued top bit, no matter what is in addr. This is the opposite of split.

Source

pub fn successor(&self) -> Address

Computes the address following the current address. Used, among other things, to increment the program counter.

The simulator relies on the fact that (as in the hardware TX-2 P register) this calculation will wrap from 0o377_777 to 0.

Trait Implementations§

Source§

impl Clone for Address

Source§

fn clone(&self) -> Address

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Address

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Default for Address

Source§

fn default() -> Address

Returns the “default value” for a type. Read more
Source§

impl Display for Address

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl From<&Address> for Unsigned18Bit

Source§

fn from(addr: &Address) -> Self

Converts to this type from the input type.
Source§

impl From<&Address> for Unsigned36Bit

Source§

fn from(addr: &Address) -> Self

Converts to this type from the input type.
Source§

impl From<&Address> for u32

Source§

fn from(a: &Address) -> u32

Converts to this type from the input type.
Source§

impl From<Address> for Unsigned18Bit

Source§

fn from(addr: Address) -> Self

Converts to this type from the input type.
Source§

impl From<Address> for Unsigned36Bit

Source§

fn from(addr: Address) -> Self

Converts to this type from the input type.
Source§

impl From<Address> for u32

Source§

fn from(a: Address) -> u32

Converts to this type from the input type.
Source§

impl From<Unsigned18Bit> for Address

Source§

fn from(a: Unsigned18Bit) -> Address

Converts to this type from the input type.
Source§

impl Hash for Address

Source§

fn hash<H>(&self, h: &mut H)
where H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl IndexBy<Signed18Bit> for Address

Source§

fn index_by(&self, delta: Signed18Bit) -> Address

Source§

impl IndexBy<Signed5Bit> for Address

Source§

fn index_by(&self, delta: Signed5Bit) -> Address

Source§

impl IndexBy<Signed6Bit> for Address

Source§

fn index_by(&self, delta: Signed6Bit) -> Address

Source§

impl IndexBy<Unsigned18Bit> for Address

Source§

impl IndexBy<u8> for Address

Source§

fn index_by(&self, index: u8) -> Address

Source§

impl Octal for Address

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Ord for Address

Source§

fn cmp(&self, other: &Self) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq<u32> for Address

Source§

fn eq(&self, other: &u32) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq for Address

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for Address

Source§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl TryFrom<Unsigned36Bit> for Address

Source§

type Error = ConversionFailed

The type returned in the event of a conversion error.
Source§

fn try_from(n: Unsigned36Bit) -> Result<Address, ConversionFailed>

Performs the conversion.
Source§

impl TryFrom<u32> for Address

Source§

type Error = ConversionFailed

The type returned in the event of a conversion error.
Source§

fn try_from(n: u32) -> Result<Address, ConversionFailed>

Performs the conversion.
Source§

impl Copy for Address

Source§

impl Eq for Address

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<Q, K> Comparable<K> for Q
where Q: Ord + ?Sized, K: Borrow<Q> + ?Sized,

§

fn compare(&self, key: &K) -> Ordering

Compare self to key and return their ordering.
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.