#include "sparcv8.H"
extern unsigned char CWP;
extern unsigned char WIM;
extern int npc;
int sparcv8::nRegs(void) {
return 72;
}
ac_word sparcv8::reg_read( int reg ) {
if ( ( reg >= 0 ) && ( reg < 32 ) ) {
if (reg <= 7)
return ac_resources::RG.read( reg );
else
return ac_resources::RB.read( ( CWP + reg ) & 0xFF );
}
else if ( reg == 64 ) return Y;
else if ( reg == 65 ) return PSR;
else if ( reg == 66 ) return WIM;
else if ( reg == 68 ) return ac_resources::ac_pc;
else if ( reg == 69 ) return npc;
return 0;
}
void sparcv8::reg_write( int reg, ac_word value ) {
if ( ( reg >= 0 ) && ( reg < 32 ) ) {
if ( ( reg <= 7 ) && ( reg != 0 ) )
RG.write( reg, value );
else
RB.write( ( CWP + reg ) & 0xFF, value );
}
else if ( reg == 64 ) Y = value;
else if ( reg == 65 ) PSR = value;
else if ( reg == 66 ) WIM = value;
else if ( reg == 68 ) ac_resources::ac_pc = value;
else if ( reg == 69 ) npc = value;
}
unsigned char sparcv8::mem_read( unsigned int address ) {
return ac_resources::IM->read_byte( address );
}
void sparcv8::mem_write( unsigned int address, unsigned char byte ) {
ac_resources::IM->write_byte( address, byte );
}