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

Function parse_imm_i64

crates/asm-to-binary/src/assembler/parser.rs:432–439  ·  view source on GitHub ↗

Parse an integer immediate: decimal, or `0x`/`0X` hex prefix.

(s: &str)

Source from the content-addressed store, hash-verified

430 out.push(AsmToken::Real(RealInstruction::Addi(Addi::new(
431 reg, 0, val32,
432 ))));
433 return;
434 }
435 let lo12 = val32 & 0xFFF;
436 let lo12_signed = if lo12 >= 0x800 { lo12 - 0x1000 } else { lo12 };
437 let hi20 = val32.wrapping_sub(lo12_signed);
438 out.push(AsmToken::Real(RealInstruction::Lui(Lui::new(reg, hi20))));
439 if lo12_signed != 0 {
440 out.push(AsmToken::Real(RealInstruction::Addi(Addi::new(
441 reg,
442 reg,

Callers 3

try_parse_liFunction · 0.85
parse_r_i_immFunction · 0.85
parse_mem_refFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected