summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog33
-rw-r--r--debugger/mcs51/sdcdb.c6
-rw-r--r--debugger/mcs51/sdcdb.h8
-rw-r--r--debugger/mcs51/symtab.c2
-rw-r--r--device/include/float.h4
-rw-r--r--device/lib/_fs2slonglong.c46
-rw-r--r--device/lib/_fs2ulong.c1
-rw-r--r--device/lib/_fs2ulonglong.c84
-rw-r--r--device/lib/incl.mk2
-rw-r--r--device/lib/z80/Makefile.in2
-rw-r--r--device/lib/z80/__mulsint2slong.s23
-rw-r--r--device/lib/z80/__muluint2slong.s52
-rw-r--r--src/SDCCopt.c20
-rw-r--r--src/pdk/gen.c14
-rw-r--r--src/z80/gen.c25
-rw-r--r--src/z80/peep.c4
-rw-r--r--support/regression/tests/bitintfromfloat.c.in35
-rw-r--r--support/regression/tests/bitinttofloat.c.in (renamed from support/regression/tests/bitintfloat.c.in)5
-rw-r--r--support/regression/tests/coremark.c.in2
-rw-r--r--support/regression/tests/muldiv.c.in7
20 files changed, 320 insertions, 55 deletions
diff --git a/ChangeLog b/ChangeLog
index d17c89c19..755bcdb34 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,8 +1,37 @@
+2025-08-08 Philipp Klaus Krause <philipp@colecovision.eu>
+
+ * device/include/float.h,
+ device/lib/incl.mk,
+ support/regression/tests/bitintfromfloat.c.in,
+ device/lib/_fs2slonglong.c,
+ device/lib/_fs2ulonglong.c:
+ Fix third part of bug #3719.
+ * debugger/mcs51/sdcdb.h,
+ debugger/mcs51/sdcdb.c,
+ debugger/mcs51/symtab.c:
+ Fix bug #3823.
+ * src/z80/gen.c:
+ Fix bug #3854.
+
+2025-08-08 Philipp Klaus Krause <philipp@colecovision.eu>
+
+ * src/z80/peep.c,
+ device/lib/z80/Makefile.in,
+ device/lib/z80/__mulsint2slong.s,
+ device/lib/z80/__muluint2slong.s,
+ support/regression/tests/coremark.c.in,
+ support/regression/tests/muldiv.c.in:
+ Fix bug #3852.
+ * src/pdk/gen.c,
+ support/regression/tests/bitintfromfloat.c.in:
+ Fix a pdk codegen issue for casts from int to _BitInt of width > 8, < 16 bits if both operands' least-significant byte is allocated to register a, part of bug #3719.
+
2025-08-07 Philipp Klaus Krause <philipp@colecovision.eu>
* src/SDCCopt.c,
- support/regression/tests/bitintfloat.c.in:
- Fix bug #3718.
+ support/regression/tests/bitinttofloat.c.in,
+ support/regression/tests/bitintfromfloat.c.in:
+ Fix bug #3718, partially fix bug #3719.
2025-08-07 Philipp Klaus Krause <philipp@colecovision.eu>
diff --git a/debugger/mcs51/sdcdb.c b/debugger/mcs51/sdcdb.c
index 4eeaf41d4..e207404ac 100644
--- a/debugger/mcs51/sdcdb.c
+++ b/debugger/mcs51/sdcdb.c
@@ -62,7 +62,7 @@ structdef **structs = NULL; /* all structures */
int nLinkrecs = 0;
linkrec **linkrecs = NULL; /* all linkage editor records */
context *currCtxt = NULL;
-short fullname = 0;
+bool fullname = 0;
short showfull = 0;
char userinterrupt = 0;
char nointerrupt = 0;
@@ -573,7 +573,7 @@ static void loadModules (void)
{
/* for module records do */
case MOD_REC:
- currMod = parseModule(loop->line, TRUE);
+ currMod = parseModule(loop->line, true);
currModName = currMod->name ;
/* search the c source file and load it into buffer */
@@ -1906,7 +1906,7 @@ static void parseCmdLine (int argc, char **argv)
if (strcmp(argv[i], "-fullname") == 0)
{
- fullname = TRUE;
+ fullname = true;
continue;
}
diff --git a/debugger/mcs51/sdcdb.h b/debugger/mcs51/sdcdb.h
index 91a42ba64..8d331c471 100644
--- a/debugger/mcs51/sdcdb.h
+++ b/debugger/mcs51/sdcdb.h
@@ -42,6 +42,7 @@ extern int sdcdbDebug;
#define Dprintf(f, fs) { }
#endif
+#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -57,11 +58,6 @@ extern int sdcdbDebug;
#include "src/SDCCset.h"
#include "src/SDCChasht.h"
-#define TRUE 1
-#define FALSE !TRUE
-
-typedef short bool;
-
#ifndef max
#define max(a,b) (a > b ? a : b)
#endif
@@ -279,7 +275,7 @@ char *alloccpy(char *,int );
char *gc_strdup(const char *s);
srcLine **loadFile (char *name, int *nlines);
-extern short fullname;
+extern bool fullname;
extern int srcMode;
extern char contsim;
char *searchDirsFname (char *);
diff --git a/debugger/mcs51/symtab.c b/debugger/mcs51/symtab.c
index d6eb3c44e..c4cd7f60f 100644
--- a/debugger/mcs51/symtab.c
+++ b/debugger/mcs51/symtab.c
@@ -836,7 +836,7 @@ static void lnkCSrc (char *s)
mod = NULL;
if (!applyToSet(modules,moduleWithCName,mname,&mod))
{
- mod = parseModule(mname, FALSE);
+ mod = parseModule(mname, false);
mod->c_name = alloccpy(mname,strlen(mname));
mod->cfullname=searchDirsFname(mod->c_name);
mod->cLines = loadFile(mod->c_name,&mod->ncLines);
diff --git a/device/include/float.h b/device/include/float.h
index 56122a95f..c5ec73ba8 100644
--- a/device/include/float.h
+++ b/device/include/float.h
@@ -100,6 +100,10 @@ unsigned int __fs2uint (float) __SDCC_FLOAT_NONBANKED;
signed int __fs2sint (float) __SDCC_FLOAT_NONBANKED;
unsigned long __fs2ulong (float) __SDCC_FLOAT_NONBANKED;
signed long __fs2slong (float) __SDCC_FLOAT_NONBANKED;
+#ifdef __SDCC_LONGLONG
+unsigned long long __fs2ulonglong (float) __SDCC_FLOAT_NONBANKED;
+signed long long __fs2longlong (float) __SDCC_FLOAT_NONBANKED;
+#endif
float __fsadd (float, float) __SDCC_FLOAT_NONBANKED;
float __fssub (float, float) __SDCC_FLOAT_NONBANKED;
diff --git a/device/lib/_fs2slonglong.c b/device/lib/_fs2slonglong.c
new file mode 100644
index 000000000..8e45209b1
--- /dev/null
+++ b/device/lib/_fs2slonglong.c
@@ -0,0 +1,46 @@
+/*-------------------------------------------------------------------------
+ _fs2slong.c - Floating point library in optimized assembly for 8051
+
+ Copyright (c) 2004, Paul Stoffregen, paul@pjrc.com
+
+ This library 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 library 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 library; see the file COPYING. If not, write to the
+ Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
+ MA 02110-1301, USA.
+
+ As a special exception, if you link this library with other files,
+ some of which are compiled with SDCC, 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.
+-------------------------------------------------------------------------*/
+
+
+#define __SDCC_FLOAT_LIB
+#include <float.h>
+
+/* convert float to signed long long */
+signed long long __fs2slonglong (float f) __SDCC_FLOAT_NONBANKED
+{
+
+ if (!f)
+ return 0;
+
+ if (f<0) {
+ return -__fs2ulonglong(-f);
+ } else {
+ return __fs2ulonglong(f);
+ }
+}
+
diff --git a/device/lib/_fs2ulong.c b/device/lib/_fs2ulong.c
index fe812a00a..4bdc6ab6b 100644
--- a/device/lib/_fs2ulong.c
+++ b/device/lib/_fs2ulong.c
@@ -126,3 +126,4 @@ unsigned long __fs2ulong (float a1) __SDCC_FLOAT_NONBANKED
}
#endif
+
diff --git a/device/lib/_fs2ulonglong.c b/device/lib/_fs2ulonglong.c
new file mode 100644
index 000000000..5840f73f5
--- /dev/null
+++ b/device/lib/_fs2ulonglong.c
@@ -0,0 +1,84 @@
+/*-------------------------------------------------------------------------
+ _fs2ulong.c - Floating point library in optimized assembly for 8051
+
+ Copyright (c) 2004, Paul Stoffregen, paul@pjrc.com
+
+ This library 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 library 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 library; see the file COPYING. If not, write to the
+ Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
+ MA 02110-1301, USA.
+
+ As a special exception, if you link this library with other files,
+ some of which are compiled with SDCC, 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.
+-------------------------------------------------------------------------*/
+
+
+#define __SDCC_FLOAT_LIB
+#include <float.h>
+
+/*
+** libgcc support for software floating point.
+** Copyright (C) 1991 by Pipeline Associates, Inc. All rights reserved.
+** Permission is granted to do *anything* you want with this file,
+** commercial or otherwise, provided this message remains intact. So there!
+** I would appreciate receiving any updates/patches/changes that anyone
+** makes, and am willing to be the repository for said changes (am I
+** making a big mistake?).
+**
+** Pat Wood
+** Pipeline Associates, Inc.
+** pipeline!phw@motown.com or
+** sun!pipeline!phw or
+** uunet!motown!pipeline!phw
+*/
+
+/* (c)2000/2001: hacked a little by johan.knol@iduna.nl for sdcc */
+/* (c)2022: fix sdcc bug #3276 -- Benedikt Freisen */
+
+
+union float_long
+{
+ float f;
+ long l;
+};
+
+/* convert float to unsigned long long */
+unsigned long long __fs2ulonglong (float a1) __SDCC_FLOAT_NONBANKED
+{
+ volatile union float_long fl1;
+ int exp;
+ unsigned long long l;
+
+ fl1.f = a1;
+
+ if (!fl1.l || SIGN(fl1.l))
+ return (0);
+
+ exp = EXP (fl1.l) - EXCESS - 24;
+ l = MANT (fl1.l);
+
+ if (exp > 8)
+ return 0xfffffffful;
+
+ if (exp < 0)
+ l >>= -exp;
+ else
+ l <<= exp;
+
+ return l;
+}
+
diff --git a/device/lib/incl.mk b/device/lib/incl.mk
index e009534e9..37566204e 100644
--- a/device/lib/incl.mk
+++ b/device/lib/incl.mk
@@ -13,9 +13,11 @@ COMMON_FLOAT = \
_fs2schar.c \
_fs2sint.c \
_fs2slong.c \
+ _fs2slonglong.c \
_fs2uchar.c \
_fs2uint.c \
_fs2ulong.c \
+ _fs2ulonglong.c \
_fsadd.c \
_fsdiv.c \
_fsmul.c \
diff --git a/device/lib/z80/Makefile.in b/device/lib/z80/Makefile.in
index 3bad46ceb..a146dc8e0 100644
--- a/device/lib/z80/Makefile.in
+++ b/device/lib/z80/Makefile.in
@@ -53,7 +53,7 @@ Z8OBJECTS = $(patsubst %.c,%.rel,$(Z80_FLOAT) $(Z80_INT) $(Z80_LONG) $(Z80_LONGL
OBJ = divunsigned.rel divsigned.rel divmixed.rel modunsigned.rel modsigned.rel modmixed.rel mul.rel mulchar.rel \
heap.rel memmove.rel strcpy.rel strlen.rel abs.rel __sdcc_call_hl.rel __sdcc_call_iy.rel crtenter.rel \
setjmp.rel atomic_flag_test_and_set.rel memcpy.rel __uitobcd.rel __ultobcd.rel __itoa.rel __ltoa.rel \
- __strreverse.rel __sdcc_bcall.rel __sdcc_critical.rel __mulsint2slong.rel
+ __strreverse.rel __sdcc_bcall.rel __sdcc_critical.rel __muluint2slong.rel __mulsint2slong.rel
LIB = z80.lib
AS = $(SAS)
diff --git a/device/lib/z80/__mulsint2slong.s b/device/lib/z80/__mulsint2slong.s
index 140facedd..2d4253651 100644
--- a/device/lib/z80/__mulsint2slong.s
+++ b/device/lib/z80/__mulsint2slong.s
@@ -32,15 +32,13 @@
.globl ___muluint2ulong
.globl ___mulsint2slong
-; uint32_t _u_16_16_mul(uint16_t l, uint16_t r);
-
.area _CODE
___mulsint2slong:
; Use lowest bit of c to remember if result needs to be negated. Use b to cache #0.
ld bc, #0
- bit #7, l
+ bit #7, h
jr z, hl_nonneg
ld a, b
sub a, l
@@ -51,7 +49,7 @@ ___mulsint2slong:
inc c
hl_nonneg:
- bit #7, e
+ bit #7, d
jr z, de_nonneg
ld a, b
sub a, e
@@ -84,20 +82,3 @@ de_nonneg:
ld h, a
ret
-; 16x16->32 multiplication
-___muluint2ulong:
- ld iy, #0
- ld b, #16
-loop:
- add iy, iy
- adc hl, hl
- jr NC, skip
- add iy, de
- jr NC, skip
- inc hl
-skip:
- djnz loop
- push iy
- pop de
- ret
-
diff --git a/device/lib/z80/__muluint2slong.s b/device/lib/z80/__muluint2slong.s
new file mode 100644
index 000000000..6eabef253
--- /dev/null
+++ b/device/lib/z80/__muluint2slong.s
@@ -0,0 +1,52 @@
+;--------------------------------------------------------------------------
+; __muluint2slong.s
+;
+; Copyright (c) 2021, Philipp Klaus Krause
+;
+; This library 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 library 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 library; see the file COPYING. If not, write to the
+; Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
+; MA 02110-1301, USA.
+;
+; As a special exception, if you link this library with other files,
+; some of which are compiled with SDCC, 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.
+;--------------------------------------------------------------------------
+
+ .module __muluint2slong
+ .optsdcc -mz80 sdcccall(1)
+
+.globl ___muluint2ulong
+
+.area _CODE
+
+; 16x16->32 multiplication
+___muluint2ulong:
+ ld iy, #0
+ ld b, #16
+loop:
+ add iy, iy
+ adc hl, hl
+ jr NC, skip
+ add iy, de
+ jr NC, skip
+ inc hl
+skip:
+ djnz loop
+ push iy
+ pop de
+ ret
+
diff --git a/src/SDCCopt.c b/src/SDCCopt.c
index f82cabf85..3f8c1276f 100644
--- a/src/SDCCopt.c
+++ b/src/SDCCopt.c
@@ -563,13 +563,29 @@ cnvFromFloatCast (iCode * ic, eBBlock * ebp)
{
iCode *ip, *newic;
symbol *func = NULL;
- sym_link *type = copyLinkChain (operandType (IC_LEFT (ic)));
- SPEC_SHORT (type) = 0;
char *filename = ic->filename;
int lineno = ic->lineno;
int bwd, su;
int bytesPushed=0;
+ // Use basic type cast function for _BitInt. Choose something big enough to represent all values of the _BitInt, don't worry about what happens if that is not enough for the float value, or some of the basic type values won't fit into the BitInt - all that is UB anyway.
+ if (IS_BITINT (operandType (ic->left)))
+ {
+ sym_link *newtype;
+ if (SPEC_BITINTWIDTH (operandType (ic->left)) <= 16)
+ newtype = newIntLink();
+ else if (SPEC_BITINTWIDTH (operandType (ic->left)) <= 32)
+ newtype = newLongLink();
+ else // Fall back to 64 bit.
+ newtype = newLongLongLink();
+ SPEC_USIGN (newtype) = SPEC_USIGN (operandType (ic->left));
+ ic->left = operandFromLink (newtype);
+ appendCast (ic, newtype, ebp);
+ }
+
+ sym_link *type = copyLinkChain (operandType (ic->left));
+ SPEC_SHORT (type) = 0;
+
ip = ic->next;
/* remove it from the iCode */
unsetDefsAndUses (ic);
diff --git a/src/pdk/gen.c b/src/pdk/gen.c
index cebf72c4e..e0934fe37 100644
--- a/src/pdk/gen.c
+++ b/src/pdk/gen.c
@@ -5327,6 +5327,8 @@ genCast (const iCode *ic)
// Cast to _BitInt can require mask of top byte.
if (IS_BITINT (resulttype) && (SPEC_BITINTWIDTH (resulttype) % 8) && bitsForType (resulttype) < bitsForType (righttype))
{
+ bool swapped_a = false;
+
aopOp (right, ic);
aopOp (result, ic);
@@ -5336,6 +5338,12 @@ genCast (const iCode *ic)
pushed_a = true;
}
genMove (result->aop, right->aop, true, regDead (P_IDX, ic));
+ if (result->aop->size == 2 && aopInReg (result->aop, 0, A_IDX))
+ {
+ emit2 ("xch", "a, p");
+ cost (1, 1);
+ swapped_a = true;
+ }
cheapMove (ASMOP_A, 0, result->aop, result->aop->size - 1, true, false, true);
emit2 ("and", "a, #0x%02x", topbytemask);
cost (2, 1);
@@ -5354,7 +5362,11 @@ genCast (const iCode *ic)
emitLabel (tlbl);
}
cheapMove (result->aop, result->aop->size - 1, ASMOP_A, 0, true, false, true);
-
+ if (swapped_a)
+ {
+ emit2 ("xch", "a, p");
+ cost (1, 1);
+ }
goto release;
}
diff --git a/src/z80/gen.c b/src/z80/gen.c
index 10d69dfca..188357e2c 100644
--- a/src/z80/gen.c
+++ b/src/z80/gen.c
@@ -8479,12 +8479,13 @@ genPlus (iCode * ic)
i += 2;
}
else if (!maskedword && (!premoved || i) && !started && i == size - 2 && aopInReg (ic->result->aop, i, HL_IDX) &&
- aopInReg (rightop, i, C_IDX) && isRegDead (B_IDX, ic))
+ aopInReg (rightop, i, C_IDX) && isRegDead (B_IDX, ic) && leftop->regs[B_IDX] <= i + 1 &&
+ !((aopInReg (rightop, i + 1, H_IDX) || aopInReg (rightop, i + 1, L_IDX)) && leftop->regs[B_IDX] >= i))
{
if (aopInReg (rightop, i + 1, H_IDX) || aopInReg (rightop, i + 1, L_IDX))
{
- cheapMove (ASMOP_B, 0, ic->right->aop, i + 1, true);
- genMove_o (ASMOP_HL, 0, ic->left->aop, i, 2, false, true, de_dead, false, !started);
+ cheapMove (ASMOP_B, 0, rightop, i + 1, true);
+ genMove_o (ASMOP_HL, 0, leftop, i, 2, false, true, de_dead, false, !started);
}
else
{
@@ -8497,12 +8498,13 @@ genPlus (iCode * ic)
i += 2;
}
else if (!maskedword && (!premoved || i) && !started && i == size - 2 && aopInReg (IC_RESULT (ic)->aop, i, HL_IDX) &&
- aopInReg (rightop, i, E_IDX) && isRegDead (D_IDX, ic))
+ aopInReg (rightop, i, E_IDX) && isRegDead (D_IDX, ic) && leftop->regs[D_IDX] <= i + 1 &&
+ !((aopInReg (rightop, i + 1, H_IDX) || aopInReg (rightop, i + 1, L_IDX)) && leftop->regs[D_IDX] >= i))
{
if (aopInReg (rightop, i + 1, H_IDX) || aopInReg (rightop, i + 1, L_IDX))
{
- cheapMove (ASMOP_D, 0, IC_RIGHT (ic)->aop, i + 1, true);
- genMove_o (ASMOP_HL, 0, ic->left->aop, i, 2, false, true, de_dead, false, true);
+ cheapMove (ASMOP_D, 0, rightop, i + 1, true);
+ genMove_o (ASMOP_HL, 0, leftop, i, 2, false, true, de_dead, false, true);
}
else
{
@@ -8515,17 +8517,18 @@ genPlus (iCode * ic)
i += 2;
}
else if (!maskedword && (!premoved || i) && !started && i == size - 2 && aopInReg (IC_RESULT (ic)->aop, i, HL_IDX) &&
- aopInReg (leftop, i, E_IDX) && isRegDead (D_IDX, ic))
+ aopInReg (leftop, i, E_IDX) && isRegDead (D_IDX, ic) && rightop->regs[D_IDX] <= i + 1 &&
+ !((aopInReg (leftop, i + 1, H_IDX) || aopInReg (leftop, i + 1, L_IDX)) && rightop->regs[D_IDX] >= i))
{
if (aopInReg (leftop, i + 1, H_IDX) || aopInReg (leftop, i + 1, L_IDX))
{
- cheapMove (ASMOP_D, 0, IC_LEFT (ic)->aop, i + 1, true);
- fetchPairLong (PAIR_HL, IC_RIGHT (ic)->aop, 0, i);
+ cheapMove (ASMOP_D, 0, leftop, i + 1, true);
+ fetchPairLong (PAIR_HL, rightop, 0, i);
}
else
{
- fetchPairLong (PAIR_HL, IC_RIGHT (ic)->aop, 0, i);
- cheapMove (ASMOP_D, 0, IC_LEFT (ic)->aop, i + 1, true);
+ fetchPairLong (PAIR_HL, rightop, 0, i);
+ cheapMove (ASMOP_D, 0, leftop, i + 1, true);
}
emit3w (A_ADD, ASMOP_HL, ASMOP_DE);
started = true;
diff --git a/src/z80/peep.c b/src/z80/peep.c
index 611a9faf7..ce284fd40 100644
--- a/src/z80/peep.c
+++ b/src/z80/peep.c
@@ -1575,8 +1575,10 @@ int z80instructionSize(lineNode *pl)
}
/* 16 bit add / subtract / and / or */
- if(IS_Z80N && ISINST(pl->line, "add") && (!STRNCASECMP(op1start, "bc", 2) || !STRNCASECMP(op1start, "de", 2) || !STRNCASECMP(op1start, "hl", 2)))
+ if(IS_Z80N && ISINST(pl->line, "add") && (!STRNCASECMP(op1start, "bc", 2) || !STRNCASECMP(op1start, "de", 2) || !STRNCASECMP(op1start, "hl", 2)) && op2start[0] == '#')
return(4);
+ else if(IS_Z80N && ISINST(pl->line, "add") && (!STRNCASECMP(op1start, "bc", 2) || !STRNCASECMP(op1start, "de", 2) || !STRNCASECMP(op1start, "hl", 2)) && !STRNCASECMP(op1start, "a", 1))
+ return(2);
if((ISINST(pl->line, "add") || ISINST(pl->line, "adc") || ISINST(pl->line, "sbc") || IS_RAB && (ISINST(pl->line, "and") || ISINST(pl->line, "or"))) &&
!STRNCASECMP(op1start, "hl", 2))
{
diff --git a/support/regression/tests/bitintfromfloat.c.in b/support/regression/tests/bitintfromfloat.c.in
new file mode 100644
index 000000000..bf7ef9530
--- /dev/null
+++ b/support/regression/tests/bitintfromfloat.c.in
@@ -0,0 +1,35 @@
+/** casts between bit-precise integers and float
+
+ width: 2, 4, 6, 7, 8, 9, 15, 16, 17, 24, 32, 33, 40, 48, 63, 64, 65
+ sign: unsigned, signed
+*/
+
+#include <testfwk.h>
+
+#include <float.h>
+
+// clang 11 supports bit-precise types, but deviates a bit from C23.
+#if __clang_major__ == 11
+#define __SDCC_BITINT_MAXWIDTH 128
+#define _BitInt _ExtInt
+#endif
+
+#if __SDCC_BITINT_MAXWIDTH >= {width} && (32 >= {width} || !defined(__SDCC_pdk14)) // Lack of memory on pdk14 for wider types. Maybe some future optimization will help here.
+typedef {sign} _BitInt({width}) bitinttype;
+
+bitinttype from_float(float f)
+{
+ return(f);
+}
+#endif
+
+void testCast (void)
+{
+#if __SDCC_BITINT_MAXWIDTH >= {width} && (32 >= {width} || !defined(__SDCC_pdk14)) // Lack of memory on pdk14 for wider types. Maybe some future optimization will help here.
+ float f;
+
+ f = 1;
+ ASSERT (from_float (f) == (bitinttype)f);
+#endif
+}
+
diff --git a/support/regression/tests/bitintfloat.c.in b/support/regression/tests/bitinttofloat.c.in
index 77d5ae986..1645c5b3f 100644
--- a/support/regression/tests/bitintfloat.c.in
+++ b/support/regression/tests/bitinttofloat.c.in
@@ -22,11 +22,6 @@ float to_float(bitinttype b)
{
return(b);
}
-
-/*bitinttype from_float(float f)
-{
- return(f);
-}*/
#endif
void testCast (void)
diff --git a/support/regression/tests/coremark.c.in b/support/regression/tests/coremark.c.in
index 35eaa4125..4944f9ad5 100644
--- a/support/regression/tests/coremark.c.in
+++ b/support/regression/tests/coremark.c.in
@@ -21,7 +21,7 @@
#define LACK_OF_MEMORY
#endif
-#if !defined(LACK_OF_MEMORY) && !defined(__SDCC_z80) && !defined(__SDCC_z180) && !defined(__SDCC_ds390) /* z80, z180, ds390: fails, possibly a bug in codegen */
+#if !defined(LACK_OF_MEMORY) && !defined(__SDCC_ds390) /* ds390: fails, possibly a bug in codegen */
// coremark.h content below.
diff --git a/support/regression/tests/muldiv.c.in b/support/regression/tests/muldiv.c.in
index 1df52656f..bd7dd71c9 100644
--- a/support/regression/tests/muldiv.c.in
+++ b/support/regression/tests/muldiv.c.in
@@ -109,6 +109,12 @@ test16to32(void)
{attr} {storage} int i, j;
{attr} {storage} unsigned int ui, uj;
+ i = 123;
+ j = 0xaa;
+ ASSERT((long)i * (long)j == 123l * (long)0xaa);
+ i = -i;
+ ASSERT((long)i * (long)j == -123l * (long)0xaa);
+
i = 42;
j = 42;
ASSERT((long)i * (long)j == 42l * 42l);
@@ -164,3 +170,4 @@ testMod(void)
ASSERT(i%4 == -1);
#endif
}
+