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.
You should probably replace stringify!($imm_val) with $imm_val.
The warning that you are ignoring is trying to point this out:
warning: unused variable: `imm_val`
--> <source>:13:36
|
13 | pub fn rotate(result: u32, a: u32, imm_val: u32) -> u32 {
| ^^^^^^^ help: if this is intentional, prefix it with an underscore: `_imm_val`
|
= note: `#[warn(unused_variables)]` on by default
You can't pass a runtime value as immediate. An immediate is by definition defined at compile time. (unless you use self-modifying code) You have to pass it as register and then use this register in the rot instruction.