From 15ffa40b6eb137bda1aab98f9f765864950e77b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ciro=20Santilli=20=E5=85=AD=E5=9B=9B=E4=BA=8B=E4=BB=B6=20?= =?UTF-8?q?=E6=B3=95=E8=BD=AE=E5=8A=9F?= Date: Thu, 25 Jun 2020 10:00:09 +0000 Subject: [PATCH] inline_asm: remember register variables :-) --- README.adoc | 6 +++--- userland/arch/aarch64/inline_asm/freestanding/linux/hello.c | 3 +-- userland/arch/x86_64/inline_asm/freestanding/linux/hello.c | 3 +-- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/README.adoc b/README.adoc index 83555a4..1bd8ad7 100644 --- a/README.adoc +++ b/README.adoc @@ -19741,11 +19741,11 @@ The following <> programs illustrate how to make system calls: * x86_64 ** link:userland/arch/x86_64/freestanding/linux/hello.S[] ** link:userland/arch/x86_64/freestanding/linux/int_system_call.S[] -** link:userland/arch/x86_64/inline_asm/freestanding/linux/hello.c[] -** link:userland/arch/x86_64/inline_asm/freestanding/linux/hello_regvar.c[] +** link:userland/arch/x86_64/inline_asm/freestanding/linux/hello.c[]: this shows how to do system calls from inline assembly without any C standard library helpers like `syscall` +** link:userland/arch/x86_64/inline_asm/freestanding/linux/hello_regvar.c[]: same as link:userland/arch/x86_64/inline_asm/freestanding/linux/hello.c[] but using register variables instead of register constraints * arm ** link:userland/arch/arm/freestanding/linux/hello.S[] -** link:userland/arch/arm/inline_asm/freestanding/linux/hello.c[] +** link:userland/arch/arm/inline_asm/freestanding/linux/hello.c[]: there are no register constraints in ARM, so register variables are the most efficient way of storing variables in specific general purpose registers: https://stackoverflow.com/questions/3929442/how-to-specify-an-individual-register-as-constraint-in-arm-gcc-inline-assembly/54845046#54845046 * aarch64 ** link:userland/arch/aarch64/freestanding/linux/hello.S[] ** link:userland/arch/aarch64/inline_asm/freestanding/linux/hello.c[] diff --git a/userland/arch/aarch64/inline_asm/freestanding/linux/hello.c b/userland/arch/aarch64/inline_asm/freestanding/linux/hello.c index 865fc0c..7cdf186 100644 --- a/userland/arch/aarch64/inline_asm/freestanding/linux/hello.c +++ b/userland/arch/aarch64/inline_asm/freestanding/linux/hello.c @@ -1,6 +1,5 @@ /* aarch64 freestanding C inline assemby Linux hello world - * https://cirosantilli.com/linux-kernel-module-cheat#linux-system-calls - */ + * https://cirosantilli.com/linux-kernel-module-cheat#linux-system-calls */ #include diff --git a/userland/arch/x86_64/inline_asm/freestanding/linux/hello.c b/userland/arch/x86_64/inline_asm/freestanding/linux/hello.c index 553c07a..28e8775 100644 --- a/userland/arch/x86_64/inline_asm/freestanding/linux/hello.c +++ b/userland/arch/x86_64/inline_asm/freestanding/linux/hello.c @@ -1,6 +1,5 @@ /* x86_64 freestanding C inline assemby Linux hello world - * https://cirosantilli.com/linux-kernel-module-cheat#linux-system-calls - */ + * https://cirosantilli.com/linux-kernel-module-cheat#linux-system-calls */ #define _XOPEN_SOURCE 700 #include