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

Function encode_branch

crates/asm-to-binary/src/assembler/encode.rs:245–279  ·  view source on GitHub ↗
(
    kind: &BranchKind,
    rs1: u8,
    rs2: u8,
    target: &str,
    current_addr: u64,
    symbols: &super::symbol_table::SymbolTable,
)

Source from the content-addressed store, hash-verified

243 .entry(current_kind.clone())
244 .or_insert_with(|| SectionData::new(current_kind.clone()));
245 sec.push_u32_le(*w);
246 current_addr += 4;
247 }
248 AsmToken::DataU64(d) => {
249 let sec = sections
250 .entry(current_kind.clone())
251 .or_insert_with(|| SectionData::new(current_kind.clone()));
252 sec.push_u64_le(*d);
253 current_addr += 8;
254 }
255 AsmToken::DataAsciz(s) => {
256 let sec = sections
257 .entry(current_kind.clone())
258 .or_insert_with(|| SectionData::new(current_kind.clone()));
259 sec.bytes.extend_from_slice(s.as_bytes());
260 sec.push_u8(0);
261 current_addr += s.len() as u64 + 1;
262 }
263 AsmToken::Comment => {}
264 }
265 }
266
267 // Flatten sections, assign absolute addresses to symbols.
268 for kind in &layout.section_order {
269 let base = section_bases.get(kind).copied().unwrap_or(0);
270 if let Some(sec) = sections.remove(kind) {
271 for (name, sec_offset) in &sec.symbols {
272 out.symbol_table.insert(name.clone(), base + sec_offset);
273 }
274 out.sections.push(sec);
275 }
276 }
277
278 for g in layout.symbols.globals() {
279 if !out.global_symbols.contains(g) {
280 out.global_symbols.push(g.clone());
281 }
282 }

Callers 1

encodeFunction · 0.85

Calls 3

resolveMethod · 0.45
containsMethod · 0.45
encodeMethod · 0.45

Tested by

no test coverage detected