Add "sym" and "def" instructions, add argument naming

This commit is contained in:
2020-10-01 23:26:06 +02:00
parent afd412f22a
commit e580a2b679
24 changed files with 333 additions and 93 deletions
+13
View File
@@ -0,0 +1,13 @@
(
(def FOO 123) ; define a constant
(call my-add 7 8)
(cmp res0 138 (ne? (fault "assert failed")))
(halt)
(proc my-add a b ; give arguments names
(sym q r0) ; give register a temporary alias
(add q a b)
(add q FOO)
(ret q)
)
)
+4 -5
View File
@@ -1,9 +1,8 @@
(
(proc main
(call fac 5)
(ld r0 res0)
(halt)
)
(call fac 5)
(ld r0 res0)
(halt)
(proc fac
(cmp arg0 2
(eq? (ret 2)))
+17 -19
View File
@@ -1,26 +1,24 @@
; Set log level to "info" or above for the best results!
(
(proc main
(sc-init 800 600)
(sc-opt 1 1) ; auto blit
(sc-opt 2 25) ; frame rate
(sc-init 800 600)
(sc-opt 1 1) ; auto blit
(sc-opt 2 25) ; frame rate
(ld r0 5) ; x
(ld r1 0) ; y
(ld r0 5) ; x
(ld r1 0) ; y
(ld r2 1) ; dx
(ld r3 1) ; dy
(ld r2 1) ; dx
(ld r3 1) ; dy
(ld r5 0x3300ff)
(ld r5 0x3300ff)
(:loop)
(add r5 0x000001)
(sc-px r0 r1 r5)
(add r0 r2)
(add r1 r3)
(cmp r0 799 (eq? (ld r2 -1)) (ne? (cmp r0 0 (eq? (ld r2 1)))))
(cmp r1 599 (eq? (ld r3 -1)) (ne? (cmp r1 0 (eq? (ld r3 1)))))
(j :loop)
)
(:loop)
(add r5 0x000001)
(sc-px r0 r1 r5)
(add r0 r2)
(add r1 r3)
(cmp r0 799 (eq? (ld r2 -1)) (ne? (cmp r0 0 (eq? (ld r2 1)))))
(cmp r1 599 (eq? (ld r3 -1)) (ne? (cmp r1 0 (eq? (ld r3 1)))))
(j :loop)
(fault "unreachable")
)