mirror of
https://github.com/cirosantilli/linux-kernel-module-cheat.git
synced 2026-01-13 20:12:26 +00:00
19 lines
388 B
C
19 lines
388 B
C
/* Increment a variable in inline assembly.
|
|
*
|
|
* https://cirosantilli.com/linux-kernel-module-cheat#gcc-inline-assembly
|
|
*/
|
|
|
|
#include <assert.h>
|
|
#include <inttypes.h>
|
|
|
|
int main(void) {
|
|
uint32_t my_local_var = 1;
|
|
__asm__ (
|
|
"add %[my_local_var], %[my_local_var], #1;"
|
|
: [my_local_var] "+r" (my_local_var)
|
|
:
|
|
:
|
|
);
|
|
assert(my_local_var == 2);
|
|
}
|