diff --git a/mach/mips/libem/lar4.s b/mach/mips/libem/lar4.s index 870140255..218496644 100644 --- a/mach/mips/libem/lar4.s +++ b/mach/mips/libem/lar4.s @@ -14,7 +14,7 @@ jal .aar4 nop - /* pass r2 = size from .aar4 to .los4 + /* pass r2 = size from .aar4 to .los4 */ jal .los4 nop diff --git a/mach/mips/libem/los4.s b/mach/mips/libem/los4.s index be9434a34..bebb7b616 100644 --- a/mach/mips/libem/los4.s +++ b/mach/mips/libem/los4.s @@ -11,7 +11,7 @@ .sect .text .define .los4 .los4: - lw r4, 0(sp) ! r4 = address + lw r4, 0(sp) ! r4 = address of source block ! Sizes 1 and 2 are handled specially. @@ -26,14 +26,14 @@ ! Else the size must be a multiple of 4. srl r5, r2, 2 ! r5 = number of words - addiu sp, sp, 4 ! adjust to end of block - subu sp, sp, r4 ! sp = start of block - mov r6, sp ! r6 = start of block + addiu sp, sp, 4 ! retract over address + subu sp, sp, r2 ! allocate space for destination block + mov r6, sp ! r6 = start of destination block 1: - lw at, 0(r2) + lw at, 0(r4) sw at, 0(r6) - addiu r2, r2, 4 + addiu r4, r4, 4 addiu r6, r6, 4 addiu r5, r5, -1 bne r5, zero, 1b @@ -43,13 +43,13 @@ nop byte_sized: - lb at, 0(r4) + lbu at, 0(r4) sw at, 0(sp) jr ra nop word_sized: - lh at, 0(r4) + lhu at, 0(r4) sw at, 0(sp) jr ra nop diff --git a/mach/mips/libem/sar4.s b/mach/mips/libem/sar4.s index a1ddea33c..8c70bf553 100644 --- a/mach/mips/libem/sar4.s +++ b/mach/mips/libem/sar4.s @@ -14,7 +14,7 @@ jal .aar4 nop - /* pass r2 = size from .aar4 to .sts4 + /* pass r2 = size from .aar4 to .sts4 */ jal .sts4 nop diff --git a/tests/plat/core/aar_e.e b/tests/plat/core/aar_e.e index bd8230d7a..0b53e5b50 100644 --- a/tests/plat/core/aar_e.e +++ b/tests/plat/core/aar_e.e @@ -71,6 +71,5 @@ descriptor 3 cal $finished - end diff --git a/tests/plat/core/lar_e.e b/tests/plat/core/lar_e.e new file mode 100644 index 000000000..650865b04 --- /dev/null +++ b/tests/plat/core/lar_e.e @@ -0,0 +1,73 @@ +# + mes 2, EM_WSIZE, EM_PSIZE + +/* + * Does basic testing of lar. Unfortunately, lar throws ERANGE on + * error, which we can't catch (or at least, the platforms I've looked at + * don't allow it to be caught, those platforms which actually throw it on + * error). So we just test the non-throwing cases, not the negative ones. + */ + +#define ARRAY_SIZE 3*EM_WSIZE + +array + con 1 + con 2 + con 3 + +descriptor + con -1 ; lower bound + con 3 ; range + con EM_WSIZE ; size of element + + exp $_m_a_i_n + pro $_m_a_i_n, 0 + + /* Read element -1 */ + + lae array + loc -1 + lae descriptor + lar EM_WSIZE + + loc 1 + beq *1 + + loc __LINE__ + cal $fail + ass EM_WSIZE +1 + + /* Read element 0 */ + + lae array + loc 0 + lae descriptor + lar EM_WSIZE + + loc 2 + beq *2 + + loc __LINE__ + cal $fail + ass EM_WSIZE +2 + + /* Read element 1 */ + + lae array + loc 1 + lae descriptor + lar EM_WSIZE + + loc 3 + beq *3 + + loc __LINE__ + cal $fail + ass EM_WSIZE +3 + + cal $finished + end + diff --git a/tests/plat/core/sar_e.e b/tests/plat/core/sar_e.e new file mode 100644 index 000000000..7c6da941b --- /dev/null +++ b/tests/plat/core/sar_e.e @@ -0,0 +1,125 @@ +# + mes 2, EM_WSIZE, EM_PSIZE + +/* + * Does basic testing of sar. Unfortunately, sar throws ERANGE on + * error, which we can't catch (or at least, the platforms I've looked at + * don't allow it to be caught, those platforms which actually throw it on + * error). So we just test the non-throwing cases, not the negative ones. + */ + +#define ARRAY_SIZE 3*EM_WSIZE + +array + bss ARRAY_SIZE, 0, 0 + +descriptor + con -1 ; lower bound + con 3 ; range + con EM_WSIZE ; size of element + +element0 + con 1 + con 0 + con 0 + +element1 + con 0 + con 1 + con 0 + +element2 + con 0 + con 0 + con 1 + + exp $_m_a_i_n + pro $_m_a_i_n, 0 + + /* Write element -1 */ + + cal $clear_array + loc 1 + lae array + loc -1 + lae descriptor + sar EM_WSIZE + + lae array + loi ARRAY_SIZE + lae element0 + loi ARRAY_SIZE + loc ARRAY_SIZE + cms + zeq *1 + + loc __LINE__ + cal $fail + ass EM_WSIZE +1 + + /* Write element 0 */ + + cal $clear_array + loc 1 + lae array + loc 0 + lae descriptor + sar EM_WSIZE + + lae array + loi ARRAY_SIZE + lae element1 + loi ARRAY_SIZE + loc ARRAY_SIZE + cms + zeq *2 + + loc __LINE__ + cal $fail + ass EM_WSIZE +2 + + /* Write element 1 */ + + cal $clear_array + loc 1 + lae array + loc 1 + lae descriptor + sar EM_WSIZE + + lae array + loi ARRAY_SIZE + lae element2 + loi ARRAY_SIZE + loc ARRAY_SIZE + cms + zeq *3 + + loc __LINE__ + cal $fail + ass EM_WSIZE +3 + + cal $finished + end + + exp $clear_array + pro $clear_array, 0 + + loc 0 + lae array + EM_WSIZE*0 + sti EM_WSIZE + + loc 0 + lae array + EM_WSIZE*1 + sti EM_WSIZE + + loc 0 + lae array + EM_WSIZE*2 + sti EM_WSIZE + + ret 0 + end +