userland: support arch specific examples

This commit is contained in:
Ciro Santilli 六四事件 法轮功
2018-11-20 00:00:00 +00:00
parent 454af5d03a
commit 07000300ab
12 changed files with 78 additions and 2 deletions

View File

@@ -0,0 +1 @@
../../Makefile

View File

@@ -0,0 +1,8 @@
#include <assert.h>
#include <inttypes.h>
int main(void) {
register uint32_t x0 __asm__ ("x0");
__asm__ ("mov x0, #1;" : : : "%x0");
assert(x0 == 1);
}

View File

@@ -0,0 +1 @@
COMMON_DIR = ../../..

View File

@@ -0,0 +1 @@
../../Makefile

View File

@@ -0,0 +1,16 @@
#include <assert.h>
#include <inttypes.h>
int main(void) {
uint32_t in = 1;
uint32_t out = 0;
__asm__ (
"movl %1, %%eax;"
"inc %%eax;"
"movl %%eax, %0"
: "=m" (out)
: "m" (in)
: "%eax"
);
assert(out == in + 1);
}

View File

@@ -0,0 +1,19 @@
.data
s:
.ascii "hello\n"
len = . - s
.text
.global _start
_start:
/* Write. */
mov $1, %rax
mov $1, %rdi
mov $s, %rsi
mov $len, %rdx
syscall
/* Exit. */
mov $60, %rax
mov $0, %rdi
syscall

View File

@@ -0,0 +1 @@
COMMON_DIR = ../../..