mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 01:55:19 +00:00
parent
c30b1fe893
commit
f2bc1f0e11
5 changed files with 39 additions and 32 deletions
|
@ -25,10 +25,18 @@ __brkdiv0(void)
|
||||||
__emit(0xDEF9);
|
__emit(0xDEF9);
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef struct _ARM_DIVRESULT
|
typedef union _ARM_DIVRESULT
|
||||||
{
|
{
|
||||||
UINT3264 quotient; /* to be returned in R0 */
|
#ifdef _USE_64_BITS_
|
||||||
UINT3264 modulus; /* to be returned in R1 */
|
unsigned int raw_data[4];
|
||||||
|
#else
|
||||||
|
unsigned long long raw_data;
|
||||||
|
#endif
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
UINT3264 quotient; /* to be returned in R0(R0,R1) */
|
||||||
|
UINT3264 modulus; /* to be returned in R1(R2,R3) */
|
||||||
|
} data;
|
||||||
} ARM_DIVRESULT;
|
} ARM_DIVRESULT;
|
||||||
|
|
||||||
#ifndef _USE_64_BITS_
|
#ifndef _USE_64_BITS_
|
||||||
|
@ -36,9 +44,9 @@ __forceinline
|
||||||
#endif
|
#endif
|
||||||
void
|
void
|
||||||
__rt_div_worker(
|
__rt_div_worker(
|
||||||
ARM_DIVRESULT *result,
|
|
||||||
UINT3264 divisor,
|
UINT3264 divisor,
|
||||||
UINT3264 dividend)
|
UINT3264 dividend,
|
||||||
|
ARM_DIVRESULT* result)
|
||||||
{
|
{
|
||||||
UINT3264 shift;
|
UINT3264 shift;
|
||||||
UINT3264 mask;
|
UINT3264 mask;
|
||||||
|
@ -70,8 +78,8 @@ __rt_div_worker(
|
||||||
|
|
||||||
if (divisor > dividend)
|
if (divisor > dividend)
|
||||||
{
|
{
|
||||||
result->quotient = 0;
|
result->data.quotient = 0;
|
||||||
result->modulus = divisor;
|
result->data.modulus = divisor;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -110,7 +118,6 @@ __rt_div_worker(
|
||||||
}
|
}
|
||||||
#endif // _SIGNED_DIV_
|
#endif // _SIGNED_DIV_
|
||||||
|
|
||||||
result->quotient = quotient;
|
result->data.quotient = quotient;
|
||||||
result->modulus = dividend;
|
result->data.modulus = dividend;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,14 +13,15 @@
|
||||||
|
|
||||||
#include "__rt_div_worker.h"
|
#include "__rt_div_worker.h"
|
||||||
|
|
||||||
ARM_DIVRESULT
|
unsigned long long
|
||||||
__rt_sdiv(
|
__rt_sdiv(
|
||||||
int divisor,
|
int divisor,
|
||||||
int dividend)
|
int dividend)
|
||||||
{
|
{
|
||||||
ARM_DIVRESULT result;
|
ARM_DIVRESULT result;
|
||||||
|
|
||||||
__rt_sdiv_worker(&result, divisor, dividend);
|
__rt_sdiv_worker(divisor, dividend, &result);
|
||||||
return result;
|
|
||||||
|
return result.raw_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,19 +18,18 @@
|
||||||
NESTED_ENTRY __rt_sdiv64
|
NESTED_ENTRY __rt_sdiv64
|
||||||
|
|
||||||
/* Allocate stack space and store parameters there */
|
/* Allocate stack space and store parameters there */
|
||||||
stmdb sp!,{r0,r1,r2,r3,lr}
|
push {lr}
|
||||||
|
sub sp,sp,0x10
|
||||||
|
mov r12,sp
|
||||||
|
push {r12}
|
||||||
PROLOG_END
|
PROLOG_END
|
||||||
|
|
||||||
/* Load pointer to stack structure into R0 */
|
|
||||||
mov r0, sp
|
|
||||||
|
|
||||||
/* Call the C worker function */
|
/* Call the C worker function */
|
||||||
adr lr, Return
|
bl __rt_sdiv64_worker
|
||||||
b __rt_sdiv64_worker
|
add sp,sp,0x04
|
||||||
|
|
||||||
Return
|
|
||||||
/* Move result data into the appropriate registers and return */
|
/* Move result data into the appropriate registers and return */
|
||||||
ldmia sp!,{r0,r1,r2,r3,pc}
|
pop {r0,r1,r2,r3,pc}
|
||||||
NESTED_END __rt_sdiv64
|
NESTED_END __rt_sdiv64
|
||||||
|
|
||||||
END
|
END
|
||||||
|
|
|
@ -11,14 +11,15 @@
|
||||||
|
|
||||||
#include "__rt_div_worker.h"
|
#include "__rt_div_worker.h"
|
||||||
|
|
||||||
ARM_DIVRESULT
|
unsigned long long
|
||||||
__rt_udiv(
|
__rt_udiv(
|
||||||
unsigned int divisor,
|
unsigned int divisor,
|
||||||
unsigned int dividend)
|
unsigned int dividend)
|
||||||
{
|
{
|
||||||
ARM_DIVRESULT result;
|
ARM_DIVRESULT result;
|
||||||
|
|
||||||
__rt_udiv_worker(&result, divisor, dividend);
|
__rt_udiv_worker(divisor, dividend, &result);
|
||||||
return result;
|
|
||||||
|
return result.raw_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,19 +18,18 @@
|
||||||
NESTED_ENTRY __rt_udiv64
|
NESTED_ENTRY __rt_udiv64
|
||||||
|
|
||||||
/* Allocate stack space and store parameters there */
|
/* Allocate stack space and store parameters there */
|
||||||
stmdb sp!,{r0,r1,r2,r3,lr}
|
push {lr}
|
||||||
|
sub sp,sp,0x10
|
||||||
|
mov r12,sp
|
||||||
|
push {r12}
|
||||||
PROLOG_END
|
PROLOG_END
|
||||||
|
|
||||||
/* Load pointer to stack structure into R0 */
|
|
||||||
mov r0, sp
|
|
||||||
|
|
||||||
/* Call the C worker function */
|
/* Call the C worker function */
|
||||||
adr lr, Return
|
bl __rt_udiv64_worker
|
||||||
b __rt_udiv64_worker
|
add sp,sp,0x04
|
||||||
|
|
||||||
Return
|
|
||||||
/* Move result data into the appropriate registers and return */
|
/* Move result data into the appropriate registers and return */
|
||||||
ldmia sp!,{r0,r1,r2,r3,pc}
|
pop {r0,r1,r2,r3,pc}
|
||||||
NESTED_END __rt_udiv64
|
NESTED_END __rt_udiv64
|
||||||
|
|
||||||
END
|
END
|
||||||
|
|
Loading…
Reference in a new issue