Added cms, and a test for it.
authorDavid Given <dg@cowlark.com>
Mon, 17 Sep 2018 11:42:10 +0000 (12:42 +0100)
committerDavid Given <dg@cowlark.com>
Mon, 17 Sep 2018 11:42:10 +0000 (12:42 +0100)
mach/mips/libem/cms.s [new file with mode: 0644]
tests/plat/core/cms_e.e [new file with mode: 0644]

diff --git a/mach/mips/libem/cms.s b/mach/mips/libem/cms.s
new file mode 100644 (file)
index 0000000..e7e87e7
--- /dev/null
@@ -0,0 +1,35 @@
+#
+.sect .text; .sect .rom; .sect .data; .sect .bss
+
+/*
+ * Set comparison Returns 0 if the sets were equal.
+ * Stack: ( a b size -- a!=b )
+ */
+
+.sect .text
+.define .cms
+.cms:
+       lw r4, 0(sp)        ! r4 = size; sp points at b-word
+       addu r5, sp, r4     ! r5 points at a-word
+       addu r6, r5, r4         ! r6 is final sp-word
+       srl r4, r4, 2       ! r4 = count of words
+       li r8, 1                        ! result
+
+1:
+       lw at, 4(r5)        ! load a
+       lw r7, 4(sp)        ! load b
+       bne at, r7, exit        ! branch if not equal
+       nop
+       addiu r5, r5, 4
+       addiu sp, sp, 4
+       addiu r4, r4, -1
+       bne r4, zero, 1b
+       nop
+
+       li r8, 0                        ! Update result.
+exit:
+       mov sp, r6
+       sw r8, 0(sp)
+       jr ra
+       nop
+
diff --git a/tests/plat/core/cms_e.e b/tests/plat/core/cms_e.e
new file mode 100644 (file)
index 0000000..fe79de2
--- /dev/null
@@ -0,0 +1,75 @@
+#
+    mes 2, EM_WSIZE, EM_PSIZE
+
+    exp $_m_a_i_n
+    pro $_m_a_i_n, 0
+
+       /* Compare equal word sets. */
+
+word
+       rom EM_WSIZE
+
+       loc 1
+       loc 1
+       loe word                /* to defeat constant folding */
+       cms
+       zeq *1
+
+    loc __LINE__
+    cal $fail
+    asp 4
+1
+
+       /* Compare non-equal word sets. */
+
+       loc 1
+       loc 2
+       loe word                /* to defeat constant folding */
+       cms
+       zne *2
+
+    loc __LINE__
+    cal $fail
+    asp 4
+2
+
+       /* Compare equal triple-word sets. */
+
+       loc 1
+       loc 2
+       loc 3
+       loc 1
+       loc 2
+       loc 3
+       loe word                /* to defeat constant folding */
+       loc 3
+       mli EM_WSIZE
+       cms
+       zeq *3
+
+    loc __LINE__
+    cal $fail
+    asp 4
+3
+
+       /* Compare non-equal triple-word sets. */
+
+       loc 1
+       loc 2
+       loc 3
+       loc 1
+       loc 2
+       loc 4
+       loe word                /* to defeat constant folding */
+       loc 3
+       mli EM_WSIZE
+       cms
+       zne *4
+
+    loc __LINE__
+    cal $fail
+    asp 4
+4
+
+    cal $finished
+    end