mirror of
https://github.com/cirosantilli/linux-kernel-module-cheat.git
synced 2026-01-30 05:24:25 +01:00
asm: start x86 intrinsics examples
Split userland/arch/<arch>/c/ into inline_asm and intrinsics, and move programs that don't match either up.
This commit is contained in:
20
userland/arch/arm/inline_asm/add.c
Normal file
20
userland/arch/arm/inline_asm/add.c
Normal file
@@ -0,0 +1,20 @@
|
||||
/* 1 + 2 == 3
|
||||
*
|
||||
* https://github.com/cirosantilli/linux-kernel-module-cheat#gcc-inline-assembly
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
int main(void) {
|
||||
uint32_t in0 = 1, in1 = 2, out;
|
||||
__asm__ (
|
||||
"add %[out], %[in0], %[in1];"
|
||||
: [out] "=r" (out)
|
||||
: [in0] "r" (in0),
|
||||
[in1] "r" (in1)
|
||||
);
|
||||
assert(in0 == 1);
|
||||
assert(in1 == 2);
|
||||
assert(out == 3);
|
||||
}
|
||||
Reference in New Issue
Block a user