Search
lxdream.org :: lxdream/src/cpu.c :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/cpu.c
changeset 1091:186558374345
next1093:34faf227070e
author nkeynes
date Tue Dec 15 08:46:37 2009 +1000 (10 years ago)
permissions -rw-r--r--
last change Add side-by-side x86+sh4 disassembly output
Print SH4 state information and disassembly of the current block when
crashing.
Fix delay slot instruction in conditional branch not being marked as a
delay-slot instruction in the branch-not-taken path.
Rename REG_* defines in cpu.h to avoid conflict with translation defs
file annotate diff log raw
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/src/cpu.c Tue Dec 15 08:46:37 2009 +1000
1.3 @@ -0,0 +1,50 @@
1.4 +/**
1.5 + * $Id$
1.6 + *
1.7 + * Generic CPU utility functions
1.8 + *
1.9 + * Copyright (c) 2009 Nathan Keynes.
1.10 + *
1.11 + * This program is free software; you can redistribute it and/or modify
1.12 + * it under the terms of the GNU General Public License as published by
1.13 + * the Free Software Foundation; either version 2 of the License, or
1.14 + * (at your option) any later version.
1.15 + *
1.16 + * This program is distributed in the hope that it will be useful,
1.17 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
1.18 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1.19 + * GNU General Public License for more details.
1.20 + */
1.21 +
1.22 +#include "cpu.h"
1.23 +
1.24 +void cpu_print_registers( FILE *f, cpu_desc_t cpu )
1.25 +{
1.26 + int i;
1.27 + int column = 0;
1.28 +
1.29 + fprintf( f, "%s registers:\n", cpu->name );
1.30 + for( i=0; cpu->regs_info[i].name != NULL; i++ ) {
1.31 + void *value = cpu->get_register(i);
1.32 + if( value != NULL ) {
1.33 + column++;
1.34 + switch( cpu->regs_info[i].type ) {
1.35 + case REG_TYPE_INT:
1.36 + fprintf( f, "%5s: %08x ", cpu->regs_info[i].name, *(uint32_t *)value );
1.37 + break;
1.38 + case REG_TYPE_FLOAT:
1.39 + fprintf( f, "%5s: %.8f ", cpu->regs_info[i].name, (double)*(float *)value );
1.40 + break;
1.41 + case REG_TYPE_DOUBLE:
1.42 + fprintf( f, "%5s: %.8f ", cpu->regs_info[i].name, *(double *)value );
1.43 + break;
1.44 + case REG_TYPE_NONE:
1.45 + column = 4;
1.46 + }
1.47 + }
1.48 + if( column == 4 ) {
1.49 + fprintf( f, "\n" );
1.50 + column = 0;
1.51 + }
1.52 + }
1.53 +}
.