forked from ArchC/mips
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mips_gdb_funcs.cpp
77 lines (65 loc) · 1.53 KB
/
mips_gdb_funcs.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/**
* @file mips_gdb_funcs.cpp
* @author Sandro Rigo
* Marcus Bartholomeu
* Alexandro Baldassin (acasm information)
*
* The ArchC Team
* http://www.archc.org/
*
* Computer Systems Laboratory (LSC)
* IC-UNICAMP
* http://www.lsc.ic.unicamp.br/
*
* @version 1.0
* @date Mon, 19 Jun 2006 15:50:52 -0300
*
* @brief The ArchC MIPS-I functional model.
*
* @attention Copyright (C) 2002-2006 --- The ArchC Team
*
*/
#include "mips.H"
// 'using namespace' statement to allow access to all
// mips-specific datatypes
using namespace mips_parms;
int mips::nRegs(void) {
return 73;
}
ac_word mips::reg_read( int reg ) {
/* general purpose registers */
if ( ( reg >= 0 ) && ( reg < 32 ) )
return RB.read( reg );
else {
if (reg == 33)
return lo;
else if (reg == 34)
return hi;
else
/* pc */
if ( reg == 37 )
return ac_pc;
}
return 0;
}
void mips::reg_write( int reg, ac_word value ) {
/* general purpose registers */
if ( ( reg >= 0 ) && ( reg < 32 ) )
RB.write( reg, value );
else
{
/* lo, hi */
if ( ( reg >= 33 ) && ( reg < 35 ) )
RB.write( reg - 1, value );
else
/* pc */
if ( reg == 37 )
ac_pc = value;
}
}
unsigned char mips::mem_read( unsigned int address ) {
return INST_PORT->read_byte( address );
}
void mips::mem_write( unsigned int address, unsigned char byte ) {
INST_PORT->write_byte( address, byte );
}