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

Function parse_csrr

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

Parse `rd, csr` for `csrr` (pseudo: csrrs rd, csr, x0).

(operands: &str)

Source from the content-addressed store, hash-verified

597// expanding to the spec's `bge`/`blt` form against x0.
598fn parse_branch_vs_zero(mnemonic: &str, operands: &str) -> Option<AsmToken> {
599 let comma = operands.find(',')?;
600 let rs = parse_int_reg(operands[..comma].trim())?;
601 let target = operands[comma + 1..].trim().to_owned();
602 if target.is_empty() {
603 return None;
604 }
605 let (kind, rs1, rs2) = match mnemonic {
606 "blez" => (BranchKind::Bge, 0, rs), // rs <= 0 == 0 >= rs
607 "bgez" => (BranchKind::Bge, rs, 0),
608 "bltz" => (BranchKind::Blt, rs, 0),
609 "bgtz" => (BranchKind::Blt, 0, rs), // rs > 0 == 0 < rs

Callers 1

parse_instruction_lineFunction · 0.85

Calls 2

parse_int_regFunction · 0.85
parse_csr_nameFunction · 0.85

Tested by

no test coverage detected