From f7ef27195f8c9dc35e5e210a333b74fcfae5ad71 Mon Sep 17 00:00:00 2001 From: Cyrille Bagard Date: Tue, 2 Dec 2014 22:02:34 +0000 Subject: Fixed sign extensions when building 32-bit mask code from bit field. git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@432 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a --- ChangeLog | 5 +++++ tools/d2c/bits.c | 24 +++++++++++++++++++++++- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 7bd7182..e5c5b1e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 14-12-02 Cyrille Bagard + * tools/d2c/bits.c: + Fix sign extensions when building 32-bit mask code from bit field. + +14-12-02 Cyrille Bagard + * src/arch/arm/v7/opdefs/Makefile.am: Distinguish Thumb 16 and Thumb 32. Add 'mov_A88102.d' to ARMV7_DEFS. diff --git a/tools/d2c/bits.c b/tools/d2c/bits.c index 32c3fd9..4169acf 100644 --- a/tools/d2c/bits.c +++ b/tools/d2c/bits.c @@ -324,7 +324,29 @@ bool declare_used_bits_fields(const coding_bits *bits, int fd, unsigned int wide bool check_bits_correctness(const coding_bits *bits, int fd) { - dprintf(fd, "\t\tif ((raw & 0x%" PRIx64 ") != 0x%" PRIx64 ") return NULL;\n", bits->mask, bits->bits); + switch (bits->curpos) + { + case 8: + dprintf(fd, "\t\tif ((raw & 0x%" PRIx8 ") != 0x%" PRIx8 ") return NULL;\n", + (uint8_t)bits->mask, (uint8_t)bits->bits); + break; + + case 16: + dprintf(fd, "\t\tif ((raw & 0x%" PRIx16 ") != 0x%" PRIx16 ") return NULL;\n", + (uint16_t)bits->mask, (uint16_t)bits->bits); + break; + + case 32: + dprintf(fd, "\t\tif ((raw & 0x%" PRIx32 ") != 0x%" PRIx32 ") return NULL;\n", + (uint32_t)bits->mask, (uint32_t)bits->bits); + break; + + case 64: + dprintf(fd, "\t\tif ((raw & 0x%" PRIx64 ") != 0x%" PRIx64 ") return NULL;\n", + bits->mask, bits->bits); + break; + + } return true; -- cgit v0.11.2-87-g4458