DRAFT riscv64: simplify assembly constructs not supported by tcc.
At the moment tcc does not support assembler instructions with C expression operands. As a workaround read values directly from stack. * lib/linux/riscv64-mes-tcc/_exit.c * lib/linux/riscv64-mes-tcc/_write.c * lib/linux/riscv64-mes-tcc/syscall.c
This commit is contained in:
parent
10054b2f17
commit
958da104e5
|
@ -28,12 +28,10 @@
|
||||||
void
|
void
|
||||||
_exit (int code)
|
_exit (int code)
|
||||||
{
|
{
|
||||||
register long __a7 asm ("a7") = SYS_exit;
|
|
||||||
register long __a0 asm ("a0") = code;
|
|
||||||
asm volatile (
|
asm volatile (
|
||||||
|
"addi a7, zero, 93\n\t"
|
||||||
|
"ld a0, s0, -24\n\t"
|
||||||
"ecall\n\t"
|
"ecall\n\t"
|
||||||
: // no outputs
|
|
||||||
: "r" (__a0), "r" (__a7)
|
|
||||||
);
|
);
|
||||||
// not reached
|
// not reached
|
||||||
_exit (0);
|
_exit (0);
|
||||||
|
|
|
@ -28,14 +28,11 @@
|
||||||
ssize_t
|
ssize_t
|
||||||
_write (int filedes, void const *buffer, size_t size)
|
_write (int filedes, void const *buffer, size_t size)
|
||||||
{
|
{
|
||||||
register long __a7 asm ("a7") = (long) SYS_write;
|
|
||||||
register long __a0 asm ("a0") = (long) filedes;
|
|
||||||
register long __a1 asm ("a1") = (long) buffer;
|
|
||||||
register long __a2 asm ("a2") = (long) size;
|
|
||||||
asm volatile (
|
asm volatile (
|
||||||
|
"addi a7, zero, 64\n\t"
|
||||||
|
"ld a0, s0, -24\n\t"
|
||||||
|
"ld a1, s0, -32\n\t"
|
||||||
|
"ld a2, s0, -40\n\t"
|
||||||
"ecall\n\t"
|
"ecall\n\t"
|
||||||
: "+r" (__a0)
|
|
||||||
: "r" (__a7), "r" (__a1), "r" (__a2)
|
|
||||||
);
|
);
|
||||||
return (ssize_t)__a0;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,89 +27,70 @@
|
||||||
long
|
long
|
||||||
__sys_call (long sys_call)
|
__sys_call (long sys_call)
|
||||||
{
|
{
|
||||||
register long __a7 asm ("a7") = sys_call;
|
|
||||||
register long __a0 asm ("a0");
|
|
||||||
asm volatile (
|
asm volatile (
|
||||||
|
"ld a7, s0, -24\n\t"
|
||||||
"ecall\n\t"
|
"ecall\n\t"
|
||||||
: "=r" (__a0)
|
|
||||||
: "r" (__a7)
|
|
||||||
);
|
);
|
||||||
return __a0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
long
|
long
|
||||||
__sys_call1 (long sys_call, long one)
|
__sys_call1 (long sys_call, long one)
|
||||||
{
|
{
|
||||||
register long __a7 asm ("a7") = sys_call;
|
|
||||||
register long __a0 asm ("a0") = one;
|
|
||||||
asm volatile (
|
asm volatile (
|
||||||
|
"ld a7, s0, -24\n\t"
|
||||||
|
"ld a0, s0, -32\n\t"
|
||||||
"ecall\n\t"
|
"ecall\n\t"
|
||||||
: "+r" (__a0)
|
|
||||||
: "r" (__a7)
|
|
||||||
);
|
);
|
||||||
return __a0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
long
|
long
|
||||||
__sys_call2 (long sys_call, long one, long two)
|
__sys_call2 (long sys_call, long one, long two)
|
||||||
{
|
{
|
||||||
register long __a7 asm ("a7") = sys_call;
|
|
||||||
register long __a0 asm ("a0") = one;
|
|
||||||
register long __a1 asm ("a1") = two;
|
|
||||||
asm volatile (
|
asm volatile (
|
||||||
|
"ld a7, s0, -24\n\t"
|
||||||
|
"ld a0, s0, -32\n\t"
|
||||||
|
"ld a1, s0, -40\n\t"
|
||||||
"ecall\n\t"
|
"ecall\n\t"
|
||||||
: "+r" (__a0)
|
|
||||||
: "r" (__a7), "r" (__a1)
|
|
||||||
);
|
);
|
||||||
return __a0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
long
|
long
|
||||||
__sys_call3 (long sys_call, long one, long two, long three)
|
__sys_call3 (long sys_call, long one, long two, long three)
|
||||||
{
|
{
|
||||||
register long __a7 asm ("a7") = sys_call;
|
|
||||||
register long __a0 asm ("a0") = one;
|
|
||||||
register long __a1 asm ("a1") = two;
|
|
||||||
register long __a2 asm ("a2") = three;
|
|
||||||
asm volatile (
|
asm volatile (
|
||||||
|
"ld a7, s0, -24\n\t"
|
||||||
|
"ld a0, s0, -32\n\t"
|
||||||
|
"ld a1, s0, -40\n\t"
|
||||||
|
"ld a2, s0, -48\n\t"
|
||||||
"ecall\n\t"
|
"ecall\n\t"
|
||||||
: "+r" (__a0)
|
|
||||||
: "r" (__a7), "r" (__a1), "r" (__a2)
|
|
||||||
);
|
);
|
||||||
return __a0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
long
|
long
|
||||||
__sys_call4 (long sys_call, long one, long two, long three, long four)
|
__sys_call4 (long sys_call, long one, long two, long three, long four)
|
||||||
{
|
{
|
||||||
register long __a7 asm ("a7") = sys_call;
|
|
||||||
register long __a0 asm ("a0") = one;
|
|
||||||
register long __a1 asm ("a1") = two;
|
|
||||||
register long __a2 asm ("a2") = three;
|
|
||||||
register long __a3 asm ("a3") = four;
|
|
||||||
asm volatile (
|
asm volatile (
|
||||||
|
"ld a7, s0, -24\n\t"
|
||||||
|
"ld a0, s0, -32\n\t"
|
||||||
|
"ld a1, s0, -40\n\t"
|
||||||
|
"ld a2, s0, -48\n\t"
|
||||||
|
"ld a3, s0, -56\n\t"
|
||||||
"ecall\n\t"
|
"ecall\n\t"
|
||||||
: "+r" (__a0)
|
|
||||||
: "r" (__a7), "r" (__a1), "r" (__a2), "r" (__a3)
|
|
||||||
);
|
);
|
||||||
return __a0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
long
|
long
|
||||||
__sys_call5 (long sys_call, long one, long two, long three, long four, long five)
|
__sys_call5 (long sys_call, long one, long two, long three, long four, long five)
|
||||||
{
|
{
|
||||||
register long __a7 asm ("a7") = sys_call;
|
|
||||||
register long __a0 asm ("a0") = one;
|
|
||||||
register long __a1 asm ("a1") = two;
|
|
||||||
register long __a2 asm ("a2") = three;
|
|
||||||
register long __a3 asm ("a3") = four;
|
|
||||||
register long __a4 asm ("a4") = five;
|
|
||||||
asm volatile (
|
asm volatile (
|
||||||
|
"ld a7, s0, -24\n\t"
|
||||||
|
"ld a0, s0, -32\n\t"
|
||||||
|
"ld a1, s0, -40\n\t"
|
||||||
|
"ld a2, s0, -48\n\t"
|
||||||
|
"ld a3, s0, -56\n\t"
|
||||||
|
"ld a4, s0, -64\n\t"
|
||||||
"ecall\n\t"
|
"ecall\n\t"
|
||||||
: "+r" (__a0)
|
|
||||||
: "r" (__a7), "r" (__a1), "r" (__a2), "r" (__a3), "r" (__a4)
|
|
||||||
);
|
);
|
||||||
return __a0;
|
|
||||||
}
|
}
|
||||||
// *INDENT-ON*
|
// *INDENT-ON*
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue