Search
lxdream.org :: lxdream/test/lib.c :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename test/lib.c
changeset 190:f7653df5e832
prev185:6755a04c447f
author nkeynes
date Wed Dec 02 10:36:49 2009 +1000 (14 years ago)
permissions -rw-r--r--
last change Add missing SUBV instruction to the emulation core (translation core is ok),
along with test cases. Thanks to D. Jeff Dionne for pointing this out.
file annotate diff log raw
1.1 --- a/test/lib.c Tue Jul 11 01:35:27 2006 +0000
1.2 +++ b/test/lib.c Wed Dec 02 10:36:49 2009 +1000
1.3 @@ -18,3 +18,45 @@
1.4 fprintf( f, "\n");
1.5 }
1.6 }
1.7 +
1.8 +void fwrite_diff( FILE *f, char *a, int a_length, char *b, int b_length )
1.9 +{
1.10 + int i;
1.11 + fprintf( f, "Expected %d bytes:\n", a_length );
1.12 + fwrite_dump( f, a, a_length );
1.13 + fprintf( f, "but was %d bytes =>\n", b_length );
1.14 + fwrite_dump( f, b, b_length );
1.15 +}
1.16 +
1.17 +void fwrite_diff32( FILE *f, char *a, int a_length, char *b, int b_length )
1.18 +{
1.19 + int i,j, k;
1.20 + int length = a_length > b_length ? a_length : b_length;
1.21 + fprintf( f, "Expected %d bytes, was %d bytes =>\n", a_length, b_length );
1.22 +
1.23 + for( i=0; i<length; i+=16 ) {
1.24 + for( k=0; k<32 && i+k < length; k+=4 ) {
1.25 + if( i+k >= a_length || i+k >= b_length ||
1.26 + *((volatile unsigned int *)(a+i+k)) != *((volatile unsigned int *)(b+i+k)) ) {
1.27 + break;
1.28 + }
1.29 + }
1.30 + if( k != 32 && i+k != length ) {
1.31 + fprintf( f, "%08X: ", i );
1.32 + for( j=0; j<16 && i+j < a_length; j+=4 ) {
1.33 + fprintf( f, "%08X ", *((volatile unsigned int *)(a+i+j)) );
1.34 + }
1.35 +
1.36 + for(; j<16; j+=4 ) {
1.37 + fprintf( f, " " );
1.38 + }
1.39 +
1.40 + fprintf( f, "| " );
1.41 + for( j=0; j<16 && i+j < b_length; j+=4 ) {
1.42 + fprintf( f, "%08X ", *((volatile unsigned int *)(b+i+j)) );
1.43 + }
1.44 +
1.45 + fprintf( f, "\n");
1.46 + }
1.47 + }
1.48 +}
.