-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRSP_Decoder.cs
599 lines (551 loc) · 25.1 KB
/
RSP_Decoder.cs
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace N64_RSP_DISASSEMBLER
{
class RSP_DECODER
{
[Flags]
public enum OPTIONS : byte
{
NO_OPTIONS = 0x00,
USE_GP_NAMES = 0x01,
USE_LONG_FORM = 0x02,
USE_ARMIPS_CP0_NAMES = 0x04
}
// General-Purpose Registers
public enum GP_REGISTER
{
r0, // Constant 0
at, // Used for psuedo-instructions
v0, v1, // Function returns
a0, a1, a2, a3, // Function arguments
t0, t1, t2, t3, t4, t5, t6, t7, // Temporary
s0, s1, s2, s3, s4, s5, s6, s7, // Saved
t8, t9, // More temporary
k0, k1, // Reserved for kernal
gp, // Global area pointer
sp, // Stack pointer
s8, // One more saved pointer
ra // Return address
}
private static readonly string[] ARMIPS_CP0_NAMES =
{
"sp_mem_addr", "sp_dram_addr", "sp_rd_len", "sp_wr_len",
"sp_status", "sp_dma_full", "sp_dma_busy", "sp_semaphore",
"dpc_start", "dpc_end", "dpc_current", "dpc_status",
"dpc_clock", "dpc_bufbusy", "dpc_pipebusy", "dpc_tmem"
};
public enum CP0_REGISTER
{
DMA_CACHE,
DMA_DRAM,
DMA_READ_LENGTH,
DMA_WRITE_LENGTH,
SP_STATUS,
DMA_FULL,
DMA_BUSY,
SP_RESERVED,
CMD_START,
CMD_END,
CMD_CURRENT,
CMD_STATUS,
CMD_CLOCK,
CMD_BUSY,
CMD_PIPE_BUSY,
CMD_TMEM_BUSY
}
public enum RSP_OPCODE
{
SPECIAL = 0x00, // 000000
REGIMM = 0x01, // 000001
J = 0x02, // 000010
JAL = 0x03, // 000011
BEQ = 0x04, // 000100
BNE = 0x05, // 000101
BLEZ = 0x06, // 000110
BGTZ = 0x07, // 000111
ADDI = 0x08, // 001000
ADDIU = 0x09, // 001001
SLTI = 0x0A, // 001010
SLTIU = 0x0B, // 001011
ANDI = 0x0C, // 001100
ORI = 0x0D, // 001101
XORI = 0x0E, // 001110
LUI = 0x0F, // 001111
COP0 = 0x10, // 010000
COP2 = 0x12, // 010010
LB = 0x20, // 100000
LH = 0x21, // 100001
LW = 0x23, // 100011
LBU = 0x24, // 100100
LHU = 0x25, // 100101
LWU = 0x27, // 100111
SB = 0x28, // 101000
SH = 0x29, // 101001
SW = 0x2B, // 101011
LWC2 = 0x32, // 110010
SWC2 = 0x3A, // 111010
}
public enum RSP_VECTOR_OPCODE
{
VMULF = 0x00, // Vector (Frac) Multiply
VMULU = 0x01, // Vector (Unsigned Frac) Multiply
VRNDP = 0x02, // Vector DCT Round (+)
VMULQ = 0x03, // Vector (Integer) Multiply
VMUDL = 0x04, // Vector low multiply
VMUDM = 0x05, // Vector mid-m multiply
VMUDN = 0x06, // Vector mid-n multiply
VMUDH = 0x07, // Vector high multiply
VMACF = 0x08, // Vector (Frac) Multiply Accumulate
VMACU = 0x09, // Vector (Unsigned Frac) Multiply Accumulate
VRNDN = 0x0A, // Vector DCT Round (-)
VMACQ = 0x0B, // Vector (Integer) Multiply Accumulate
VMADL = 0x0C, // Vector low multiply accumulate
VMADM = 0x0D, // Vector mid-m multiply accumulate
VMADN = 0x0E, // Vector mid-n multiply accumulate
VMADH = 0x0F, // Vector high multiply accumulate
VADD = 0x10, // Vector add
VSUB = 0x11, // Vector subtract
VABS = 0x13, // Vector absolute value
VADDC = 0x14, // Vector add with carry
VSUBC = 0x15, // Vector subtract with carry
VSAR = 0x1D, // Vector accumulator read (and write)
VLT = 0x20, // Vector select (Less than)
VEQ = 0x21, // Vector select (Equal)
VNE = 0x22, // Vector select (Not equal)
VGE = 0x23, // Vector select (Greater than or equal)
VCL = 0x24, // Vector select clip (Test low)
VCH = 0x25, // Vector select clip (Test high)
VCR = 0x26, // Vector select crimp (Test low)
VMRG = 0x27, // Vector select merge
VAND = 0x28, // Vector AND
VNAND = 0x29, // Vector NAND
VOR = 0x2A, // Vector OR
VNOR = 0x2B, // Vector NOR
VXOR = 0x2C, // Vector XOR
VNXOR = 0x2D, // Vector NXOR
VRCP = 0x30, // Vector element scalar reciprocal (Single precision)
VRCPL = 0x31, // Vector element scalar reciprocal (Double precision, Low)
VRCPH = 0x32, // Vector element scalar reciprocal (Double precision, High)
VMOV = 0x33, // Vector element scalar move
VRSQ = 0x34, // Vector element scalar SQRT reciprocal
VRSQL = 0x35, // Vector element scalar SQRT reciprocal (Double precision, Low)
VRSQH = 0x36, // Vector element scalar SQRT reciprocal (Double precision, High)
VNOP = 0x37, // Vector null instruction
}
public enum RSP_LOAD_STORE_COMMAND
{
b = 0x00, // (BYTE) 00000
s = 0x01, // (HALFWORD) 00001
l = 0x02, // (WORD) 00010
d = 0x03, // (DOUBLEWORD) 00011
q = 0x04, // (QUADWORD) 00100
r = 0x05, // (REST) 00101
p = 0x06, // (PACKED) 00110
u = 0x07, // (UNPACKED) 00111
h = 0x08, // (HALF) 01000
f = 0x09, // (FOURTH) 01001
w = 0x0A, // (WRAP) 01010
t = 0x0B, // (TRANSPOSE) 01011
}
private static bool usingRegNames = false;
private static bool usingLongForm = false;
private static bool usingArmipsCP0Names = false;
private static string getRPRegName(byte reg)
{
if (usingRegNames)
return ((GP_REGISTER)reg).ToString();
else
return "r" + reg.ToString();
}
private static string getGRPRegName(GP_REGISTER reg)
{
if (usingRegNames)
return reg.ToString();
else
return "r" + ((byte)reg).ToString();
}
private static string getCP0RegName(CP0_REGISTER reg)
{
if (usingArmipsCP0Names)
return ARMIPS_CP0_NAMES[(int)reg];
else
return reg.ToString();
}
private static string decodeLoadStoreOperation(uint operation, string LorS)
{
RSP_LOAD_STORE_COMMAND ls_subop =
(RSP_LOAD_STORE_COMMAND)((operation >> 11) & 0x1F);
string str = LorS + ls_subop.ToString() + "v";
byte base_ = (byte)((operation >> 21) & 0x1F);
byte dest = (byte)((operation >> 16) & 0x1F);
byte del = (byte)((operation >> 7) & 0xF);
ushort offset = (ushort)((operation & 0x3F) << 2);
str += " $v" + dest + "[" + del + "], 0x" + offset.ToString("X4") + "(" + getRPRegName(base_) + ")";
return str;
}
private static string getLongFormForQuaterElement(int eq)
{
switch (eq)
{
case 0: return "[00224466]";
case 1: return "[11335577]";
}
return "";
}
private static string getLongFormForHalfElement(int eh)
{
switch (eh)
{
case 0: return "[00004444]";
case 1: return "[11115555]";
case 2: return "[22226666]";
case 3: return "[33337777]";
}
return "";
}
private static string getLongForm(int e)
{
switch (e)
{
case 0: return "[00000000]";
case 1: return "[11111111]";
case 2: return "[22222222]";
case 3: return "[33333333]";
case 4: return "[44444444]";
case 5: return "[55555555]";
case 6: return "[66666666]";
case 7: return "[77777777]";
}
return "";
}
private static string decodeVectorElement(byte v, byte e)
{
if ((e & 0x8) == 8)
if (usingLongForm)
return v + getLongForm(e & 0x7);
else
return v + "[" + (e & 0x7) + "]";
else if ((e & 0xC) == 4)
if (usingLongForm)
return v + getLongFormForHalfElement(e & 0x3);
else
return v + "[" + (e & 0x3) + "h]";
else if ((e & 0xE) == 2)
if (usingLongForm)
return v + getLongFormForQuaterElement(e & 0x1);
else
return v + "[" + (e & 0x1) + "q]";
else
if (usingLongForm)
return v + "[01234567]";
else
return v.ToString();
}
private static string decodeVectorElementScalarOperation(RSP_VECTOR_OPCODE opcode, uint operation)
{
byte e = (byte)((operation >> 21) & 0xF);
byte vt = (byte)((operation >> 16) & 0x1F);
byte de = (byte)((operation >> 11) & 0x1F);
byte vd = (byte)((operation >> 6) & 0x1F);
// return opcode.ToString().ToLower() + " $v" + vd + "[" + de + "], $v" + vt + "[" + e + "]";
return opcode.ToString().ToLower() + " $v" + decodeVectorElement(vd, de)
+ ", $v" + decodeVectorElement(vt, e);
}
private static string decodeVectorOperation(uint operation)
{
RSP_VECTOR_OPCODE opcode = (RSP_VECTOR_OPCODE)(operation & 0x3F);
switch(opcode)
{
case RSP_VECTOR_OPCODE.VRCP:
case RSP_VECTOR_OPCODE.VRCPL:
case RSP_VECTOR_OPCODE.VRCPH:
case RSP_VECTOR_OPCODE.VMOV:
case RSP_VECTOR_OPCODE.VRSQ:
case RSP_VECTOR_OPCODE.VRSQL:
case RSP_VECTOR_OPCODE.VRSQH:
return decodeVectorElementScalarOperation(opcode, operation);
case RSP_VECTOR_OPCODE.VNOP:
return "vnop";
}
byte e = (byte)((operation >> 21) & 0xF);
byte vt = (byte)((operation >> 16) & 0x1F);
byte vs = (byte)((operation >> 11) & 0x1F);
byte vd = (byte)((operation >> 6) & 0x1F);
return opcode.ToString().ToLower() + " $v" + vd + ", $v" + vs + ", $v" + decodeVectorElement(vt, e);
}
private static string decodeMoveControlToFromCoprocessorOperation(string opcode, uint operation)
{
GP_REGISTER rt = (GP_REGISTER)((operation >> 16) & 0x1F);
byte rd = (byte)((operation >> 11) & 0x1F);
return opcode + " " + getGRPRegName(rt) + ", $v" + rd;
}
private static string decodeMoveToFromCoprocessorOperation(string opcode, uint operation)
{
GP_REGISTER rt = (GP_REGISTER)((operation >> 16) & 0x1F);
byte rd = (byte)((operation >> 11) & 0x1F);
byte e = (byte)((operation >> 7) & 0xF);
return opcode + " " + getGRPRegName(rt) + ", $v" + rd + "[" + e + "]";
}
private static string decodeCOP2Operation(uint operation)
{
if ((operation & 0x7FF) != 0)
return decodeVectorOperation(operation);
byte subop = (byte)((operation >> 21) & 0x1F);
switch (subop)
{
case 0x00: // MFC2 operation
return decodeMoveToFromCoprocessorOperation("mfc2", operation);
case 0x02: // CFC2 operation
return decodeMoveControlToFromCoprocessorOperation("cfc2", operation);
case 0x04: // MTC2 operation
return decodeMoveToFromCoprocessorOperation("mtc2", operation);
case 0x06: // CTC2 operation
return decodeMoveControlToFromCoprocessorOperation("ctc2", operation);
default:
return "Unimplemented (COP2 opcode: " + Convert.ToString(subop, 2) + "b)"; ;
}
}
private static string decodeNormalMIPSLoadStore(string opcode, uint operation)
{
GP_REGISTER dest = (GP_REGISTER)((operation >> 16) & 0x1F);
GP_REGISTER base_ = (GP_REGISTER)((operation >> 21) & 0x1F);
short imm = (short)(operation & 0xFFFF);
if (imm < 0)
opcode += " " + getGRPRegName(dest) + ", -0x" + (-imm).ToString("X4") + "(" + getGRPRegName(base_) + ")";
else
opcode += " " + getGRPRegName(dest) + ", 0x" + imm.ToString("X4") + "(" + getGRPRegName(base_) + ")";
return opcode;
}
private static string decodeCOP0Operation(uint operation)
{
string str = "Unimplemented (COP0 operation)";
byte mt = (byte)((operation >> 21) & 0x1F);
GP_REGISTER rt = (GP_REGISTER)((operation >> 16) & 0x1F);
CP0_REGISTER rd = (CP0_REGISTER)((operation >> 11) & 0x1F);
switch (mt)
{
case 0x00: // MFC0
str = "mfc0 " + getGRPRegName(rt) + ", " + getCP0RegName(rd);
break;
case 0x04: // MTC0
str = "mtc0 " + getGRPRegName(rt) + ", " + getCP0RegName(rd);
break;
}
return str;
}
private static string decodeOneRegisterWithImmediateOperation(string opcode, uint operation)
{
GP_REGISTER dest = (GP_REGISTER)((operation >> 16) & 0x1F);
return opcode + " " + getGRPRegName(dest) + ", 0x" + (operation & 0xFFFF).ToString("X4");
}
private static string decodeTwoRegistersWithImmediateOperation(string opcode, uint operation)
{
GP_REGISTER dest = (GP_REGISTER)((operation >> 16) & 0x1F);
GP_REGISTER src = (GP_REGISTER)((operation >> 21) & 0x1F);
short imm = (short)(operation & 0xFFFF);
if (imm < 0)
return opcode + " " + getGRPRegName(dest) + ", " + getGRPRegName(src) + ", -0x" + (-imm).ToString("X4");
else
return opcode + " " + getGRPRegName(dest) + ", " + getGRPRegName(src) + ", 0x" + imm.ToString("X4");
}
private static string decodeThreeRegisterOperation(string opcode, uint operation, bool swapRT_RS)
{
GP_REGISTER dest = (GP_REGISTER)((operation >> 11) & 0x1F);
GP_REGISTER src1 = (GP_REGISTER)((operation >> 21) & 0x1F);
GP_REGISTER src2 = (GP_REGISTER)((operation >> 16) & 0x1F);
if(!swapRT_RS)
return opcode + " " + getGRPRegName(dest) + ", " + getGRPRegName(src1) + ", " + getGRPRegName(src2);
else
return opcode + " " + getGRPRegName(dest) + ", " + getGRPRegName(src2) + ", " + getGRPRegName(src1);
}
private static string decodeBranchOperation(string opcode, uint operation, uint address)
{
GP_REGISTER src = (GP_REGISTER)((operation >> 21) & 0x1F);
short imm = (short)((operation & 0xFFFF) << 2);
uint current_offset = (uint)((address + 4) + imm);
return opcode + " " + getGRPRegName(src) + ", 0x" + (current_offset).ToString("X8");
}
private static string decodeBranchEqualsOperation(string opcode, uint operation, uint address)
{
GP_REGISTER src1 = (GP_REGISTER)((operation >> 21) & 0x1F);
GP_REGISTER src2 = (GP_REGISTER)((operation >> 16) & 0x1F);
short imm = (short)((operation & 0xFFFF) << 2);
//Console.WriteLine("("+address.ToString("X8")+")immediate = " + imm);
uint current_offset = (uint)((address + 4) + imm);
return opcode + " " + getGRPRegName(src1) + ", " + getGRPRegName(src2) + ", 0x" + current_offset.ToString("X8");
}
private static string decodeSpecialShiftOperation(string opcode, uint operation)
{
GP_REGISTER dest = (GP_REGISTER)((operation >> 11) & 0x1F);
GP_REGISTER src = (GP_REGISTER)((operation >> 16) & 0x1F);
int imm = (int)((operation >> 6) & 0x1F);
return opcode + " " + getGRPRegName(dest) + ", " + getGRPRegName(src) + ", " + imm;
}
public static string decodeOPERATION(uint operation, uint address, OPTIONS options)
{
if (operation == 0x00000000)
return "nop";
usingRegNames = options.HasFlag(OPTIONS.USE_GP_NAMES);
usingLongForm = options.HasFlag(OPTIONS.USE_LONG_FORM);
usingArmipsCP0Names = options.HasFlag(OPTIONS.USE_ARMIPS_CP0_NAMES);
RSP_OPCODE opcode = (RSP_OPCODE)((operation >> 26) & 0x3F);
string str = "Unimplemented (opcode: " + Convert.ToString((int)opcode, 2) + "b)";
switch (opcode)
{
case RSP_OPCODE.J:
case RSP_OPCODE.JAL:
str = opcode.ToString().ToLower() + " 0x0" + ((operation & 0x03FFFFFF) << 2).ToString("X7");
break;
case RSP_OPCODE.BEQ:
case RSP_OPCODE.BNE:
str = decodeBranchEqualsOperation(opcode.ToString().ToLower(), operation, address);
break;
case RSP_OPCODE.BLEZ:
case RSP_OPCODE.BGTZ:
str = decodeBranchOperation(opcode.ToString().ToLower(), operation, address);
break;
case RSP_OPCODE.ADDI:
case RSP_OPCODE.ADDIU:
case RSP_OPCODE.SLTI:
case RSP_OPCODE.SLTIU:
case RSP_OPCODE.ANDI:
case RSP_OPCODE.ORI:
case RSP_OPCODE.XORI:
str = decodeTwoRegistersWithImmediateOperation(opcode.ToString().ToLower(), operation);
break;
case RSP_OPCODE.LUI:
str = decodeOneRegisterWithImmediateOperation(opcode.ToString().ToLower(), operation);
break;
case RSP_OPCODE.COP0:
str = decodeCOP0Operation(operation);
break;
case RSP_OPCODE.COP2:
{
//str = "Vector operation!";
str = decodeCOP2Operation(operation);
}
break;
case RSP_OPCODE.LB:
case RSP_OPCODE.LH:
case RSP_OPCODE.LW:
case RSP_OPCODE.LBU:
case RSP_OPCODE.LHU:
case RSP_OPCODE.LWU:
case RSP_OPCODE.SB:
case RSP_OPCODE.SH:
case RSP_OPCODE.SW:
str = decodeNormalMIPSLoadStore(opcode.ToString().ToLower(), operation);
break;
case RSP_OPCODE.LWC2:
{
str = decodeLoadStoreOperation(operation, "l");
}
break;
case RSP_OPCODE.SWC2:
{
str = decodeLoadStoreOperation(operation, "s");
}
break;
case RSP_OPCODE.REGIMM:
{
byte subop = (byte)((operation >> 16) & 0x1F);
switch (subop)
{
case 0x00: // BLTZ operation
str = decodeBranchOperation("bltz", operation, address);
break;
case 0x01: // BGEZ operation
str = decodeBranchOperation("bgez", operation, address);
break;
case 0x10: // BLTZAL operation
str = decodeBranchOperation("bltzal", operation, address);
break;
case 0x11: // BGEZAL operation
str = decodeBranchOperation("bgezal", operation, address);
break;
}
}
break;
case RSP_OPCODE.SPECIAL:
{
byte subop = (byte)(operation & 0x3F);
switch (subop)
{
case 0x00: // SLL operation
str = decodeSpecialShiftOperation("sll", operation);
break;
case 0x02: // SRL operation
str = decodeSpecialShiftOperation("srl", operation);
break;
case 0x03: // SRA operation
str = decodeSpecialShiftOperation("sra", operation);
break;
case 0x04: // SLLV operation
str = decodeThreeRegisterOperation("sllv", operation, true);
break;
case 0x06: // SRLV operation
str = decodeThreeRegisterOperation("srlv", operation, true);
break;
case 0x07: // SRAV operation
str = decodeThreeRegisterOperation("srav", operation, true);
break;
case 0x08: // JR operation
str = "jr " + getGRPRegName(((GP_REGISTER)((operation >> 21) & 0x1F)));
break;
case 0x09: // JALR operation
{
GP_REGISTER return_reg = (GP_REGISTER)((operation >> 11) & 0x1F);
if(return_reg == GP_REGISTER.ra)
str = "jalr " + getGRPRegName(((GP_REGISTER)((operation >> 21) & 0x1F)));
else
str = "jalr " + getGRPRegName(return_reg) + ", " + getGRPRegName(((GP_REGISTER)((operation >> 21) & 0x1F)));
}
break;
case 0x0D: // BREAK operation
str = "break " + ((operation >> 6) & 0xFFFFF);
break;
case 0x20: // ADD operation
str = decodeThreeRegisterOperation("add", operation, false);
break;
case 0x21: // ADDU operation
str = decodeThreeRegisterOperation("addu", operation, false);
break;
case 0x22: // SUB operation
str = decodeThreeRegisterOperation("sub", operation, false);
break;
case 0x23: // SUBU operation
str = decodeThreeRegisterOperation("subu", operation, false);
break;
case 0x24: // AND operation
str = decodeThreeRegisterOperation("and", operation, false);
break;
case 0x25: // OR operation
str = decodeThreeRegisterOperation("or", operation, false);
break;
case 0x26: // XOR operation
str = decodeThreeRegisterOperation("xor", operation, false);
break;
case 0x27: // NOR operation
str = decodeThreeRegisterOperation("nor", operation, false);
break;
case 0x2A: // SLT operation
str = decodeThreeRegisterOperation("slt", operation, false);
break;
case 0x2B: // SLTU operation
str = decodeThreeRegisterOperation("sltu", operation, false);
break;
default:
str = "Unimplemented (special: " + Convert.ToString(subop, 2) + "b)";
break;
}
}
break;
}
return str;
}
}
}