Hi.
I am trying to implement an "Asm" instruction in rust as follows:
In instructions_lib.rs file i have:
pub fn rotate(result: u32, a: u32, imm_val: u32) -> u32 {
mylib::rot!(4, result, a, (imm_val| 0xC0))
}
In myasm.rs file I have:
#[macro_export]
macro_rules! rot{ ($input:expr, $result:expr, $a:expr, $imm_val:expr) => {
{
let mut result: u32 = $result;
unsafe {
core::arch::asm!(concat!("rot p", stringify!($input), ", {}, {}, #", stringify!($imm_val)), inout(reg) result, in(reg) $a);
}
result
}
};
}
However when i do cargo run i get the following error:
note: instantiated into assembly here
--> <inline asm>:1:19
|
1 | rot p4, r0, r1, #(imm_val| 0xC0)
| ^
error: operand must be an immediate in the range [0,511]
This assembly function should take any input value from the user and then do the OR with 0xC0 and then pass the result value to the asm instruction but instead it is using the string. How can i solve this issue.
Thank you.