Added a test for set. Fix mips set implementation.

This commit is contained in:
David Given 2018-09-17 11:56:15 +01:00
parent 7efb749003
commit 15ae171aef
4 changed files with 61 additions and 9 deletions

View file

@ -11,23 +11,25 @@
.set:
lw r4, 0(sp) ! r4 = size
lw r5, 4(sp) ! r5 = bit number
addiu sp, sp, 4
addiu sp, sp, 8
srl r4, r4, 2 ! r4 = word count
! Create an empty set.
! Create an empty set by pushing zeros.
1:
addiu sp, sp, -4
sw zero, 0(sp)
addiu r4, r4, -1
bne r4, zero, 1b
nop
! sp now points at the set.
srl r6, r5, 3 ! r6 = offset of word in set
addu r6, sp, r6 ! r6 = address of word in set
andi r6, r5, ~31 ! r6 = bit offset of base of word in set
srl r6,r6, 3 ! r6 = byte offset of word in set
addu r6, sp, r6 ! r6 = address of word in set
ext r7, r5, 0, 3 ! r7 = bit number within word
andi r7, r5, 31 ! r7 = bit number within word
li r8, 1
sllv r8, r8, r7 ! r8 = word with 1 set
sw r8, 0(r6) ! write to set

50
tests/plat/core/set_e.e Normal file
View file

@ -0,0 +1,50 @@
#
mes 2, EM_WSIZE, EM_PSIZE
exp $_m_a_i_n
pro $_m_a_i_n, 0
/* Create word-sized singleton set. */
word
rom EM_WSIZE
loc 1
loe word /* to defeat constant folding */
set
loc 2
cmu EM_WSIZE
zeq *1
loc __LINE__
cal $fail
asp 4
1
/* Create triple-word-sized set with low bit */
loc EM_WSIZE*8 + 1
loe word /* to defeat constant folding */
loc 3
mli EM_WSIZE
set
loc 0
cmu EM_WSIZE
zne *2
loc 2
cmu EM_WSIZE
zne *2
loc 0
cmu EM_WSIZE
zeq *3
2
loc __LINE__
cal $fail
asp 4
3
cal $finished
end

View file

@ -9,7 +9,7 @@ void finished(void)
_exit(0);
}
void writehex(uint32_t code)
void writehex(unsigned int code)
{
char buf[8];
char* p = &buf[sizeof(buf)];
@ -24,7 +24,7 @@ void writehex(uint32_t code)
write(1, p, buf + sizeof(buf) - p);
}
void fail(uint32_t code)
void fail(unsigned int code)
{
static const char fail_msg[] = "@@FAIL 0x";
static const char nl_msg[] = "\n";

View file

@ -5,8 +5,8 @@
#include <stdint.h>
extern void finished(void);
extern void writehex(uint32_t code);
extern void fail(uint32_t code);
extern void writehex(unsigned int code);
extern void fail(unsigned int code);
#define ASSERT(condition) \
do { if (!(condition)) fail(__LINE__); } while(0)