__asm__ keyword asm is GCC macro definitions
used to declare an inline assembler expressions
__volatile__ GCC is the keyword volatile macro definition
#define volatile volatile
statement to the GCC does not allow optimization of the inline assembler, or when using an optimization option (-O) compiled, GCC will be based on their own judgment to decide whether to the inline assembler instructions expression optimize away.
Inline assembler format with C / C ++ expression is:
asm volatile(“Instruction List” : Output : Input : Clobber/Modify);
When a plurality of instructions in the "Instruction List" when
you can list a pair of quotation marks in all the instructions,
but also one or several instructions can be placed in a pair of quotes, more than all orders placed within quotes. To separate them or newline (/ n); must be a semicolon ().
On ARM architecture the interrupt disabling operation
Three instructions / separate n.
Only two output registers, no input
Change memory
int disable_interrupts (void)
{
unsigned long old,temp;
__asm__ __volatile__("mrs %0, cpsr/n"
"orr %1, %0, #0x80/n"
"msr cpsr_c, %1"
: "=r" (old), "=r" (temp)
:
: "memory");
return (old & 0x80) == 0;
}
ref
command query
https://blog.csdn.net/qq_35608277/article/details/105123483
the CPSR query
https://blog.csdn.net/qq_35608277/article/details/105107353
ref
other
https://blog.csdn.net/geekcome/article/details/6216436