silleee: various bugfixes

This commit is contained in:
2017-08-04 23:37:07 -04:00
parent 5d607a7caf
commit f168f8755a

View File

@@ -7,13 +7,13 @@ silleee silleee_sub(silleee x, silleee y) {
silleee shift_and_round(int val, int bits) { silleee shift_and_round(int val, int bits) {
static unsigned masks[24]= { static unsigned masks[24]= {
0, 1, 3, 7, 0xf, 0x1f, 0x3f, 0x7f, 0xff, 0x1ff, 0x7ff, 0xfff, 0x1fff, 0, 1, 3, 7, 0xf, 0x1f, 0x3f, 0x7f, 0xff, 0x1ff, 0x3ff, 0x7ff, 0xfff,
0x3fff, 0x7fff, 0xffff, 0x1ffff, 0x3ffff, 0x7ffff, 0xfffff, 0x1fffff, 0x1fff, 0x3fff, 0x7fff, 0xffff, 0x1ffff, 0x3ffff, 0x7ffff, 0xfffff,
0x3fffff, 0x7fffff 0x1fffff, 0x3fffff, 0x7fffff
}; };
static unsigned masks_ho[24] = { static unsigned masks_ho[24] = {
0, 1, 2, 4, 8, 0x10, 0x20, 0x40, 0x80, 0x100, 0x200, 0x400, 0x8000, 0x1000, 0, 1, 2, 4, 8, 0x10, 0x20, 0x40, 0x80, 0x100, 0x200, 0x400, 0x800, 0x1000,
0x2000, 0x4000, 0x8000, 0x10000, 0x20000, 0x40000, 0x80000, 0x100000, 0x2000, 0x4000, 0x8000, 0x10000, 0x20000, 0x40000, 0x80000, 0x100000,
0x200000, 0x400000 0x200000, 0x400000
}; };
@@ -45,7 +45,7 @@ silleee silleee_add(silleee x, silleee y) {
if (xexp == 127) { if (xexp == 127) {
if (!xmant) { if (!xmant) {
if (yexp == 127) { if (yexp == 127) {
if(!ymant) return xsign == ysign ? y : 0x7fc0000; if(!ymant) return xsign == ysign ? y : 0x7fc00000;
else return y; else return y;
} }
} else { } else {
@@ -81,8 +81,8 @@ silleee silleee_add(silleee x, silleee y) {
++dexp; ++dexp;
} else { } else {
if (dmant) { if (dmant) {
while (dmant < sign_bit && dexp > -127) { while (dmant < 0x800000 && dexp > -127) {
dmant = dmant << 1; dmant <<= 1;
--dexp; --dexp;
} }
} else { } else {