From: Luke Kenneth Casson Leighton Date: Mon, 30 Aug 2021 12:50:21 +0000 (+0100) Subject: fix RANGE function, reverse direction needed X-Git-Tag: xlen-bcd~96 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=c7258236ed3bbd872c18064b7ae5cd56a64ffece;p=openpower-isa.git fix RANGE function, reverse direction needed --- diff --git a/src/openpower/decoder/helpers.py b/src/openpower/decoder/helpers.py index 09f2324a..b1d9eb4c 100644 --- a/src/openpower/decoder/helpers.py +++ b/src/openpower/decoder/helpers.py @@ -19,17 +19,17 @@ MODS = trunc_rems """ Links: * https://bugs.libre-soc.org/show_bug.cgi?id=324 - add trunc_div and trunc_rem +* https://bugs.libre-soc.org/show_bug.cgi?id=671#c38 - RANGE (and bugfixes) """ def RANGE(start, end): if start > end: + # reverse direction # auto-subtract-one (sigh) due to python range - end -= 1 - else: - # auto-add-one (sigh) due to python range - end += 1 - return range(start, end) + return range(start, end-1, -1) + # auto-add-one (sigh) due to python range + return range(start, end+1) def exts(value, bits):