1 // -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
2 // ---------------------------------------------------------------------------
4 // Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
5 // ---------------------------------------------------------------------------
6 // SquirrelJME is under the GNU General Public License v3+, or later.
7 // See license.mkd for licensing and copyright information.
8 // ---------------------------------------------------------------------------
10 package cc
.squirreljme
.jvm
;
12 import cc
.squirreljme
.runtime
.cldc
.annotation
.Exported
;
13 import cc
.squirreljme
.runtime
.cldc
.debug
.Debugging
;
16 * Software integer operations.
21 @SuppressWarnings("MagicNumber")
22 public final class SoftInteger
41 public static double toDouble(int __a
)
43 Assembly
.breakpoint();
44 throw Debugging
.todo();
55 public static float toFloat(int __a
)
57 boolean sign
= (__a
< 0);
59 // if ( ! (a & 0x7FFFFFFF) ) {
60 if ((__a
& 0x7FFF_FFFF
) == 0)
62 // uZ.ui = sign ? packToF32UI( 1, 0x9E, 0 ) : 0;
63 return Float
.intBitsToFloat((sign ?
64 SoftFloat
.__packToF32UI(true, 0x9E, 0) :
68 int absA
= sign ?
-__a
: __a
;
70 // return softfloat_normRoundPackToF32( sign, 0x9C, absA );
71 return Float
.intBitsToFloat(
72 SoftFloat
.__normRoundPackToF32(sign
, 0x9C, absA
));
83 public static long toLong(int __a
)
85 // If the integer has the sign bit, then it will be sign extended
86 // meaning all the upper bits get set
87 if ((__a
& 0x80000000) != 0)
88 return Assembly
.longPack(__a
, 0xFFFFFFFF);
90 // Otherwise, the top is just zero
92 return Assembly
.longPack(__a
, 0);