aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authors-ol <s+removethis@s-ol.nu>2021-06-08 15:46:37 +0000
committers-ol <s+removethis@s-ol.nu>2021-06-08 15:46:37 +0000
commitc2be2195f0fb036a39f8c8842350694309c65922 (patch)
tree5a7ba49d2d81f70baada51426ebfe75af4d5644f
parentfix jalr immediate slice, update example stage results (diff)
downloadsubv-c2be2195f0fb036a39f8c8842350694309c65922.tar.gz
subv-c2be2195f0fb036a39f8c8842350694309c65922.zip
new test case for survey.py
-rwxr-xr-xsurvey.py42
1 files changed, 38 insertions, 4 deletions
diff --git a/survey.py b/survey.py
index a0246c9..37f9759 100755
--- a/survey.py
+++ b/survey.py
@@ -54,13 +54,47 @@ Resolves label references and substitutes them with literal values.
23/7 00/5 02/3 05/5 06/5 00/7
# jump back up to the top
6f/7 00/5 ff/8 1/1 3e6/10 1/1
+
+>>> # doctest: +REPORT_NDIFF
+... print(subv.join_all(survey(StringIO('''
+... == code 0x80000000
+... # repeatedly print "Hi\\\\n"
+... main:
+... # load 0x10010000 (UART0) into t0
+... 37/7 05/5 10010/20
+... # store 0x48 (H) in UART0+0
+... 13/7 06/5 0/3 00/5 048/12
+... 23/7 00/5 2/3 05/5 06/5 00/7
+... # store 0x69 (i) in UART0+0
+... 13/7 06/5 0/3 00/5 069/12
+... 23/7 00/5 2/3 05/5 06/5 00/7
+... # store 0x0a (\\\\n) in UART0+0
+... 13/7 06/5 0/3 00/5 00a/12
+... 23/7 00/5 2/3 05/5 06/5 00/7
+... # jump back up to the top
+... 17/7 07/5 main/off32/[31:12]
+... 67/7 00/5 0/3 07/5 main+4/off32/[11:0]
+... '''[1:-1]))))
+== code 0x80000000
+# repeatedly print "Hi\\n"
+# main:
+# load 0x10010000 (UART0) into t0
+37/7 05/5 10010/20
+# store 0x48 (H) in UART0+0
+13/7 06/5 00/3 00/5 48/12
+23/7 00/5 02/3 05/5 06/5 00/7
+# store 0x69 (i) in UART0+0
+13/7 06/5 00/3 00/5 69/12
+23/7 00/5 02/3 05/5 06/5 00/7
+# store 0x0a (\\n) in UART0+0
+13/7 06/5 00/3 00/5 0a/12
+23/7 00/5 02/3 05/5 06/5 00/7
+# jump back up to the top
+17/7 07/5 00000/20
+67/7 00/5 00/3 07/5 fe4/12
"""
import subv
import bits
-import re
-
-slice_re = re.compile(r"^([^\[]+)(?:\[(\d+):(\d+)\])?$")
-field_re = re.compile(r"^(imm|off)(\d+)$")
def observe(word, pc, map):