summaryrefslogtreecommitdiff
path: root/src/modules/generator/assembly.scm
diff options
context:
space:
mode:
Diffstat (limited to 'src/modules/generator/assembly.scm')
-rw-r--r--src/modules/generator/assembly.scm18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/modules/generator/assembly.scm b/src/modules/generator/assembly.scm
new file mode 100644
index 0000000..50e158e
--- /dev/null
+++ b/src/modules/generator/assembly.scm
@@ -0,0 +1,18 @@
+(define-module (modules generator assembly)
+ #:use-module (modules ast ir)
+ #:use-module (modules utils assign-stack)
+ #:use-module (modules utils merge-instructions)
+ #:export (instrs
+ mov))
+
+
+(define (instrs lst)
+ (cons 'list (cons (list 'alloc (abs (get-frame-size)))
+ (merge-instr lst))))
+
+(define (mov dst src)
+ (if (and (eq? 'stack (car dst))
+ (eq? 'stack (car src)))
+ (append (list (list 'mov (reg "r10") src))
+ (list (list 'mov dst (reg "r10"))))
+ (list 'mov dst src)))