I'm trying to do a simple inline asm command in C
and compile it with gcc. I want to push the variable num
to the stack:
asm (
"push %0"
: //output
: "r"(num) //input
: //clobber
);
The above is generating the error:
Error: expression too complex -- `push r3'
I'm following this tutorial and I found nothing about the push
command.
I also tried:
asm ( "push %num" ); //Assembler Error: expression too complex -- `push %num'
and:
asm ( "push %[num]" ); //gcc error: undefined named operand 'num'
But none worked.
edit:
I'm using this compiler: arm-linux-gnueabihf-gcc
In ARM assembly, the push
instruction is a shorthand for stmdb
. It can push multiple registers at once. Thus, you have to use braces around the operand as it indicates a set of registers:
asm("push {%0}" : : "r"(num) : );
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