mirror of
https://github.com/YohannDR/mzm.git
synced 2025-02-23 23:22:15 +00:00
Decompile most of libgcc
This commit is contained in:
parent
465795eba7
commit
b7421d6db4
7
Makefile
7
Makefile
@ -39,7 +39,7 @@ CFLAGS = -O2 -mthumb-interwork -fhex-asm
|
||||
CPPFLAGS = -nostdinc -Isrc/
|
||||
|
||||
# Objects
|
||||
CSRC = $(wildcard src/*.c) $(wildcard src/sram/*.c)
|
||||
CSRC = $(wildcard src/*.c) $(wildcard src/sram/*.c) $(wildcard src/libgcc/*.c)
|
||||
.PRECIOUS: $(CSRC:.c=.s)
|
||||
DATA = data/data_0x0808c71c.s
|
||||
ASMSRC = $(CSRC:.c=.s) $(wildcard asm/*.s) $(DATA)
|
||||
@ -112,7 +112,7 @@ $(ELF) $(MAP): $(OBJ) linker.ld
|
||||
|
||||
%.dump: %.gba
|
||||
$(MSG) OBJDUMP $@
|
||||
$Q$(OBJDUMP) -D -bbinary -marm7tdmi -Mforce-thumb $< | $(TAIL) -n+3 > $@
|
||||
$Q$(OBJDUMP) -D -bbinary -marm7tdmi -Mforce-thumb --stop-address 0x8c728 $< | $(TAIL) -n+3 >$@
|
||||
|
||||
%.o: %.s
|
||||
$(MSG) AS $@
|
||||
@ -129,6 +129,9 @@ data/data_0x0808c71c.s: data/data.txt
|
||||
src/sram/%.s: CFLAGS = -O1 -mthumb-interwork -fhex-asm
|
||||
src/sram/%.s: src/sram/%.c
|
||||
|
||||
src/libgcc/%.s: CFLAGS = -O2 -fhex-asm
|
||||
src/libgcc/%.s: src/libgcc/%.c
|
||||
|
||||
tools/%: tools/%.c
|
||||
$(MSG) HOSTCC $@
|
||||
$Q$(HOSTCC) $< $(HOSTCFLAGS) $(HOSTCPPFLAGS) -o $@
|
||||
|
@ -69694,10 +69694,10 @@ lbl_08027d94: @ jump table
|
||||
.4byte lbl_08027e2c @ case 6
|
||||
lbl_08027db0:
|
||||
adds r0, r2, #0
|
||||
bl sub_0808bb30
|
||||
bl __floatsidf
|
||||
ldr r3, lbl_08027dd0 @ =0x9999999a
|
||||
ldr r2, lbl_08027dcc @ =0x3fe99999
|
||||
bl sub_0808b40c
|
||||
bl __muldf3
|
||||
bl sub_0808accc
|
||||
lsls r0, r0, #0x10
|
||||
lsrs r2, r0, #0x10
|
||||
@ -69709,10 +69709,10 @@ lbl_08027dcc: .4byte 0x3fe99999
|
||||
lbl_08027dd0: .4byte 0x9999999a
|
||||
lbl_08027dd4:
|
||||
adds r0, r2, #0
|
||||
bl sub_0808bb30
|
||||
bl __floatsidf
|
||||
ldr r3, lbl_08027dfc @ =0x9999999a
|
||||
ldr r2, lbl_08027df8 @ =0x3fe99999
|
||||
bl sub_0808b40c
|
||||
bl __muldf3
|
||||
bl sub_0808accc
|
||||
lsls r0, r0, #0x10
|
||||
lsrs r2, r0, #0x10
|
||||
@ -69734,10 +69734,10 @@ lbl_08027e00:
|
||||
b lbl_08027e5c
|
||||
lbl_08027e06:
|
||||
adds r0, r2, #0
|
||||
bl sub_0808bb30
|
||||
bl __floatsidf
|
||||
ldr r3, lbl_08027e28 @ =0x9999999a
|
||||
ldr r2, lbl_08027e24 @ =0x3fe99999
|
||||
bl sub_0808b40c
|
||||
bl __muldf3
|
||||
bl sub_0808accc
|
||||
lsls r0, r0, #0x10
|
||||
lsrs r2, r0, #0x10
|
||||
@ -69749,10 +69749,10 @@ lbl_08027e24: .4byte 0x3fe99999
|
||||
lbl_08027e28: .4byte 0x9999999a
|
||||
lbl_08027e2c:
|
||||
adds r0, r2, #0
|
||||
bl sub_0808bb30
|
||||
bl __floatsidf
|
||||
ldr r3, lbl_08027e54 @ =0x9999999a
|
||||
ldr r2, lbl_08027e50 @ =0x3fe99999
|
||||
bl sub_0808b40c
|
||||
bl __muldf3
|
||||
bl sub_0808accc
|
||||
lsls r0, r0, #0x10
|
||||
lsrs r2, r0, #0x10
|
||||
@ -164396,20 +164396,20 @@ power_bomb_explosion: @ 0x080574a4
|
||||
lsls r7, r0, #2
|
||||
lsls r6, r0, #3
|
||||
adds r0, r7, #0
|
||||
bl sub_0808bb30
|
||||
bl __floatsidf
|
||||
ldr r4, lbl_080575f0 @ =0x3fee6666
|
||||
ldr r5, lbl_080575f4 @ =0x66666666
|
||||
adds r3, r5, #0
|
||||
adds r2, r4, #0
|
||||
bl sub_0808b40c
|
||||
bl sub_0808bbac
|
||||
bl __muldf3
|
||||
bl __fixdfsi
|
||||
adds r7, r0, #0
|
||||
adds r0, r6, #0
|
||||
bl sub_0808bb30
|
||||
bl __floatsidf
|
||||
adds r3, r5, #0
|
||||
adds r2, r4, #0
|
||||
bl sub_0808b40c
|
||||
bl sub_0808bbac
|
||||
bl __muldf3
|
||||
bl __fixdfsi
|
||||
adds r6, r0, #0
|
||||
rsbs r0, r6, #0
|
||||
lsls r0, r0, #0x10
|
||||
@ -191839,26 +191839,26 @@ lbl_08064c2c:
|
||||
cmp r0, #0
|
||||
bne lbl_08064c9c
|
||||
adds r0, r6, #0
|
||||
bl sub_0808bb30
|
||||
bl __floatsidf
|
||||
adds r5, r1, #0
|
||||
adds r4, r0, #0
|
||||
ldr r3, lbl_08064cf0 @ =0x083a0558
|
||||
movs r1, #0xa
|
||||
ldrsh r0, [r3, r1]
|
||||
bl sub_0808bb30
|
||||
bl __floatsidf
|
||||
ldr r2, lbl_08064cf4 @ =0x3ff80000
|
||||
ldr r3, lbl_08064cf8 @ =0x00000000
|
||||
bl sub_0808b6b4
|
||||
bl __divdf3
|
||||
adds r3, r1, #0
|
||||
adds r2, r0, #0
|
||||
ldr r0, lbl_08064cfc @ =0x40a64000
|
||||
ldr r1, lbl_08064d00 @ =0x00000000
|
||||
bl sub_0808b3d4
|
||||
bl __subdf3
|
||||
adds r3, r1, #0
|
||||
adds r2, r0, #0
|
||||
adds r1, r5, #0
|
||||
adds r0, r4, #0
|
||||
bl sub_0808ba4c
|
||||
bl __gedf2
|
||||
cmp r0, #0
|
||||
blt lbl_08064c9c
|
||||
mov r0, sb
|
||||
|
File diff suppressed because it is too large
Load Diff
60
asm/disasm_0x0808c6bc.s
Normal file
60
asm/disasm_0x0808c6bc.s
Normal file
@ -0,0 +1,60 @@
|
||||
.include "asm/macros.inc"
|
||||
|
||||
.syntax unified
|
||||
|
||||
thumb_func_start memcpy
|
||||
memcpy: @ 0x0808c6bc
|
||||
push {r4, r5, lr}
|
||||
adds r5, r0, #0
|
||||
adds r4, r5, #0
|
||||
adds r3, r1, #0
|
||||
cmp r2, #0xf
|
||||
bls lbl_0808c6fc
|
||||
adds r0, r3, #0
|
||||
orrs r0, r5
|
||||
movs r1, #3
|
||||
ands r0, r1
|
||||
cmp r0, #0
|
||||
bne lbl_0808c6fc
|
||||
adds r1, r5, #0
|
||||
lbl_0808c6d6:
|
||||
ldm r3!, {r0}
|
||||
stm r1!, {r0}
|
||||
ldm r3!, {r0}
|
||||
stm r1!, {r0}
|
||||
ldm r3!, {r0}
|
||||
stm r1!, {r0}
|
||||
ldm r3!, {r0}
|
||||
stm r1!, {r0}
|
||||
subs r2, #0x10
|
||||
cmp r2, #0xf
|
||||
bhi lbl_0808c6d6
|
||||
cmp r2, #3
|
||||
bls lbl_0808c6fa
|
||||
lbl_0808c6f0:
|
||||
ldm r3!, {r0}
|
||||
stm r1!, {r0}
|
||||
subs r2, #4
|
||||
cmp r2, #3
|
||||
bhi lbl_0808c6f0
|
||||
lbl_0808c6fa:
|
||||
adds r4, r1, #0
|
||||
lbl_0808c6fc:
|
||||
subs r2, #1
|
||||
movs r0, #1
|
||||
rsbs r0, r0, #0
|
||||
cmp r2, r0
|
||||
beq lbl_0808c716
|
||||
adds r1, r0, #0
|
||||
lbl_0808c708:
|
||||
ldrb r0, [r3]
|
||||
strb r0, [r4]
|
||||
adds r3, #1
|
||||
adds r4, #1
|
||||
subs r2, #1
|
||||
cmp r2, r1
|
||||
bne lbl_0808c708
|
||||
lbl_0808c716:
|
||||
adds r0, r5, #0
|
||||
pop {r4, r5, pc}
|
||||
.align 2, 0
|
@ -178,12 +178,12 @@ sub_0808accc: @ 0x0808accc
|
||||
adds r4, r0, #0
|
||||
ldr r3, lbl_0808acec @ =0x00000000
|
||||
ldr r2, lbl_0808ace8 @ =0x41e00000
|
||||
bl sub_0808ba4c
|
||||
bl __gedf2
|
||||
cmp r0, #0
|
||||
bge lbl_0808acf0
|
||||
adds r1, r5, #0
|
||||
adds r0, r4, #0
|
||||
bl sub_0808bbac
|
||||
bl __fixdfsi
|
||||
b lbl_0808ad06
|
||||
.align 2, 0
|
||||
lbl_0808ace8: .4byte 0x41e00000
|
||||
@ -193,8 +193,8 @@ lbl_0808acf0:
|
||||
ldr r2, lbl_0808ad08 @ =0xc1e00000
|
||||
adds r1, r5, #0
|
||||
adds r0, r4, #0
|
||||
bl sub_0808b3a4
|
||||
bl sub_0808bbac
|
||||
bl __adddf3
|
||||
bl __fixdfsi
|
||||
movs r1, #0x80
|
||||
lsls r1, r1, #0x18
|
||||
adds r0, r0, r1
|
||||
|
@ -41,6 +41,8 @@ SECTIONS {
|
||||
. = 0x00001cfc; timer3_callback = .;
|
||||
. = 0x00001d00; music_info = .;
|
||||
. = 0x00002924; sound_data = .;
|
||||
. = 0x000058e0; src/libgcc/fp-bit-base.o(.bss);
|
||||
. = 0x000058f8; src/libgcc/float.o(.bss);
|
||||
. = 0x00007e60; sp_sys = .;
|
||||
. = 0x00007fa0; sp_irq = .;
|
||||
. = 0x00007ff8; unk_03007ff8 = .;
|
||||
@ -70,6 +72,10 @@ SECTIONS {
|
||||
asm/disasm_0x08005368.o(.text);
|
||||
asm/libgcc.o(.text);
|
||||
asm/disasm_0x0808af18.o(.text);
|
||||
src/libgcc/fp-bit-base.o(.text);
|
||||
src/libgcc/float.o(.text);
|
||||
src/libgcc/libgcc.o(.text);
|
||||
asm/disasm_0x0808c6bc.o(.text);
|
||||
data/data_0x0808c71c.o(.text);
|
||||
} >rom
|
||||
|
||||
|
2
src/libgcc/float.c
Normal file
2
src/libgcc/float.c
Normal file
@ -0,0 +1,2 @@
|
||||
#define FLOAT
|
||||
#include "libgcc/fp-bit-base.c"
|
1289
src/libgcc/fp-bit-base.c
Normal file
1289
src/libgcc/fp-bit-base.c
Normal file
File diff suppressed because it is too large
Load Diff
155
src/libgcc/libgcc.c
Normal file
155
src/libgcc/libgcc.c
Normal file
@ -0,0 +1,155 @@
|
||||
/* clang-format off */
|
||||
|
||||
/* More subroutines needed by GCC output code on some machines. */
|
||||
/* Compile this one with gcc. */
|
||||
/* Copyright (C) 1989, 92-97, 1998 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU CC.
|
||||
It has been modified to match this project.
|
||||
|
||||
GNU CC is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU CC is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU CC; see the file COPYING. If not, write to
|
||||
the Free Software Foundation, 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA. */
|
||||
|
||||
/* As a special exception, if you link this library with other files,
|
||||
some of which are compiled with GCC, to produce an executable,
|
||||
this library does not by itself cause the resulting executable
|
||||
to be covered by the GNU General Public License.
|
||||
This exception does not however invalidate any other reasons why
|
||||
the executable file might be covered by the GNU General Public License. */
|
||||
|
||||
/* In the first part of this file, we are interfacing to calls generated
|
||||
by the compiler itself. These calls pass values into these routines
|
||||
which have very specific modes (rather than very specific types), and
|
||||
these compiler-generated calls also expect any return values to have
|
||||
very specific modes (rather than very specific types). Thus, we need
|
||||
to avoid using regular C language type names in this part of the file
|
||||
because the sizes for those types can be configured to be anything.
|
||||
Instead we use the following special type names. */
|
||||
|
||||
typedef unsigned int UQItype __attribute__ ((mode (QI)));
|
||||
typedef int SItype __attribute__ ((mode (SI)));
|
||||
typedef unsigned int USItype __attribute__ ((mode (SI)));
|
||||
typedef int DItype __attribute__ ((mode (DI)));
|
||||
typedef unsigned int UDItype __attribute__ ((mode (DI)));
|
||||
|
||||
typedef float SFtype __attribute__ ((mode (SF)));
|
||||
typedef float DFtype __attribute__ ((mode (DF)));
|
||||
|
||||
typedef int word_type __attribute__ ((mode (__word__)));
|
||||
|
||||
/* Make sure that we don't accidentally use any normal C language built-in
|
||||
type names in the first part of this file. Instead we want to use *only*
|
||||
the type names defined above. The following macro definitions insure
|
||||
that if we *do* accidentally use some normal C language built-in type name,
|
||||
we will get a syntax error. */
|
||||
|
||||
#define char bogus_type
|
||||
#define short bogus_type
|
||||
#define int bogus_type
|
||||
#define long bogus_type
|
||||
#define unsigned bogus_type
|
||||
#define float bogus_type
|
||||
#define double bogus_type
|
||||
|
||||
#define SI_TYPE_SIZE (sizeof (SItype) * 8)
|
||||
|
||||
struct DIstruct {USItype low, high;};
|
||||
|
||||
/* We need this union to unpack/pack DImode values, since we don't have
|
||||
any arithmetic yet. Incoming DImode parameters are stored into the
|
||||
`ll' field, and the unpacked result is read from the struct `s'. */
|
||||
|
||||
typedef union
|
||||
{
|
||||
struct DIstruct s;
|
||||
DItype ll;
|
||||
} DIunion;
|
||||
|
||||
#include "libgcc/longlong.h"
|
||||
|
||||
DItype
|
||||
__lshrdi3 (DItype u, word_type b)
|
||||
{
|
||||
DIunion w;
|
||||
word_type bm;
|
||||
DIunion uu;
|
||||
|
||||
if (b == 0)
|
||||
return u;
|
||||
|
||||
uu.ll = u;
|
||||
|
||||
bm = (sizeof (SItype) * 8) - b;
|
||||
if (bm <= 0)
|
||||
{
|
||||
w.s.high = 0;
|
||||
w.s.low = (USItype)uu.s.high >> -bm;
|
||||
}
|
||||
else
|
||||
{
|
||||
USItype carries = (USItype)uu.s.high << bm;
|
||||
w.s.high = (USItype)uu.s.high >> b;
|
||||
w.s.low = ((USItype)uu.s.low >> b) | carries;
|
||||
}
|
||||
|
||||
return w.ll;
|
||||
}
|
||||
|
||||
DItype
|
||||
__muldi3 (DItype u, DItype v)
|
||||
{
|
||||
DIunion w;
|
||||
DIunion uu, vv;
|
||||
|
||||
uu.ll = u,
|
||||
vv.ll = v;
|
||||
|
||||
w.ll = __umulsidi3 (uu.s.low, vv.s.low);
|
||||
w.s.high += ((USItype) uu.s.low * (USItype) vv.s.high
|
||||
+ (USItype) uu.s.high * (USItype) vv.s.low);
|
||||
|
||||
return w.ll;
|
||||
}
|
||||
|
||||
DItype
|
||||
__negdi2 (DItype u)
|
||||
{
|
||||
DIunion w;
|
||||
DIunion uu;
|
||||
|
||||
uu.ll = u;
|
||||
|
||||
w.s.low = -uu.s.low;
|
||||
w.s.high = -uu.s.high - ((USItype) w.s.low > 0);
|
||||
|
||||
return w.ll;
|
||||
}
|
||||
|
||||
/* From here on down, the routines use normal data types. */
|
||||
|
||||
#define SItype bogus_type
|
||||
#define USItype bogus_type
|
||||
#define DItype bogus_type
|
||||
#define UDItype bogus_type
|
||||
#define SFtype bogus_type
|
||||
#define DFtype bogus_type
|
||||
|
||||
#undef char
|
||||
#undef short
|
||||
#undef int
|
||||
#undef long
|
||||
#undef unsigned
|
||||
#undef float
|
||||
#undef double
|
152
src/libgcc/longlong.h
Executable file
152
src/libgcc/longlong.h
Executable file
@ -0,0 +1,152 @@
|
||||
/* clang-format off */
|
||||
/* longlong.h -- definitions for mixed size 32/64 bit arithmetic.
|
||||
Copyright (C) 1991, 92, 94, 95, 96, 1997, 1998 Free Software Foundation, Inc.
|
||||
|
||||
This definition file is free software; you can redistribute it
|
||||
and/or modify it under the terms of the GNU General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2, or (at your option) any later version.
|
||||
|
||||
This definition file is distributed in the hope that it will be
|
||||
useful, but WITHOUT ANY WARRANTY; without even the implied
|
||||
warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA. */
|
||||
|
||||
#define __BITS4 (SI_TYPE_SIZE / 4)
|
||||
#define __ll_B (1L << (SI_TYPE_SIZE / 2))
|
||||
#define __ll_lowpart(t) ((USItype) (t) % __ll_B)
|
||||
#define __ll_highpart(t) ((USItype) (t) / __ll_B)
|
||||
|
||||
/* Define auxiliary macros.
|
||||
|
||||
1) umul_ppmm(high_prod, low_prod, multipler, multiplicand)
|
||||
multiplies two USItype integers MULTIPLER and MULTIPLICAND,
|
||||
and generates a two-part USItype product in HIGH_PROD and
|
||||
LOW_PROD.
|
||||
|
||||
2) __umulsidi3(a,b) multiplies two USItype integers A and B,
|
||||
and returns a UDItype product. This is just a variant of umul_ppmm.
|
||||
|
||||
3) udiv_qrnnd(quotient, remainder, high_numerator, low_numerator,
|
||||
denominator) divides a two-word unsigned integer, composed by the
|
||||
integers HIGH_NUMERATOR and LOW_NUMERATOR, by DENOMINATOR and
|
||||
places the quotient in QUOTIENT and the remainder in REMAINDER.
|
||||
HIGH_NUMERATOR must be less than DENOMINATOR for correct operation.
|
||||
The most significant bit of DENOMINATOR must be 1, which requires
|
||||
normalization.
|
||||
|
||||
4) count_leading_zeros(count, x) counts the number of zero-bits from
|
||||
the msb to the first non-zero bit. This is the number of steps X
|
||||
needs to be shifted left to set the msb. Undefined for X == 0.
|
||||
|
||||
5) sub_ddmmss(high_difference, low_difference, high_minuend,
|
||||
low_minuend, high_subtrahend, low_subtrahend) subtracts two
|
||||
two-word unsigned integers, composed by HIGH_MINUEND_1 and
|
||||
LOW_MINUEND_1, and HIGH_SUBTRAHEND_2 and LOW_SUBTRAHEND_2
|
||||
respectively. The result is placed in HIGH_DIFFERENCE and
|
||||
LOW_DIFFERENCE. Overflow (i.e. carry out) is not stored anywhere,
|
||||
and is lost.
|
||||
|
||||
If any of these macros are left undefined for a particular CPU,
|
||||
C macros are used. */
|
||||
|
||||
#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
|
||||
do { \
|
||||
USItype __x; \
|
||||
__x = (al) - (bl); \
|
||||
(sh) = (ah) - (bh) - (__x > (al)); \
|
||||
(sl) = __x; \
|
||||
} while (0)
|
||||
|
||||
#define umul_ppmm(w1, w0, u, v) \
|
||||
do { \
|
||||
USItype __x0, __x1, __x2, __x3; \
|
||||
USItype __ul, __vl, __uh, __vh; \
|
||||
\
|
||||
__ul = __ll_lowpart (u); \
|
||||
__uh = __ll_highpart (u); \
|
||||
__vl = __ll_lowpart (v); \
|
||||
__vh = __ll_highpart (v); \
|
||||
\
|
||||
__x0 = (USItype) __ul * __vl; \
|
||||
__x1 = (USItype) __ul * __vh; \
|
||||
__x2 = (USItype) __uh * __vl; \
|
||||
__x3 = (USItype) __uh * __vh; \
|
||||
\
|
||||
__x1 += __ll_highpart (__x0);/* this can't give carry */ \
|
||||
__x1 += __x2; /* but this indeed can */ \
|
||||
if (__x1 < __x2) /* did we get it? */ \
|
||||
__x3 += __ll_B; /* yes, add it in the proper pos. */ \
|
||||
\
|
||||
(w1) = __x3 + __ll_highpart (__x1); \
|
||||
(w0) = __ll_lowpart (__x1) * __ll_B + __ll_lowpart (__x0); \
|
||||
} while (0)
|
||||
|
||||
#define __umulsidi3(u, v) \
|
||||
({DIunion __w; \
|
||||
umul_ppmm (__w.s.high, __w.s.low, u, v); \
|
||||
__w.ll; })
|
||||
|
||||
#define udiv_qrnnd(q, r, n1, n0, d) \
|
||||
do { \
|
||||
USItype __d1, __d0, __q1, __q0; \
|
||||
USItype __r1, __r0, __m; \
|
||||
__d1 = __ll_highpart (d); \
|
||||
__d0 = __ll_lowpart (d); \
|
||||
\
|
||||
__r1 = (n1) % __d1; \
|
||||
__q1 = (n1) / __d1; \
|
||||
__m = (USItype) __q1 * __d0; \
|
||||
__r1 = __r1 * __ll_B | __ll_highpart (n0); \
|
||||
if (__r1 < __m) \
|
||||
{ \
|
||||
__q1--, __r1 += (d); \
|
||||
if (__r1 >= (d)) /* i.e. we didn't get carry when adding to __r1 */\
|
||||
if (__r1 < __m) \
|
||||
__q1--, __r1 += (d); \
|
||||
} \
|
||||
__r1 -= __m; \
|
||||
\
|
||||
__r0 = __r1 % __d1; \
|
||||
__q0 = __r1 / __d1; \
|
||||
__m = (USItype) __q0 * __d0; \
|
||||
__r0 = __r0 * __ll_B | __ll_lowpart (n0); \
|
||||
if (__r0 < __m) \
|
||||
{ \
|
||||
__q0--, __r0 += (d); \
|
||||
if (__r0 >= (d)) \
|
||||
if (__r0 < __m) \
|
||||
__q0--, __r0 += (d); \
|
||||
} \
|
||||
__r0 -= __m; \
|
||||
\
|
||||
(q) = (USItype) __q1 * __ll_B | __q0; \
|
||||
(r) = __r0; \
|
||||
} while (0)
|
||||
|
||||
extern const UQItype __clz_tab[];
|
||||
#define count_leading_zeros(count, x) \
|
||||
do { \
|
||||
USItype __xr = (x); \
|
||||
USItype __a; \
|
||||
\
|
||||
if (SI_TYPE_SIZE <= 32) \
|
||||
{ \
|
||||
__a = __xr < ((USItype)1<<2*__BITS4) \
|
||||
? (__xr < ((USItype)1<<__BITS4) ? 0 : __BITS4) \
|
||||
: (__xr < ((USItype)1<<3*__BITS4) ? 2*__BITS4 : 3*__BITS4); \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
for (__a = SI_TYPE_SIZE - 8; __a > 0; __a -= 8) \
|
||||
if (((__xr >> __a) & 0xff) != 0) \
|
||||
break; \
|
||||
} \
|
||||
\
|
||||
(count) = SI_TYPE_SIZE - (__clz_tab[__xr >> __a] + __a); \
|
||||
} while (0)
|
Loading…
x
Reference in New Issue
Block a user