ARM: Return both the quotient and the remainder.
* lib/mes/div.c (__aeabi_idivmod): Use ldiv. Return both quotient and remainder. (__aeabi_uidivmod): Use __mesabi_uldiv. Return both quotient and remainder.
This commit is contained in:
parent
899b613dbc
commit
9a84e94a0a
|
@ -119,11 +119,14 @@ ldiv_t ldiv(long a, long b)
|
||||||
// /gnu/store/7sfr3vhxq7l4mai8m0fr1cd8w9xcj9dh-binutils-2.31.1/bin/ld: gcc-lib/libc.a(ntoab.o): in function `ntoab':
|
// /gnu/store/7sfr3vhxq7l4mai8m0fr1cd8w9xcj9dh-binutils-2.31.1/bin/ld: gcc-lib/libc.a(ntoab.o): in function `ntoab':
|
||||||
// ntoab.c:(.text+0x54): undefined reference to `__aeabi_uidivmod'
|
// ntoab.c:(.text+0x54): undefined reference to `__aeabi_uidivmod'
|
||||||
// /gnu/store/7sfr3vhxq7l4mai8m0fr1cd8w9xcj9dh-binutils-2.31.1/bin/ld: ntoab.c:(.text+0x62): undefined reference to `__aeabi_uidiv'
|
// /gnu/store/7sfr3vhxq7l4mai8m0fr1cd8w9xcj9dh-binutils-2.31.1/bin/ld: ntoab.c:(.text+0x62): undefined reference to `__aeabi_uidiv'
|
||||||
|
/* Result: r0: quotient; r1: remainder */
|
||||||
long
|
long
|
||||||
__aeabi_idivmod (long a, long b)
|
__aeabi_idivmod (long a, long b)
|
||||||
{
|
{
|
||||||
ldiv_t result = ldiv(a, b);
|
ldiv_t result = ldiv(a, b);
|
||||||
return result.rem;
|
register long rem_result asm("r1");
|
||||||
|
rem_result = result.rem;
|
||||||
|
return result.quot;
|
||||||
}
|
}
|
||||||
|
|
||||||
long
|
long
|
||||||
|
@ -133,12 +136,22 @@ __aeabi_idiv (long a, long b)
|
||||||
return result.quot;
|
return result.quot;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
unsigned long quot;
|
||||||
|
unsigned long rem;
|
||||||
|
} uidiv_t;
|
||||||
|
|
||||||
|
/* Result: r0: quotient; r1: remainder */
|
||||||
unsigned long
|
unsigned long
|
||||||
__aeabi_uidivmod (unsigned long a, unsigned long b)
|
__aeabi_uidivmod (unsigned long a, unsigned long b)
|
||||||
{
|
{
|
||||||
unsigned long remainder;
|
unsigned long quot;
|
||||||
__mesabi_uldiv (a, b, &remainder);
|
unsigned long rem;
|
||||||
return remainder;
|
register unsigned long rem_result asm("r1");
|
||||||
|
quot = __mesabi_uldiv (a, b, &rem);
|
||||||
|
rem_result = rem;
|
||||||
|
return quot;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned long
|
unsigned long
|
||||||
|
|
Loading…
Reference in New Issue