-
Notifications
You must be signed in to change notification settings - Fork 0
/
mips1_gdb_funcs.cpp
91 lines (79 loc) · 2.24 KB
/
mips1_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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
/**
* @file mips1_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
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#include "mips1.H"
// 'using namespace' statement to allow access to all
// mips1-specific datatypes
using namespace mips1_parms;
int mips1::nRegs(void) {
return 73;
}
ac_word mips1::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 mips1::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 mips1::mem_read( unsigned int address ) {
return IM->read_byte( address );
}
void mips1::mem_write( unsigned int address, unsigned char byte ) {
IM->write_byte( address, byte );
}