summaryrefslogtreecommitdiffstats
path: root/share
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2018-03-12 23:57:32 -0700
committerKaz Kylheku <kaz@kylheku.com>2018-03-12 23:57:32 -0700
commitfb056029e86b0c21d362d623a851a7c89c12ff8b (patch)
tree71f1ccbcb5294649b9ff9ad9bb85629e4a89cf9e /share
parent4c0019ef1bf58ccb782e52bc3db5032e3df45e77 (diff)
downloadtxr-fb056029e86b0c21d362d623a851a7c89c12ff8b.tar.gz
txr-fb056029e86b0c21d362d623a851a7c89c12ff8b.tar.bz2
txr-fb056029e86b0c21d362d623a851a7c89c12ff8b.zip
asm: allow compound syntax reg operands.
In additon to the encoded notation like t13 and v013f, we allow forms like (t 19) and (v 1 63) which mean the same thing. These are a much more convenient representation for a compiler. * share/txr/stdlib/asm.tl (assembler parse-operand): Recognize a compound expression as an operand, and handle via parse-compound-operand function. (parse-compound-operand): New function.
Diffstat (limited to 'share')
-rw-r--r--share/txr/stdlib/asm.tl15
1 files changed, 15 insertions, 0 deletions
diff --git a/share/txr/stdlib/asm.tl b/share/txr/stdlib/asm.tl
index be83a0e3..911f65de 100644
--- a/share/txr/stdlib/asm.tl
+++ b/share/txr/stdlib/asm.tl
@@ -123,6 +123,8 @@
((r rs d ds)
(cond
((null arg) 0)
+ ((consp arg)
+ (parse-compound-operand arg))
((symbolp arg)
(parse-operand (symbol-name arg)))))
(t (error "assembler: invalid arg type spec")))))
@@ -201,6 +203,19 @@
(and (symbolp obj)
(not (symbol-package obj)))))
+(defun parse-compound-operand (cons)
+ (tree-case cons
+ ((sym arg)
+ (when (<= 0 arg 255)
+ (caseq sym
+ ((t) arg)
+ (d (+ arg 256)))))
+ ((sym arg1 arg2)
+ (when (and (<= 0 arg1 253)
+ (<= 0 arg2 255))
+ (caseq sym
+ (v (+ (* arg1 256) arg2)))))))
+
(defun parse-operand (str)
(cond
((r^$ #/t[0-9A-Fa-f][0-9A-Fa-f]?/ str)