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

Function load32

crates/asm-to-binary/src/pseudo.rs:421–430  ·  view source on GitHub ↗

Helper to produce the lui+addi sequence for a 32-bit constant

(rd: Reg, val32: i32)

Source from the content-addressed store, hash-verified

419 let lo12_signed = if lo12 >= 0x800 { lo12 - 0x1000 } else { lo12 };
420 let hi20 = val32.wrapping_sub(lo12_signed);
421 let mut seq = vec![RealInstruction::Lui(Lui::new(rd, hi20))];
422 if lo12_signed != 0 {
423 seq.push(RealInstruction::Addi(Addi::new(rd, rd, lo12_signed)));
424 }
425 seq
426 }
427
428 let mut seq = Vec::new();
429
430 // Load the high 32 bits into t1 and shift them left by 32.
431 seq.append(&mut load32(T1, high32)); // T1 = sign_ext(high32)
432 seq.push(RealInstruction::Slli(Slli::new(T1, T1, 32))); // T1 = high32 << 32
433

Callers 2

expand_liFunction · 0.85
expand_liFunction · 0.85

Calls 1

pushMethod · 0.80

Tested by

no test coverage detected