9c9d16c1906730368afdd384f480f62ea9675717
2 Copyright 1992 Free Software Foundation, Inc.
4 Contributed by Cygnus Support.
5 Written by Steve Chamberlain (sac@cygnus.com).
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.
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.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
26 #define SET_WORD_MEM(x,y) {mem[x] = (y)>>8;mem[x+1] = y;}
27 #define SET_BYTE_MEM(x,y) mem[x]=y
29 #define WORD_MEM(x) ((mem[x]<<8) | (mem[x+1]))
30 #define BYTE_MEM(x) mem[x]
39 unsigned short int reg
[10];
40 unsigned char *(bregp
[16]);
41 unsigned char *(bregp_NNNNxxxx
[256]);
42 unsigned char *(bregp_xxxxNNNN
[256]);
43 unsigned short int *(wregp_xNNNxxxx
[256]);
44 unsigned short int *(wregp_xxxxxNNN
[256]);
54 #define SET_CCR(x) n = x & 0x8; v = x & 0x2; z = x & 0x4; c = x & 0x1;
55 #define GET_CCR() ((N << 3) | (Z<<2) | (V<<1) | C)
59 static unsigned char *mem
;
83 mem
= calloc (1024, 64);
85 /* initialze the array of pointers to byte registers */
86 for (tmp
= 0; tmp
< 8; tmp
++)
88 if (littleendian
.u
.high
)
90 saved_state
.bregp
[tmp
] = (unsigned char *) (saved_state
.reg
+ tmp
);
91 saved_state
.bregp
[tmp
+ 8] = saved_state
.bregp
[tmp
] + 1;
95 saved_state
.bregp
[tmp
+ 8] = (unsigned char *) (saved_state
.reg
+ tmp
);
96 saved_state
.bregp
[tmp
] = saved_state
.bregp
[tmp
+ 8] + 1;
100 /* we keep two 256 sized pointers to byte regs, one for when we
101 want to look at the reg descibed by bits NNNNxxxx and one for
102 when we want to look at xxxxNNNN */
103 for (tmp
= 0; tmp
< 256; tmp
++)
105 saved_state
.bregp_NNNNxxxx
[tmp
] = saved_state
.bregp
[(tmp
>> 4) & 0xf];
106 saved_state
.bregp_xxxxNNNN
[tmp
] = saved_state
.bregp
[tmp
& 0xf];
108 /* We keep two 256 sized pointers to word regs, one for regs in
109 xNNNxxxx and one for regs in xxxxxNNNN */
110 for (tmp
= 0; tmp
< 256; tmp
++)
112 saved_state
.wregp_xNNNxxxx
[tmp
] = &saved_state
.reg
[(tmp
>> 4) & 0x7];
113 saved_state
.wregp_xxxxxNNN
[tmp
] = &saved_state
.reg
[tmp
& 0x7];
121 control_c (sig
, code
, scp
, addr
)
131 sim_store_register (reg
, val
)
135 saved_state
.reg
[reg
] = val
;
139 sim_fetch_register (reg
, buf
)
144 buf
[0] = saved_state
.reg
[reg
] >> 8;
145 buf
[1] = saved_state
.reg
[reg
];
149 sim_write (to
, from
, len
)
155 memcpy (mem
+ to
, from
, len
);
159 sim_read (from
, to
, len
)
166 memcpy (to
, mem
+ from
, len
);
176 sim_resume (step
, sig
)
184 unsigned char **blow
;
185 unsigned char **bhigh
;
186 unsigned short **wlow
;
187 unsigned short **whigh
;
190 unsigned short int *reg
;
191 unsigned char **bregp
;
198 int cycles
= saved_state
.cycles
;
205 SET_CCR (saved_state
.reg
[CCR
]);
206 pc
= saved_state
.reg
[PC
] + mem
;
208 reg
= saved_state
.reg
;
209 bregp
= saved_state
.bregp
;
210 blow
= saved_state
.bregp_xxxxNNNN
;
211 bhigh
= saved_state
.bregp_NNNNxxxx
;
213 wlow
= saved_state
.wregp_xxxxxNNN
;
214 whigh
= saved_state
.wregp_xNNNxxxx
;
216 prev
= signal (SIGINT
, control_c
);
This page took 0.034095 seconds and 4 git commands to generate.