From c7258236ed3bbd872c18064b7ae5cd56a64ffece Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Mon, 30 Aug 2021 13:50:21 +0100 Subject: [PATCH] fix RANGE function, reverse direction needed --- src/openpower/decoder/helpers.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) 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): -- 2.30.2