summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorDamien George <damien@micropython.org>2020-11-24 23:37:58 +1100
committerDamien George <damien@micropython.org>2021-05-20 23:43:25 +1000
commit5176a2d7325d941d8f2f41b31eab87b6e7a83f06 (patch)
tree2aac2de2815abd78bcd5e282576f8c62e489481a /tests
parentf49d47c167ce97b48ff3e9cbbc016b09664390f5 (diff)
py/emitnative: Fix x86-64 emitter to generate correct 8/16-bit stores.
Fixes issue #6643. Signed-off-by: Damien George <damien@micropython.org>
Diffstat (limited to 'tests')
-rw-r--r--tests/micropython/viper_misc2.py21
-rw-r--r--tests/micropython/viper_misc2.py.exp1
2 files changed, 22 insertions, 0 deletions
diff --git a/tests/micropython/viper_misc2.py b/tests/micropython/viper_misc2.py
new file mode 100644
index 000000000..8f0be487d
--- /dev/null
+++ b/tests/micropython/viper_misc2.py
@@ -0,0 +1,21 @@
+# Miscellaneous viper tests
+
+# Test correct use of registers in load and store
+@micropython.viper
+def expand(dest: ptr8, source: ptr8, length: int):
+ n = 0
+ for x in range(0, length, 2):
+ c = source[x]
+ d = source[x + 1]
+ dest[n] = (c & 0xE0) | ((c & 0x1C) >> 1)
+ n += 1
+ dest[n] = ((c & 3) << 6) | ((d & 0xE0) >> 4)
+ n += 1
+ dest[n] = ((d & 0x1C) << 3) | ((d & 3) << 2)
+ n += 1
+
+
+source = b"\xaa\xaa\xff\xff"
+dest = bytearray(len(source) // 2 * 3)
+expand(dest, source, len(source))
+print(dest)
diff --git a/tests/micropython/viper_misc2.py.exp b/tests/micropython/viper_misc2.py.exp
new file mode 100644
index 000000000..eff2f5e41
--- /dev/null
+++ b/tests/micropython/viper_misc2.py.exp
@@ -0,0 +1 @@
+bytearray(b'\xa4\x8aH\xee\xce\xec')