Map a CSR name or numeric literal to its 12-bit address.
(name: &str)
| 564 | let rd = parse_int_reg(parts[0].trim())?; |
| 565 | let target = parts[1].trim().to_owned(); |
| 566 | Some(AsmToken::Jal { rd, target }) |
| 567 | } |
| 568 | 1 => { |
| 569 | // Bare `jal label` means `jal ra, label`. |
| 570 | let target = parts[0].trim().to_owned(); |
| 571 | if target.is_empty() { |
| 572 | None |
| 573 | } else { |
| 574 | Some(AsmToken::Jal { rd: 1, target }) |
| 575 | } |
| 576 | } |
| 577 | _ => None, |
| 578 | } |
| 579 | } |
| 580 | |
| 581 | // Parse `rd, symbol` for the `la` pseudo-instruction. |
| 582 | fn parse_la(operands: &str) -> Option<AsmToken> { |
| 583 | let parts: Vec<&str> = operands.splitn(2, ',').collect(); |
| 584 | if parts.len() != 2 { |
| 585 | return None; |
| 586 | } |
| 587 | let rd = parse_int_reg(parts[0].trim())?; |
| 588 | let symbol = parts[1].trim().to_owned(); |
| 589 | if symbol.is_empty() { |
| 590 | None |
| 591 | } else { |
| 592 | Some(AsmToken::La { rd, symbol }) |
| 593 | } |
| 594 | } |
| 595 | |
| 596 | // Parse `rs, label` for a compare-with-zero branch pseudo (`blez`/`bgez`/`bltz`/`bgtz`), |
| 597 | // expanding to the spec's `bge`/`blt` form against x0. |
| 598 | fn parse_branch_vs_zero(mnemonic: &str, operands: &str) -> Option<AsmToken> { |
| 599 | let comma = operands.find(',')?; |
no outgoing calls
no test coverage detected