]> gitweb.factorcode.org Git - factor.git/commitdiff
cpu.x86: add some alien-assembly unit tests
authorSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Thu, 7 Jan 2010 04:59:17 +0000 (17:59 +1300)
committerSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Thu, 7 Jan 2010 04:59:17 +0000 (17:59 +1300)
basis/cpu/x86/32/32-tests.factor [new file with mode: 0644]
basis/cpu/x86/64/64-tests.factor [new file with mode: 0644]

diff --git a/basis/cpu/x86/32/32-tests.factor b/basis/cpu/x86/32/32-tests.factor
new file mode 100644 (file)
index 0000000..bc07e3a
--- /dev/null
@@ -0,0 +1,7 @@
+IN: cpu.x86.32.tests
+USING: alien alien.c-types tools.test cpu.x86.assembler
+cpu.x86.assembler.operands ;
+
+: assembly-test-1 ( -- x ) int { } "cdecl" [ EAX 3 MOV ] alien-assembly ;
+
+[ 3 ] [ assembly-test-1 ] unit-test
diff --git a/basis/cpu/x86/64/64-tests.factor b/basis/cpu/x86/64/64-tests.factor
new file mode 100644 (file)
index 0000000..6d171af
--- /dev/null
@@ -0,0 +1,15 @@
+USING: alien alien.c-types cpu.architecture cpu.x86.64
+cpu.x86.assembler cpu.x86.assembler.operands tools.test ;
+IN: cpu.x86.64.tests
+
+: assembly-test-1 ( -- x ) int { } "cdecl" [ RAX 3 MOV ] alien-assembly ;
+
+[ 3 ] [ assembly-test-1 ] unit-test
+
+: assembly-test-2 ( a b -- x )
+    int { int int } "cdecl" [
+        param-reg-0 param-reg-1 ADD
+        int-regs return-reg param-reg-0 MOV
+    ] alien-assembly ;
+
+[ 23 ] [ 17 6 assembly-test-2 ] unit-test