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

Function parse_branch_zero

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

Parse `rs, label` for a zero-register branch (`beqz`/`bnez`). Expands to `beq/bne rs, x0, label`.

(kind: BranchKind, operands: &str)

Source from the content-addressed store, hash-verified

548 let rs1 = parse_int_reg(parts[0].trim())?;
549 let rs2 = parse_int_reg(parts[1].trim())?;
550 let target = parts[2].trim().to_owned();
551 Some(AsmToken::Branch {
552 kind,
553 rs1,
554 rs2,
555 target,
556 })
557}
558
559// Parse `rd, label` (or just `label` for the `j` form handled above).
560fn parse_jal(operands: &str) -> Option<AsmToken> {
561 let parts: Vec<&str> = operands.splitn(2, ',').collect();
562 match parts.len() {
563 2 => {
564 let rd = parse_int_reg(parts[0].trim())?;
565 let target = parts[1].trim().to_owned();
566 Some(AsmToken::Jal { rd, target })

Callers 1

parse_instruction_lineFunction · 0.85

Calls 1

parse_int_regFunction · 0.85

Tested by

no test coverage detected