mirror of
https://github.com/cirosantilli/linux-kernel-module-cheat.git
synced 2026-01-23 02:05:57 +01:00
Split userland/arch/<arch>/c/ into inline_asm and intrinsics, and move programs that don't match either up.
21 lines
408 B
C
21 lines
408 B
C
/* 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);
|
|
}
|