Search
lxdream.org :: lxdream/src/cpu.c
lxdream 0.9.1
released Jun 29
Download Now
filename src/cpu.c
changeset 1093:34faf227070e
prev1091:186558374345
author nkeynes
date Fri Dec 02 18:18:04 2011 +1000 (12 years ago)
permissions -rw-r--r--
last change SH4 shadow-mode tweaks
- Fix exceptions generated by the translator to account for the excepting
instruction(s) in the cycle counts.
- Compare floating point regs bitwise rather than with FP comparisons
(otherwise can fail due to nan != nan)
- Dump the translated block when we abort with an inconsistency
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     if( column != 0 ) {
    51         fprintf( f, "\n" );
    52     }
    53 }
.