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

Function pcrel_split

crates/asm-to-binary/src/assembler/encode.rs:314–318  ·  view source on GitHub ↗

Split a PC-relative byte offset into (hi20, lo12) for AUIPC+lo pairs.

(offset: i64)

Source from the content-addressed store, hash-verified

312
313 let offset = (target_addr as i64) - (site_local as i64);
314 if offset & 1 != 0 {
315 return Err(AssemblerError::new(format!(
316 "branch to `{target}` has odd offset {offset}"
317 )));
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]"

Callers 1

pcrel_offsetsFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected