diff --git a/mach/mips/libem/set.s b/mach/mips/libem/set.s index 01a6ff654..ec45eb45a 100644 --- a/mach/mips/libem/set.s +++ b/mach/mips/libem/set.s @@ -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 diff --git a/tests/plat/core/set_e.e b/tests/plat/core/set_e.e new file mode 100644 index 000000000..55659a3de --- /dev/null +++ b/tests/plat/core/set_e.e @@ -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 diff --git a/tests/plat/lib/test.c b/tests/plat/lib/test.c index 6df3ee7d5..33a4e86e7 100644 --- a/tests/plat/lib/test.c +++ b/tests/plat/lib/test.c @@ -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"; diff --git a/tests/plat/lib/test.h b/tests/plat/lib/test.h index db16506f9..6c0acc6b2 100644 --- a/tests/plat/lib/test.h +++ b/tests/plat/lib/test.h @@ -5,8 +5,8 @@ #include 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)