Skip to content

Commit

Permalink
Fixed some compiler errors in int64.h.
Browse files Browse the repository at this point in the history
Fixed and tested ARM assembler version of fix16_mul.
  • Loading branch information
flatmush committed Mar 16, 2011
1 parent 1870ec0 commit 297e94e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
9 changes: 5 additions & 4 deletions libfixmath/fix16.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,17 @@ fix16_t fix16_sadd(fix16_t inArg0, fix16_t inArg1) {

#if defined(__arm__) || defined(_ARM) || defined(__thumb2__)
fix16_t fix16_mul(int32_t inArg0, int32_t inArg1) {
fix16_t res;
register fix16_t res;
register fix16_t tmp;
asm(
"smull %0, r0, %1, %2\n\t"
"smull %0, %3, %1, %2\n\t"
#ifndef FIXMATH_NO_ROUNDING
"add %0, %0, #0x8000\n\t"
#endif
"mov %0, %0, lsr #16\n\t"
"orr %0, %0, r0, lsl #16"
"orr %0, %0, %3, lsl #16"
: "=r"(res)
: "r"(inArg0), "r"(inArg1)
: "r"(inArg0), "r"(inArg1), "r"(tmp)
: "r0");
return res;
}
Expand Down
20 changes: 10 additions & 10 deletions libfixmath/int64.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@ static inline __int64_t int64_from_int32(int32_t x) { return (__int64_t){ (x < 0
static inline int32_t int64_hi(__int64_t x) { return x.hi; }
static inline uint32_t int64_lo(__int64_t x) { return x.lo; }

static inline int int64_cmp_eq(__int64_t x, __int64_t y) { return ((x.hi == y.hi) && (x.lo == y.lo)); }
static inline int int64_cmp_ne(__int64_t x, __int64_t y) { return ((x.hi != y.hi) || (x.lo != y.lo)); }
static inline int int64_cmp_gt(__int64_t x, __int64_t y) { return ((x.hi > y.hi) || ((x.hi == y.hi) && (x.lo > y.lo))); }
static inline int int64_cmp_ge(__int64_t x, __int64_t y) { return ((x.hi > y.hi) || ((x.hi == y.hi) && (x.lo >= y.lo))); }
static inline int int64_cmp_lt(__int64_t x, __int64_t y) { return ((x.hi < y.hi) || ((x.hi == y.hi) && (x.lo < y.lo))); }
static inline int int64_cmp_le(__int64_t x, __int64_t y) { return ((x.hi < y.hi) || ((x.hi == y.hi) && (x.lo <= y.lo))); }

static inline __int64_t int64_add(__int64_t x, __int64_t y) {
__int64_t ret;
ret.hi = x.hi + y.hi;
Expand Down Expand Up @@ -129,28 +136,21 @@ static inline __int64_t int64_div_i64_i32(__int64_t x, int32_t y) {
__int64_t _y = int64_from_int32(y);

__int64_t i;
for(i = int64_from_int32(1); _y < x; _y = int64_shift(_y, 1), i = int64_shift(i, 1));
for(i = int64_from_int32(1); int64_cmp_lt(_y, x); _y = int64_shift(_y, 1), i = int64_shift(i, 1));

while(x.hi) {
_y = int64_shift(_y, -1);
i = int64_shift(i, -1);
if(in64_cmp_ge(x, _y)) {
if(int64_cmp_ge(x, _y)) {
x = int64_sub(x, _y);
ret = int64_add(ret, i);
}
}

ret = int64_add(ret, int64_from_int32(x.lo / y))
ret = int64_add(ret, int64_from_int32(x.lo / y));
return (neg ? int64_neg(ret) : ret);
}

static inline int int64_cmp_eq(__int64_t x, __int64_t y) { return ((x.hi == y.hi) && (x.lo == y.lo)); }
static inline int int64_cmp_ne(__int64_t x, __int64_t y) { return ((x.hi != y.hi) || (x.lo != y.lo)); }
static inline int int64_cmp_gt(__int64_t x, __int64_t y) { return ((x.hi > y.hi) || ((x.hi == y.hi) && (x.lo > y.lo))); }
static inline int int64_cmp_ge(__int64_t x, __int64_t y) { return ((x.hi > y.hi) || ((x.hi == y.hi) && (x.lo >= y.lo))); }
static inline int int64_cmp_lt(__int64_t x, __int64_t y) { return ((x.hi < y.hi) || ((x.hi == y.hi) && (x.lo < y.lo))); }
static inline int int64_cmp_le(__int64_t x, __int64_t y) { return ((x.hi < y.hi) || ((x.hi == y.hi) && (x.lo <= y.lo))); }

#define int64_t __int64_t

#endif
Expand Down

0 comments on commit 297e94e

Please sign in to comment.