Search
lxdream.org :: lxdream/src/test/testsh4x86.c :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/test/testsh4x86.c
changeset 365:94cab5ad0ed8
prev363:7d0bab24016c
next369:4b4223e7d720
author nkeynes
date Tue Sep 04 08:32:10 2007 +0000 (13 years ago)
permissions -rw-r--r--
last change Change sh4x86 test to translate/disasm full basic blocks
Add prelim sym-tab support
file annotate diff log raw
1.1 --- a/src/test/testsh4x86.c Tue Aug 28 08:47:35 2007 +0000
1.2 +++ b/src/test/testsh4x86.c Tue Sep 04 08:32:10 2007 +0000
1.3 @@ -1,5 +1,5 @@
1.4 /**
1.5 - * $Id: testsh4x86.c,v 1.1 2007-08-28 08:47:13 nkeynes Exp $
1.6 + * $Id: testsh4x86.c,v 1.2 2007-09-04 08:32:10 nkeynes Exp $
1.7 *
1.8 * Test cases for the SH4 => x86 translator core. Takes as
1.9 * input a binary SH4 object (and VMA), generates the
1.10 @@ -21,8 +21,9 @@
1.11 #include <stdio.h>
1.12 #include <stdarg.h>
1.13 #include <getopt.h>
1.14 +#include <sys/stat.h>
1.15 +#include "x86dasm/x86dasm.h"
1.16 #include "sh4/sh4trans.h"
1.17 -#include <sys/stat.h>
1.18 #include "sh4/sh4core.h"
1.19
1.20 #define MAX_INS_SIZE 32
1.21 @@ -34,11 +35,19 @@
1.22 char *diff_file = NULL;
1.23 char *output_file = NULL;
1.24 uint32_t start_addr = 0x8C010000;
1.25 -
1.26 +uint32_t sh4_cpu_period = 5;
1.27 FILE *in;
1.28
1.29 char *inbuf;
1.30 -char *outbuf;
1.31 +
1.32 +struct x86_symbol local_symbols[] = {
1.33 + { "_sh4_read_byte", sh4_read_byte },
1.34 + { "_sh4_read_word", sh4_read_word },
1.35 + { "_sh4_read_long", sh4_read_long },
1.36 + { "_sh4_write_byte", sh4_write_byte },
1.37 + { "_sh4_write_word", sh4_write_word },
1.38 + { "_sh4_write_long", sh4_write_long }
1.39 +};
1.40
1.41 int32_t sh4_read_byte( uint32_t addr )
1.42 {
1.43 @@ -64,6 +73,7 @@
1.44 void sh4_write_byte( uint32_t addr, uint32_t val ) {}
1.45 void sh4_write_word( uint32_t addr, uint32_t val ) {}
1.46 void sh4_write_long( uint32_t addr, uint32_t val ) {}
1.47 +gboolean sh4_raise_exception( int exc ) {}
1.48
1.49 void usage()
1.50 {
1.51 @@ -123,16 +133,13 @@
1.52 fstat( fileno(in), &st );
1.53 inbuf = malloc( st.st_size );
1.54 fread( inbuf, st.st_size, 1, in );
1.55 - outbuf = malloc( st.st_size * MAX_INS_SIZE );
1.56 - xlat_output = outbuf;
1.57
1.58 + xlat_cache_init();
1.59 uint32_t pc;
1.60 - for( pc = start_addr; pc < start_addr + st.st_size; pc+=2 ) {
1.61 - sh4_x86_translate_instruction( pc );
1.62 - }
1.63 -
1.64 - uint32_t buflen = (xlat_output - (uint8_t *)outbuf);
1.65 - x86_disasm_init( outbuf, 0x8c010000, buflen );
1.66 + uint8_t *buf = sh4_translate_basic_block( start_addr );
1.67 + uint32_t buflen = xlat_get_block_size(buf);
1.68 + x86_disasm_init( buf, 0x8c010000, buflen );
1.69 + x86_set_symtab( local_symbols, 6 );
1.70 for( pc = 0x8c010000; pc < 0x8c010000 + buflen; ) {
1.71 char buf[256];
1.72 char op[256];
.