This is my current code:
void int32hex(u32 val, char *out) {
asm("rev %[dst], %[src]" :: [dst]"=r"(val), [src]"r"(val));
binhex((u8*)&val, 4, out);
}
My idea is to take the argument val, flip it (endianness) using the rev instruction, and then pass it on.
From what I've read, the above code seems to be correct, the destination register has the =r flag, which implies that the register can be written to. However, when run though GCC, I get the error: input operand constraint contains '='
If I change the flag to simply r then it will compile fine, but the value of val does not change.
The error is telling you what is going wrong -- the = constraint applies only to outputs, not inputs, and your asm pattern has two inputs (one confusingly called 'dst') and no outputs. You probably meant to have 'dst' be an output:
asm("rev %[dst], %[src]" : [dst]"=r"(val) : [src]"r"(val));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With