-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add register API for raw bit patterns
This is functionally identical to the existing unsigned API, but better indicates intent for values that are known to be bitmasks. It would also align with any future Zig support for raw bit types: see ziglang/zig#7512 and ziglang/zig#8388.
- Loading branch information
Showing
7 changed files
with
71 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,19 @@ | ||
//! Register values can interpreted as signed or unsigned 16-bit integers. | ||
const introspection = @import("../utils/introspection.zig"); | ||
|
||
/// A 16-bit register value interpreted as a signed integer. | ||
/// Intended for signed arithmetic. | ||
pub const Signed = i16; | ||
/// A 16-bit register value interpreted as an unsigned integer. | ||
/// Intended for unsigned arithmetic. | ||
pub const Unsigned = u16; | ||
pub const Mask = Unsigned; | ||
pub const Shift = introspection.ShiftType(Unsigned); | ||
/// A 16-bit register value interpreted as a pattern of 16 raw bits. | ||
/// Intended for bitmasking and shifting. | ||
pub const BitPattern = Unsigned; | ||
|
||
/// The integer type used for bit-shift operations. | ||
/// Example: | ||
/// -------- | ||
/// const shift: Shift = 6; | ||
/// const shifted_value = @as(BitPattern, 0b0000_0000_0000_1000) << 6 | ||
pub const Shift = introspection.ShiftType(BitPattern); |