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

Function resolve_absolute_symbol

crates/asm-to-binary/src/assembler/encode.rs:320–335  ·  view source on GitHub ↗
(
    symbol: &str,
    symbols: &super::symbol_table::SymbolTable,
    section_bases: &std::collections::HashMap<SectionKind, u64>,
)

Source from the content-addressed store, hash-verified

318 }
319 if !(-4096..=4094).contains(&offset) {
320 return Err(AssemblerError::new(format!(
321 "branch to `{target}` offset {offset} out of B-type range [-4096, 4094]"
322 )));
323 }
324 let off = offset as i32;
325
326 let inst: RealInstruction = match kind {
327 BranchKind::Beq => RealInstruction::Beq(Beq::new(rs1, rs2, off)),
328 BranchKind::Bne => RealInstruction::Bne(Bne::new(rs1, rs2, off)),
329 BranchKind::Blt => RealInstruction::Blt(Blt::new(rs1, rs2, off)),
330 BranchKind::Bge => RealInstruction::Bge(Bge::new(rs1, rs2, off)),
331 BranchKind::Bltu => RealInstruction::Bltu(Bltu::new(rs1, rs2, off)),
332 BranchKind::Bgeu => RealInstruction::Bgeu(Bgeu::new(rs1, rs2, off)),
333 };
334 Ok(inst.encode())
335}
336
337fn encode_jal(
338 rd: u8,

Callers 3

encode_callFunction · 0.85
encode_tailFunction · 0.85
encode_laFunction · 0.85

Calls 2

getMethod · 0.80
allMethod · 0.45

Tested by

no test coverage detected