3 // Simulator definition for the MIPS16e instructions.
4 // Copyright (C) 2005-2018 Free Software Foundation, Inc.
5 // Contributed by Nigel Stephens (nigel@mips.com) and
6 // David Ung (davidu@mips.com) of MIPS Technologies.
8 // This file is part of GDB, the GNU debugger.
10 // This program is free software; you can redistribute it and/or modify
11 // it under the terms of the GNU General Public License as published by
12 // the Free Software Foundation; either version 3 of the License, or
13 // (at your option) any later version.
15 // This program is distributed in the hope that it will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU General Public License for more details.
20 // You should have received a copy of the GNU General Public License
21 // along with this program. If not, see <http://www.gnu.org/licenses/>.
24 11101,3.RX,100,10001:RR:16::SEB
28 TRACE_ALU_INPUT1 (GPR[TRX]);
29 GPR[TRX] = EXTEND8 (GPR[TRX]);
30 TRACE_ALU_RESULT (GPR[TRX]);
34 11101,3.RX,101,10001:RR:16::SEH
38 TRACE_ALU_INPUT1 (GPR[TRX]);
39 GPR[TRX] = EXTEND16 (GPR[TRX]);
40 TRACE_ALU_RESULT (GPR[TRX]);
43 11101,3.RX,110,10001:RR:16::SEW
47 check_u64 (SD_, instruction_0);
48 TRACE_ALU_INPUT1 (GPR[TRX]);
49 GPR[TRX] = EXTEND32 (GPR[TRX]);
50 TRACE_ALU_RESULT (GPR[TRX]);
53 11101,3.RX,000,10001:RR:16::ZEB
57 TRACE_ALU_INPUT1 (GPR[TRX]);
58 GPR[TRX] = (unsigned_word)(unsigned8)(GPR[TRX]);
59 TRACE_ALU_RESULT (GPR[TRX]);
62 11101,3.RX,001,10001:RR:16::ZEH
66 TRACE_ALU_INPUT1 (GPR[TRX]);
67 GPR[TRX] = (unsigned_word)(unsigned16)(GPR[TRX]);
68 TRACE_ALU_RESULT (GPR[TRX]);
71 11101,3.RX,010,10001:RR:16::ZEW
75 check_u64 (SD_, instruction_0);
76 TRACE_ALU_INPUT1 (GPR[TRX]);
77 GPR[TRX] = (unsigned_word)(unsigned32)(GPR[TRX]);
78 TRACE_ALU_RESULT (GPR[TRX]);
82 11101,3.RX,100,00000:RR:16::JRC
90 11101,000,101,00000:RR:16::JRCRA
98 11101,3.RX,110,00000:RR:16::JALRC
107 // format routines for save/restore
122 :%s::::XSREGS:int xsregs
126 return "s2,s3,s4,s5,s6,s7,s8,";
128 return "s2,s3,s4,s5,s6,s7,";
130 return "s2,s3,s4,s5,s6,";
132 return "s2,s3,s4,s5,";
142 :%s::::AREGS:int aregs
145 // Fixme: how is the arg/static distinction made by the assembler?
146 static const char * const aregstr[16] = {
163 return aregstr[aregs];
166 :compute:::int:SFRAME:FS:((FS == 0) ? 128 \: (FS << 3))
167 :compute:::int:BFRAME:FSHI,FSLO:(((FSHI << 4) | FSLO) << 3)
169 :function:::void:do_save:int xsregs, int aregs, int ras0s1, int framesize
176 /* writes are in the same order as the hardware description... */
178 case 0: case 1: case 2: case 3: case 11:
181 case 4: case 5: case 6: case 7:
184 case 8: case 9: case 10:
194 sim_engine_abort (SD, CPU, CIA, "save: aregs=%d causes unpredictable results\n", aregs);
197 do_store (SD_, AccessLength_WORD, temp, 0, GPR[4]);
199 do_store (SD_,AccessLength_WORD, temp, 4 , GPR[5]);
201 do_store (SD_,AccessLength_WORD, temp, 8 , GPR[6]);
203 do_store (SD_,AccessLength_WORD, temp, 12, GPR[7]);
210 do_store (SD_,AccessLength_WORD, temp -= 4, 0, GPR[31]);
214 do_store (SD_,AccessLength_WORD, temp -= 4, 0, GPR[30]);
216 do_store (SD_,AccessLength_WORD, temp -= 4, 0, GPR[23]);
218 do_store (SD_,AccessLength_WORD, temp -= 4, 0, GPR[22]);
220 do_store (SD_,AccessLength_WORD, temp -= 4, 0, GPR[21]);
222 do_store (SD_,AccessLength_WORD, temp -= 4, 0, GPR[20]);
224 do_store (SD_,AccessLength_WORD, temp -= 4, 0, GPR[19]);
226 do_store (SD_,AccessLength_WORD, temp -= 4, 0, GPR[18]);
230 do_store (SD_,AccessLength_WORD, temp -= 4, 0, GPR[17]);
232 do_store (SD_,AccessLength_WORD, temp -= 4, 0, GPR[16]);
235 case 0: case 4: case 8: case 12: case 14:
238 case 1: case 5: case 9: case 13:
241 case 2: case 6: case 10:
251 sim_engine_abort (SD, CPU, CIA, "save: aregs=%d causes unpredictable results\n", aregs);
254 do_store (SD_, AccessLength_WORD, temp -= 4, 0, GPR[7]);
256 do_store (SD_, AccessLength_WORD, temp -= 4, 0, GPR[6]);
258 do_store (SD_, AccessLength_WORD, temp -= 4, 0, GPR[5]);
260 do_store (SD_, AccessLength_WORD, temp -= 4, 0, GPR[4]);
266 GPR[29] -= framesize;
269 01100,100,1,3.RAS,4.FS:I8:16::SAVE
270 "save %s<RAS>,<SFRAME>"
273 do_save (SD_, 0, 0, RAS, SFRAME);
277 11110,3.XSREGS,4.FSHI,4.AREGS + 01100,100,1,3.RAS,4.FSLO:EXT-I8:16::SAVE
278 "save %s<RAS>%s<XSREGS>%s<AREGS><BFRAME>"
281 do_save (SD_, XSREGS, AREGS, RAS, BFRAME);
285 :function:::void:do_restore:int xsregs, int aregs, int ras0s1, int framesize
288 unsigned_word temp, temp2;
291 temp = GPR[29] + framesize;
294 /* reads are in the same order as the hardware description... */
297 GPR[31] = EXTEND32 (do_load(SD_, AccessLength_WORD, temp -= 4, 0));
301 GPR[30] = EXTEND32 (do_load (SD_,AccessLength_WORD, temp -= 4, 0));
303 GPR[23] = EXTEND32 (do_load (SD_,AccessLength_WORD, temp -= 4, 0));
305 GPR[22] = EXTEND32 (do_load (SD_,AccessLength_WORD, temp -= 4, 0));
307 GPR[21] = EXTEND32 (do_load (SD_,AccessLength_WORD, temp -= 4, 0));
309 GPR[20] = EXTEND32 (do_load (SD_,AccessLength_WORD, temp -= 4, 0));
311 GPR[19] = EXTEND32 (do_load (SD_,AccessLength_WORD, temp -= 4, 0));
313 GPR[18] = EXTEND32 (do_load (SD_,AccessLength_WORD, temp -= 4, 0));
317 GPR[17] = EXTEND32 (do_load (SD_,AccessLength_WORD, temp -= 4, 0));
319 GPR[16] = EXTEND32 (do_load (SD_,AccessLength_WORD, temp -= 4, 0));
322 case 0: case 4: case 8: case 12: case 14:
325 case 1: case 5: case 9: case 13:
328 case 2: case 6: case 10:
338 sim_engine_abort (SD, CPU, CIA, "save: aregs=%d causes unpredictable results\n", aregs);
341 GPR[7] = EXTEND32 (do_load (SD_,AccessLength_WORD, temp -= 4, 0));
343 GPR[6] = EXTEND32 (do_load (SD_,AccessLength_WORD, temp -= 4, 0));
345 GPR[5] = EXTEND32 (do_load (SD_,AccessLength_WORD, temp -= 4, 0));
347 GPR[4] = EXTEND32 (do_load (SD_,AccessLength_WORD, temp -= 4, 0));
356 01100,100,0,3.RAS,4.FS:I8:16::RESTORE
357 "restore %s<RAS>,<SFRAME>"
360 do_restore (SD_,0,0,RAS,SFRAME);
363 11110,3.XSREGS,4.FSHI,4.AREGS + 01100,100,0,3.RAS,4.FSLO:EXT-I8:16::RESTORE
364 "restore %s<RAS>%s<XSREGS>%s<AREGS><BFRAME>"
367 do_restore (SD_,XSREGS,AREGS,RAS,BFRAME);