3 // Simulator definition for the MIPS16e instructions.
4 // Copyright (C) 2005-2024 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)(uint8_t)(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)(uint16_t)(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)(uint32_t)(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]);
215 ATTRIBUTE_FALLTHROUGH;
217 do_store (SD_,AccessLength_WORD, temp -= 4, 0, GPR[23]);
218 ATTRIBUTE_FALLTHROUGH;
220 do_store (SD_,AccessLength_WORD, temp -= 4, 0, GPR[22]);
221 ATTRIBUTE_FALLTHROUGH;
223 do_store (SD_,AccessLength_WORD, temp -= 4, 0, GPR[21]);
224 ATTRIBUTE_FALLTHROUGH;
226 do_store (SD_,AccessLength_WORD, temp -= 4, 0, GPR[20]);
227 ATTRIBUTE_FALLTHROUGH;
229 do_store (SD_,AccessLength_WORD, temp -= 4, 0, GPR[19]);
230 ATTRIBUTE_FALLTHROUGH;
232 do_store (SD_,AccessLength_WORD, temp -= 4, 0, GPR[18]);
236 do_store (SD_,AccessLength_WORD, temp -= 4, 0, GPR[17]);
238 do_store (SD_,AccessLength_WORD, temp -= 4, 0, GPR[16]);
241 case 0: case 4: case 8: case 12: case 14:
244 case 1: case 5: case 9: case 13:
247 case 2: case 6: case 10:
257 sim_engine_abort (SD, CPU, CIA, "save: aregs=%d causes unpredictable results\n", aregs);
260 do_store (SD_, AccessLength_WORD, temp -= 4, 0, GPR[7]);
262 do_store (SD_, AccessLength_WORD, temp -= 4, 0, GPR[6]);
264 do_store (SD_, AccessLength_WORD, temp -= 4, 0, GPR[5]);
266 do_store (SD_, AccessLength_WORD, temp -= 4, 0, GPR[4]);
272 GPR[29] -= framesize;
275 01100,100,1,3.RAS,4.FS:I8:16::SAVE
276 "save %s<RAS>,<SFRAME>"
279 do_save (SD_, 0, 0, RAS, SFRAME);
283 11110,3.XSREGS,4.FSHI,4.AREGS + 01100,100,1,3.RAS,4.FSLO:EXT-I8:16::SAVE
284 "save %s<RAS>%s<XSREGS>%s<AREGS><BFRAME>"
287 do_save (SD_, XSREGS, AREGS, RAS, BFRAME);
291 :function:::void:do_restore:int xsregs, int aregs, int ras0s1, int framesize
294 unsigned_word temp, temp2;
297 temp = GPR[29] + framesize;
300 /* reads are in the same order as the hardware description... */
303 GPR[31] = EXTEND32 (do_load(SD_, AccessLength_WORD, temp -= 4, 0));
307 GPR[30] = EXTEND32 (do_load (SD_,AccessLength_WORD, temp -= 4, 0));
309 GPR[23] = EXTEND32 (do_load (SD_,AccessLength_WORD, temp -= 4, 0));
311 GPR[22] = EXTEND32 (do_load (SD_,AccessLength_WORD, temp -= 4, 0));
313 GPR[21] = EXTEND32 (do_load (SD_,AccessLength_WORD, temp -= 4, 0));
315 GPR[20] = EXTEND32 (do_load (SD_,AccessLength_WORD, temp -= 4, 0));
317 GPR[19] = EXTEND32 (do_load (SD_,AccessLength_WORD, temp -= 4, 0));
319 GPR[18] = EXTEND32 (do_load (SD_,AccessLength_WORD, temp -= 4, 0));
323 GPR[17] = EXTEND32 (do_load (SD_,AccessLength_WORD, temp -= 4, 0));
325 GPR[16] = EXTEND32 (do_load (SD_,AccessLength_WORD, temp -= 4, 0));
328 case 0: case 4: case 8: case 12: case 14:
331 case 1: case 5: case 9: case 13:
334 case 2: case 6: case 10:
344 sim_engine_abort (SD, CPU, CIA, "save: aregs=%d causes unpredictable results\n", aregs);
347 GPR[7] = EXTEND32 (do_load (SD_,AccessLength_WORD, temp -= 4, 0));
349 GPR[6] = EXTEND32 (do_load (SD_,AccessLength_WORD, temp -= 4, 0));
351 GPR[5] = EXTEND32 (do_load (SD_,AccessLength_WORD, temp -= 4, 0));
353 GPR[4] = EXTEND32 (do_load (SD_,AccessLength_WORD, temp -= 4, 0));
362 01100,100,0,3.RAS,4.FS:I8:16::RESTORE
363 "restore %s<RAS>,<SFRAME>"
366 do_restore (SD_,0,0,RAS,SFRAME);
369 11110,3.XSREGS,4.FSHI,4.AREGS + 01100,100,0,3.RAS,4.FSLO:EXT-I8:16::RESTORE
370 "restore %s<RAS>%s<XSREGS>%s<AREGS><BFRAME>"
373 do_restore (SD_,XSREGS,AREGS,RAS,BFRAME);