MCPcopy Create free account
hub / github.com/LPC4/Full-Stack / b_imm

Function b_imm

crates/virtual-machine/src/cpu/decoder.rs:914–920  ·  view source on GitHub ↗

B-type immediate: [31]<<12 | [7]<<11 | [30:25]<<5 | [11:8]<<1, sign-extended to 13 bits.

(word: u32)

Source from the content-addressed store, hash-verified

912
913// B-type immediate: [31]<<12 | [7]<<11 | [30:25]<<5 | [11:8]<<1, sign-extended to 13 bits.
914fn b_imm(word: u32) -> i64 {
915 let bit12 = field(word, 31, 31) << 12;
916 let bit11 = field(word, 7, 7) << 11;
917 let bits10_5 = field(word, 30, 25) << 5;
918 let bits4_1 = field(word, 11, 8) << 1;
919 sign_ext(bit12 | bit11 | bits10_5 | bits4_1, 13)
920}
921
922// J-type immediate: [31]<<20 | [19:12]<<12 | [20]<<11 | [30:21]<<1, sign-extended to 21 bits.
923fn j_imm(word: u32) -> i64 {

Callers 1

decodeFunction · 0.85

Calls 2

fieldFunction · 0.85
sign_extFunction · 0.85

Tested by

no test coverage detected