Search
lxdream.org :: lxdream/src/cpu.c
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 (12 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
view annotate diff log raw
     1 /**
     2  * $Id$
     3  *
     4  * Generic CPU utility functions
     5  *
     6  * Copyright (c) 2009 Nathan Keynes.
     7  *
     8  * This program is free software; you can redistribute it and/or modify
     9  * it under the terms of the GNU General Public License as published by
    10  * the Free Software Foundation; either version 2 of the License, or
    11  * (at your option) any later version.
    12  *
    13  * This program is distributed in the hope that it will be useful,
    14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    16  * GNU General Public License for more details.
    17  */
    19 #include "cpu.h"
    21 void cpu_print_registers( FILE *f, cpu_desc_t cpu )
    22 {
    23     int i;
    24     int column = 0;
    26     fprintf( f, "%s registers:\n", cpu->name );
    27     for( i=0; cpu->regs_info[i].name != NULL; i++ ) {
    28         void *value = cpu->get_register(i);
    29         if( value != NULL ) {
    30             column++;
    31             switch( cpu->regs_info[i].type ) {
    32             case REG_TYPE_INT:
    33                 fprintf( f,  "%5s: %08x   ", cpu->regs_info[i].name, *(uint32_t *)value );
    34                 break;
    35             case REG_TYPE_FLOAT:
    36                 fprintf( f, "%5s: %.8f ", cpu->regs_info[i].name, (double)*(float *)value );
    37                 break;
    38             case REG_TYPE_DOUBLE:
    39                 fprintf( f, "%5s: %.8f ", cpu->regs_info[i].name, *(double *)value );
    40                 break;
    41             case REG_TYPE_NONE:
    42                 column = 4;
    43             }
    44         }
    45         if( column == 4 ) {
    46             fprintf( f, "\n" );
    47             column = 0;
    48         }
    49     }
    50 }
.