Set fixes; also add discrete tests for and, ior, xor.

This commit is contained in:
David Given 2018-09-14 14:13:35 +01:00
parent 08b1e8d71b
commit 7efb749003
6 changed files with 194 additions and 0 deletions

View file

@ -21,6 +21,7 @@
addiu r5, r5, 4 addiu r5, r5, 4
addiu r4, r4, -1 addiu r4, r4, -1
bne r4, zero, 1b bne r4, zero, 1b
nop
jr ra jr ra
nop nop

30
mach/mips/libem/xor.s Normal file
View file

@ -0,0 +1,30 @@
#
.sect .text; .sect .rom; .sect .data; .sect .bss
/*
* Set xor..
* Stack: ( a b size -- a^b )
*/
.sect .text
.define .xor
.xor:
lw r4, 0(sp) ! r4 = size
addiu sp, sp, 4 ! sp points at b
addu r5, sp, r4 ! r5 points at a
srl r4, r4, 2 ! r4 = count of words
1:
lw at, 0(r5) ! load a
lw r6, 0(sp) ! load b
xor at, at, r6 ! combine
sw at, 0(r5) ! write back to a
addiu r5, r5, 4
addiu sp, sp, 4
addiu r4, r4, -1
bne r4, zero, 1b
nop
jr ra
nop

View file

@ -18,6 +18,7 @@
sw zero, 0(sp) sw zero, 0(sp)
addiu r4, r4, -1 addiu r4, r4, -1
bne r4, zero, 1b bne r4, zero, 1b
nop
jr ra jr ra
nop nop

54
tests/plat/core/and_e.e Normal file
View file

@ -0,0 +1,54 @@
#
mes 2, EM_WSIZE, EM_PSIZE
exp $_m_a_i_n
pro $_m_a_i_n, 0
/* And word-sized set */
four
rom EM_WSIZE
loc 32769
loc 1
loe four /* to defeat constant folding */
and
loc 1
cmu EM_WSIZE
zeq *1
loc __LINE__
cal $fail
asp 4
1
/* And triple-word-sized set */
four_by_three
rom EM_WSIZE*3
loc 32769
loc 32770
loc 32772
loc 1
loc 2
loc 4
loe four_by_three
and
loc 4
cmu EM_WSIZE
zne *2
loc 2
cmu EM_WSIZE
zne *2
loc 1
cmu EM_WSIZE
zeq *3
2
loc __LINE__
cal $fail
asp 4
3
cal $finished
end

54
tests/plat/core/ior_e.e Normal file
View file

@ -0,0 +1,54 @@
#
mes 2, EM_WSIZE, EM_PSIZE
exp $_m_a_i_n
pro $_m_a_i_n, 0
/* Or word-sized set */
four
rom EM_WSIZE
loc 0
loc 1
loe four /* to defeat constant folding */
ior
loc 1
cmu EM_WSIZE
zeq *1
loc __LINE__
cal $fail
asp 4
1
/* Or triple-word-sized set */
four_by_three
rom EM_WSIZE*3
loc 16
loc 32
loc 64
loc 1
loc 2
loc 3
loe four_by_three
ior
loc 67
cmu EM_WSIZE
zne *2
loc 34
cmu EM_WSIZE
zne *2
loc 17
cmu EM_WSIZE
zeq *3
2
loc __LINE__
cal $fail
asp 4
3
cal $finished
end

54
tests/plat/core/xor_e.e Normal file
View file

@ -0,0 +1,54 @@
#
mes 2, EM_WSIZE, EM_PSIZE
exp $_m_a_i_n
pro $_m_a_i_n, 0
/* Xor word-sized set */
four
rom EM_WSIZE
loc 32769
loc 1
loe four /* to defeat constant folding */
xor
loc 32768
cmu EM_WSIZE
zeq *1
loc __LINE__
cal $fail
asp 4
1
/* Xor triple-word-sized set */
four_by_three
rom EM_WSIZE*3
loc 32769
loc 32770
loc 32772
loc 1
loc 2
loc 4
loe four_by_three
xor
loc 32768
cmu EM_WSIZE
zne *2
loc 32768
cmu EM_WSIZE
zne *2
loc 32768
cmu EM_WSIZE
zeq *3
2
loc __LINE__
cal $fail
asp 4
3
cal $finished
end