Using custom asm instructions
⚓ Rust 📅 2025-10-19 👤 surdeus 👁️ 2I'm writing bare-metal code for MicroBlaze V, AMD's soft-core RISC-V processor, using the target riscv32im-unknown-none-elf.
In addition to the standard RISC-V instructions, the MicroBlaze V defines some custom instructions. Is there a way of using these from Rust using inline assembly?
For example, I'd like to use the custom instruction PUT to write data to an AXI4-Stream link, but the following code does not compile because the instruction is not recognized:
fn axi_write(word: u32) {
unsafe {
// write to M0_AXIS_TDATA using custom instruction PUT
asm!("put {}, 0", in(reg) word);
}
}
error: unrecognized instruction mnemonic
|
note: instantiated into assembly here
--> <inline asm>:1:2
|
1 | put a0, 0
| ^
error: could not compile `xxx` (bin "xxx") due to 1 previous error
Is there a way of using custom instructions in inline assembly? If not, is there some workaround?
2 posts - 2 participants
🏷️ Rust_feed