aboutsummaryrefslogtreecommitdiff
path: root/include/opcode/maxq.h
blob: f4fcb30a80c61e85cafc05e01609a5a231379278 (plain)
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
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
/* maxq.h -- Header file for MAXQ opcode table.

   Copyright (C) 2004 Free Software Foundation, Inc.

   This file is part of GDB, GAS, and the GNU binutils.

   Written by Vineet Sharma(vineets@noida.hcltech.com)
   Inderpreet Singh (inderpreetb@noida.hcltech.com)

   GDB, GAS, and the GNU binutils are free software; you can redistribute
   them and/or modify them under the terms of the GNU General Public License
   as published by the Free Software Foundation; either version 2, or (at
   your option) any later version.

   GDB, GAS, and the GNU binutils are distributed in the hope that they 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 file; see the file COPYING.  If not, write to the Free Software
   Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */

#ifndef _MAXQ20_H_
#define  _MAXQ20_H_

/* This file contains the opcode table for the MAXQ10/20 processor. The table
   has been designed on the lines of the SH processor with the following 
   fields:
   (1) Instruction Name
   (2) Instruction arguments description
   (3) Description of the breakup of the opcode (1+7+8|8+8|1+4+4|1+7+1+3+4
       |1+3+4+1+3+4|1+3+4+8|1+1+2+4+8)  
   (4) Architecture supported

   The Register table is also defined. It contains the following fields
   (1) Register name
   (2) Module Number
   (3) Module Index
   (4) Opcode
   (5) Regtype

   The Memory access table is defined containing the various opcodes for 
   memory access containing the following fields
   (1) Memory access Operand Name
   (2) Memory access Operand opcode.  */

# define MAXQ10 0x0001
# define MAXQ20 0x0002
# define MAX    (MAXQ10 | MAXQ20)

/* This is for the NOP instruction Specify : 1st bit : NOP_FMT 1st byte:
   NOP_DST 2nd byte: NOP_SRC.  */
# define NOP_FMT  1
# define NOP_SRC  0x3A
# define NOP_DST  0x5A

typedef enum
{
  ZEROBIT = 0x1,		/* A zero followed by 3 bits.  */
  ONEBIT = 0x2,			/* A one followed by 3 bits.  */
  REG = 0x4,			/* Register.  */
  MEM = 0x8,			/* Memory access.  */
  IMM = 0x10,			/* Immediate value.  */
  DISP = 0x20,			/* Displacement value.  */
  BIT = 0x40,			/* Bit value.  */
  FMT = 0x80,			/* The format bit.  */
  IMMBIT = 0x100,		/* An immediate bit.  */
  FLAG = 0x200,			/* A Flag.  */
  DATA = 0x400,			/* Symbol in the data section.  */
  BIT_BUCKET = 0x800,		/* FOr BIT BUCKET.  */
}
UNKNOWN_OP;

typedef enum
{
  NO_ARG = 0,
  A_IMM = 0x01,			/* An 8 bit immediate value.  */
  A_REG = 0x2,			/* An 8 bit source register.  */
  A_MEM = 0x4,			/* A 7 bit destination register.  */
  FLAG_C = 0x8,			/* Carry Flag.  */
  FLAG_NC = 0x10,		/* No Carry (~C) flag.  */
  FLAG_Z = 0x20,		/* Zero Flag.  */
  FLAG_NZ = 0x40,		/* Not Zero Flag.  */
  FLAG_S = 0x80,		/* Sign Flag.  */
  FLAG_E = 0x100,		/* Equals Flag.  */
  FLAG_NE = 0x200,		/* Not Equal Flag.  */
  ACC_BIT = 0x400,		/* One of the 16 accumulator bits of the form Acc.<b>.  */
  DST_BIT = 0x800,		/* One of the 8 bits of the specified SRC.  */
  SRC_BIT = 0x1000,		/* One of the 8 bits of the specified source register.  */
  A_BIT_0 = 0x2000,		/* #0.  */
  A_BIT_1 = 0x4000,		/* #1.  */
  A_DISP = 0x8000,		/* Displacement Operand.  */
  A_DATA = 0x10000,		/* Data in the data section.  */
  A_BIT_BUCKET = 0x200000,
}
MAX_ARG_TYPE;

typedef struct
{
  char * name;			/* Name of the instruction.  */
  unsigned int op_number;	/* Operand Number or the number of operands.  */
  MAX_ARG_TYPE arg[2];		/* Types of operands.  */
  int format;			/* Format bit.  */
  int dst[2];			/* Destination in the move instruction.  */
  int src[2];			/* Source in the move instruction.  */
  int arch;			/* The Machine architecture.  */
  unsigned int instr_id;	/* Added for decode and dissassembly.  */
}
MAXQ20_OPCODE_INFO;

/* Structure for holding opcodes of the same name.  */
typedef struct
{
  const MAXQ20_OPCODE_INFO *start;	/* The first opcode.  */
  const MAXQ20_OPCODE_INFO *end;	/* The last opcode.  */
}
MAXQ20_OPCODES;

/* The entry into the hash table will be of the type MAXX_OPCODES.  */

/* The definition of the table.  */
const MAXQ20_OPCODE_INFO op_table[] =
{
  /* LOGICAL OPERATIONS */
  /* AND src : f001 1010 ssss ssss */
  {"AND", 1, {A_IMM | A_REG | A_MEM | A_DISP, 0}, FMT, {0x1a, 0},
   {REG | MEM | IMM | DISP, 0}, MAX, 0x11},
  /* AND Acc.<b> : 1111 1010 bbbb 1010 */
  {"AND", 1, {ACC_BIT, 0}, 1, {0x1a, 0}, {BIT, 0xa}, MAX, 0x39},
  /* OR src : f010 1010 ssss ssss */
  {"OR", 1, {A_IMM | A_REG | A_MEM | A_DISP, 0}, FMT, {0x2a, 0},
   {REG | MEM | IMM | DISP, 0}, MAX, 0x12},
  /* OR Acc.<b> : 1010 1010 bbbb 1010 */
  {"OR", 1, {ACC_BIT, 0}, 1, {0x2a, 0}, {BIT, 0xa}, MAX, 0x3A},
  /* XOR src : f011 1010 ssss ssss */
  {"XOR", 1, {A_IMM | A_REG | A_MEM | A_DISP, 0}, FMT, {0x3a, 0},
   {REG | MEM | IMM | DISP, 0}, MAX, 0x13},
  /* XOR Acc.<b> : 1011 1010 bbbb 1010 */
  {"XOR", 1, {ACC_BIT, 0}, 1, {0x3a, 0}, {BIT, 0xa}, MAX, 0x3B},
  /* LOGICAL OPERATIONS INVOLVING ONLY THE ACCUMULATOR */
  /* CPL : 1000 1010 0001 1010 */
  {"CPL", 0, {0, 0}, 1, {0x0a, 0}, {0x1a, 0}, MAX, 0x21},
  /* CPL C : 1101 1010 0010 1010 */
  {"CPL", 1, {FLAG_C, 0}, 1, {0x5a, 0}, {0x2a, 0}, MAX, 0x3D},
  /* NEG : 1000 1010 1001 1010 */
  {"NEG", 0, {0, 0}, 1, {0x0a, 0}, {0x9a, 0}, MAX, 0x29},
  /* SLA : 1000 1010 0010 1010 */
  {"SLA", 0, {0, 0}, 1, {0x0a, 0}, {0x2a, 0}, MAX, 0x22},
  /* SLA2: 1000 1010 0011 1010 */
  {"SLA2", 0, {0, 0}, 1, {0x0a, 0}, {0x3a, 0}, MAX, 0x23},
  /* SLA4: 1000 1010 0110 1010 */
  {"SLA4", 0, {0, 0}, 1, {0x0a, 0}, {0x6a, 0}, MAX, 0x26},
  /* RL : 1000 1010 0100 1010 */
  {"RL", 0, {0, 0}, 1, {0x0a, 0}, {0x4a, 0}, MAX, 0x24},
  /* RLC : 1000 1010 0101 1010 */
  {"RLC", 0, {0, 0}, 1, {0x0a, 0}, {0x5a, 0}, MAX, 0x25},
  /* SRA : 1000 1010 1111 1010 */
  {"SRA", 0, {0, 0}, 1, {0x0a, 0}, {0xfa, 0}, MAX, 0x2F},
  /* SRA2: 1000 1010 1110 1010 */
  {"SRA2", 0, {0, 0}, 1, {0x0a, 0}, {0xea, 0}, MAX, 0x2E},
  /* SRA4: 1000 1010 1011 1010 */
  {"SRA4", 0, {0, 0}, 1, {0x0a, 0}, {0xba, 0}, MAX, 0x2B},
  /* SR : 1000 1010 1010 1010 */
  {"SR", 0, {0, 0}, 1, {0x0a, 0}, {0xaa, 0}, MAX, 0x2A},
  /* RR : 1000 1010 1100 1010 */
  {"RR", 0, {0, 0}, 1, {0x0a, 0}, {0xca, 0}, MAX, 0x2C},
  /* RRC : 1000 1010 1101 1010 */
  {"RRC", 0, {0, 0}, 1, {0x0a, 0}, {0xda, 0}, MAX, 0x2D},
  /* MATH OPERATIONS */
  /* ADD src : f100 1010 ssss ssss */
  {"ADD", 1, {A_IMM | A_REG | A_MEM | A_DISP, 0}, FMT, {0x4a, 0},
   {IMM | REG | MEM | DISP, 0}, MAX, 0x14},
  /* ADDC src : f110 1010 ssss ssss */
  {"ADDC", 1, {A_IMM | A_REG | A_MEM | A_DISP, 0}, FMT, {0x6a, 0},
   {IMM | REG | MEM | DISP, 0}, MAX, 0x16},
  /* SUB src : f101 1010 ssss ssss */
  {"SUB", 1, {A_IMM | A_REG | A_MEM | A_DISP, 0}, FMT, {0x5a, 0},
   {IMM | REG | MEM | DISP, 0}, MAX, 0x15},
  /* SUBB src : f111 1010 ssss ssss */
  {"SUBB", 1, {A_IMM | A_REG | A_MEM | A_DISP, 0}, FMT, {0x7a, 0},
   {IMM | REG | MEM | DISP, 0}, MAX, 0x17},
  /* BRANCHING OPERATIONS */

  /* DJNZ LC[0] src: f100 1101 ssss ssss */
  {"DJNZ", 2, {A_REG, A_IMM | A_REG | A_MEM | A_DISP}, FMT, {0x4d, 0},
   {IMM | REG | MEM | DISP, 0}, MAX, 0xA4},
  /* DJNZ LC[1] src: f101 1101 ssss ssss */
  {"DJNZ", 2, {A_REG, A_IMM | A_REG | A_MEM | A_DISP}, FMT, {0x5d, 0},
   {IMM | REG | MEM | DISP, 0}, MAX, 0xA5},
  /* CALL src : f011 1101 ssss ssss */
  {"CALL", 1, {A_IMM | A_REG | A_MEM | A_DISP, 0}, FMT, {0x3d, 0},
   {IMM | REG | MEM | DISP, 0}, MAX, 0xA3},
  /* JUMP src : f000 1100 ssss ssss */
  {"JUMP", 1, {A_IMM | A_REG | A_MEM | A_DISP, 0}, FMT, {0x0c, 0},
   {IMM | REG | MEM | DISP, 0}, MAX, 0x50},
  /* JUMP C,src : f010 1100 ssss ssss */
  {"JUMP", 2, {FLAG_C, A_IMM | A_REG | A_MEM | A_DISP}, FMT, {0x2c, 0},
   {IMM | REG | MEM | DISP, 0}, MAX, 0x52},
  /* JUMP NC,src: f110 1100 ssss ssss */
  {"JUMP", 2, {FLAG_NC, A_IMM | A_REG | A_MEM | A_DISP}, FMT, {0x6c, 0},
   {IMM | REG | MEM | DISP, 0}, MAX, 0x56},
  /* JUMP Z,src : f001 1100 ssss ssss */
  {"JUMP", 2, {FLAG_Z, A_IMM | A_REG | A_MEM | A_DISP}, FMT, {0x1c, 0},
   {IMM | REG | MEM | DISP, 0}, MAX, 0x51},
  /* JUMP NZ,src: f101 1100 ssss ssss */
  {"JUMP", 2, {FLAG_NZ, A_IMM | A_REG | A_MEM | A_DISP}, FMT, {0x5c, 0},
   {IMM | REG | MEM | DISP, 0}, MAX, 0x55},
  /* JUMP E,src : 0011 1100 ssss ssss */
  {"JUMP", 2, {FLAG_E, A_IMM | A_DISP}, 0, {0x3c, 0}, {IMM, 0}, MAX, 0x53},
  /* JUMP NE,src: 0111 1100 ssss ssss */
  {"JUMP", 2, {FLAG_NE, A_IMM | A_DISP}, 0, {0x7c, 0}, {IMM, 0}, MAX, 0x57},
  /* JUMP S,src : f100 1100 ssss ssss */
  {"JUMP", 2, {FLAG_S, A_IMM | A_REG | A_MEM | A_DISP}, FMT, {0x4c, 0},
   {IMM | REG | MEM | DISP, 0}, MAX, 0x54},
  /* RET : 1000 1100 0000 1101 */
  {"RET", 0, {0, 0}, 1, {0x0c, 0}, {0x0d, 0}, MAX, 0x68},
  /* RET C : 1010 1100 0000 1101 */
  {"RET", 1, {FLAG_C, 0}, 1, {0x2c, 0}, {0x0d, 0}, MAX, 0x6A},
  /* RET NC : 1110 1100 0000 1101 */
  {"RET", 1, {FLAG_NC, 0}, 1, {0x6c, 0}, {0x0d, 0}, MAX, 0x6E},
  /* RET Z : 1001 1100 0000 1101 */
  {"RET", 1, {FLAG_Z, 0}, 1, {0x1c, 0}, {0x0d, 0}, MAX, 0x69},
  /* RET NZ : 1101 1100 0000 1101 */
  {"RET", 1, {FLAG_NZ, 0}, 1, {0x5c, 0}, {0x0d, 0}, MAX, 0x6D},
  /* RET S : 1100 1100 0000 1101 */
  {"RET", 1, {FLAG_S, 0}, 1, {0x4c, 0}, {0x0d, 0}, MAX, 0x6C},
  /* RETI : 1000 1100 1000 1101 */
  {"RETI", 0, {0, 0}, 1, {0x0c, 0}, {0x8d, 0}, MAX, 0x78},
  /* ADDED ACCORDING TO NEW SPECIFICATION */

  /* RETI C : 1010 1100 1000 1101 */
  {"RETI", 1, {FLAG_C, 0}, 1, {0x2c, 0}, {0x8d, 0}, MAX, 0x7A},
  /* RETI NC : 1110 1100 1000 1101 */
  {"RETI", 1, {FLAG_NC, 0}, 1, {0x6c, 0}, {0x8d, 0}, MAX, 0x7E},
  /* RETI Z : 1001 1100 1000 1101 */
  {"RETI", 1, {FLAG_Z, 0}, 1, {0x1c, 0}, {0x8d, 0}, MAX, 0x79},
  /* RETI NZ : 1101 1100 1000 1101 */
  {"RETI", 1, {FLAG_NZ, 0}, 1, {0x5c, 0}, {0x8d, 0}, MAX, 0x7D},
  /* RETI S : 1100 1100 1000 1101 */
  {"RETI", 1, {FLAG_S, 0}, 1, {0x4c, 0}, {0x8d, 0}, MAX, 0x7C},
  /* MISCELLANEOUS INSTRUCTIONS */
  /* CMP src : f111 1000 ssss ssss */
  {"CMP", 1, {A_REG | A_IMM | A_MEM | A_DISP, 0}, FMT, {0x78, 0},
   {REG | MEM | IMM | DISP, 0}, MAX, 0xD7},
  /* DATA TRANSFER OPERATIONS */
  /* XCH : 1000 1010 1000 1010 */
  {"XCH", 0, {0, 0}, 1, {0x0a, 0}, {0x8a, 0}, MAXQ20, 0x28},
  /* XCHN : 1000 1010 0111 1010 */
  {"XCHN", 0, {0, 0}, 1, {0x0a, 0}, {0x7a, 0}, MAX, 0x27},
  /* PUSH src : f000 1101 ssss ssss */
  {"PUSH", 1, {A_REG | A_IMM | A_MEM | A_DISP, 0}, FMT, {0x0d, 0},
   {IMM | REG | MEM | DISP, 0}, MAX, 0xA0},
  /* POP dst : 1ddd dddd 0000 1101 */
  {"POP", 1, {A_REG, 0}, 1, {REG, 0}, {0x0d, 0}, MAX, 0xB0},
  /* Added according to new spec */
  /* POPI dst : 1ddd dddd 1000 1101 */
  {"POPI", 1, {A_REG, 0}, 1, {REG, 0}, {0x8d, 0}, MAX, 0xC0},
  /* MOVE dst,src: fddd dddd ssss ssss */
  {"MOVE", 2, {A_REG | A_MEM, A_REG | A_IMM | A_MEM | A_DATA | A_DISP}, FMT,
   {REG | MEM, 0}, {REG | IMM | MEM | DATA | A_DISP, 0}, MAX, 0x80},
  /* BIT OPERATIONS */
  /* MOVE C,Acc.<b> : 1110 1010 bbbb 1010 */
  {"MOVE", 2, {FLAG_C, ACC_BIT}, 1, {0x6a, 0}, {BIT, 0xa}, MAX, 0x3E},
  /* MOVE C,#0 : 1101 1010 0000 1010 */
  {"MOVE", 2, {FLAG_C, A_BIT_0}, 1, {0x5a, 0}, {0x0a, 0}, MAX, 0x3D},
  /* MOVE C,#1 : 1101 1010 0001 1010 */
  {"MOVE", 2, {FLAG_C, A_BIT_1}, 1, {0x5a, 0}, {0x1a, 0}, MAX, 0x3D},
  /* MOVE Acc.<b>,C : 1111 1010 bbbb 1010 */
  {"MOVE", 2, {ACC_BIT, FLAG_C}, 1, {0x7a, 0}, {BIT, 0xa}, MAX, 0x3F},
  /* MOVE dst.<b>,#0 : 1ddd dddd 0bbb 0111 */
  {"MOVE", 2, {DST_BIT, A_BIT_0}, 1, {REG, 0}, {ZEROBIT, 0x7}, MAX, 0x40},
  /* MOVE dst.<b>,#1 : 1ddd dddd 1bbb 0111 */
  {"MOVE", 2, {DST_BIT, A_BIT_1}, 1, {REG, 0}, {ONEBIT, 0x7}, MAX, 0x41},
  /* MOVE C,src.<b> : fbbb 0111 ssss ssss */
  {"MOVE", 2, {FLAG_C, SRC_BIT}, FMT, {BIT, 0x7}, {REG, 0}, MAX, 0x97},
  /* NOP : 1101 1010 0011 1010 */
  {"NOP", 0, {0, 0}, NOP_FMT, {NOP_DST, 0}, {NOP_SRC, 0}, MAX, 0x3D},
  {NULL, 0, {0, 0}, 0, {0, 0}, {0, 0}, 0, 0x00}
};

/* All the modules.  */

#define	MOD0 0x0
#define MOD1 0x1
#define MOD2 0x2
#define MOD3 0x3
#define MOD4 0x4
#define MOD5 0x5
#define MOD6 0x6
#define MOD7 0x7
#define MOD8 0x8
#define MOD9 0x9
#define MODA 0xa
#define MODB 0xb
#define MODC 0xc
#define MODD 0xd
#define MODE 0xe
#define MODF 0xf

/* Added according to new specification.  */
#define MOD10 0x10
#define MOD11 0x11
#define MOD12 0x12
#define MOD13 0x13
#define MOD14 0x14
#define MOD15 0x15
#define MOD16 0x16
#define MOD17 0x17
#define MOD18 0x18
#define MOD19 0x19
#define MOD1A 0x1a
#define MOD1B 0x1b
#define MOD1C 0x1c
#define MOD1D 0x1d
#define MOD1E 0x1e
#define MOD1F 0x1f

/* - Peripheral Register Modules - */
/* Serial Register Modules.  */
#define CTRL		MOD8	/* For the module containing the control registers.  */
#define ACC	 	MOD9	/* For the module containing the 16 accumulators.  */
#define Act_ACC 	MODA	/* For the module containing the active accumulator.  */
#define PFX  		MODB	/* For the module containing the prefix registers.  */
#define IP	 	MODC	/* For the module containing the instruction pointer register.  */
#define SPIV 		MODD	/* For the module containing the stack pointer and the interrupt vector.  */
#define	LC 		MODD	/* For the module containing the loop counters and HILO registers.  */
#define DP 		MODF	/* For the module containig the data pointer registers.  */

/* Register Types.  */
typedef enum _Reg_type
{ Reg_8R,			/* 8 bit register. read only.  */
  Reg_16R,			/* 16 bit register, read only.  */
  Reg_8W,			/* 8 bit register, both read and write.  */
  Reg_16W			/* 16 bit register, both read and write.  */
}
Reg_type;

/* Register Structure.  */
typedef struct reg
{
  char *reg_name;		/* Register name.  */
  short int Mod_name;		/* The module name.  */
  short int Mod_index;		/* The module index.  */
  int opcode;			/* The opcode of the register.  */
  Reg_type rtype;		/* 8 bit/16 bit and read only/read write.  */
  int arch;			/* The Machine architecture.  */
}
reg_entry;

reg_entry *new_reg_table = NULL;
int num_of_reg = 0;

typedef struct
{
  char *rname;
  int rindex;
}
reg_index;

/* Register Table description.  */
reg_entry system_reg_table[] =
{
  /* Serial Registers */
  /* MODULE 8 Registers : I call them the control registers.  */
  /* Accumulator Pointer CTRL[0h] */
  {
   "AP", CTRL, 0x0, 0x00 | CTRL, Reg_8W, MAX},
  /* Accumulator Pointer Control Register : CTRL[1h] */

  {
   "APC", CTRL, 0x1, 0x10 | CTRL, Reg_8W, MAX},
  /* Processor Status Flag Register CTRL[4h] Note: Bits 6 and 7 read only */
  {
   "PSF", CTRL, 0x4, 0x40 | CTRL, Reg_8W, MAX},
  /* Interrupt and Control Register : CTRL[5h] */
  {
   "IC", CTRL, 0x5, 0x50 | CTRL, Reg_8W, MAX},
  /* Interrupt Mask Register : CTRL[6h] */
  {
   "IMR", CTRL, 0x6, 0x60 | CTRL, Reg_8W, MAX},
  /* Interrupt System Control : CTRL[8h] */
  {
   "SC", CTRL, 0x8, 0x80 | CTRL, Reg_8W, MAX},
  /* Interrupt Identification Register : CTRL[Bh] */
  {
   "IIR", CTRL, 0xb, 0xb0 | CTRL, Reg_8R, MAX},
  /* System Clock Control Register : CTRL[Eh] Note: Bit 5 is read only */
  {
   "CKCN", CTRL, 0xe, 0xe0 | CTRL, Reg_8W, MAX},
  /* Watchdog Control Register : CTRL[Fh] */
  {
   "WDCN", CTRL, 0xf, 0xf0 | CTRL, Reg_8W, MAX},
  /* The 16 accumulator registers : ACC[0h-Fh] */
  {
   "A[0]", ACC, 0x0, 0x00 | ACC, Reg_16W, MAXQ20},
  {
   "A[1]", ACC, 0x1, 0x10 | ACC, Reg_16W, MAXQ20},
  {
   "A[2]", ACC, 0x2, 0x20 | ACC, Reg_16W, MAXQ20},
  {
   "A[3]", ACC, 0x3, 0x30 | ACC, Reg_16W, MAXQ20},
  {
   "A[4]", ACC, 0x4, 0x40 | ACC, Reg_16W, MAXQ20},
  {
   "A[5]", ACC, 0x5, 0x50 | ACC, Reg_16W, MAXQ20},
  {
   "A[6]", ACC, 0x6, 0x60 | ACC, Reg_16W, MAXQ20},
  {
   "A[7]", ACC, 0x7, 0x70 | ACC, Reg_16W, MAXQ20},
  {
   "A[8]", ACC, 0x8, 0x80 | ACC, Reg_16W, MAXQ20},
  {
   "A[9]", ACC, 0x9, 0x90 | ACC, Reg_16W, MAXQ20},
  {
   "A[10]", ACC, 0xa, 0xa0 | ACC, Reg_16W, MAXQ20},
  {
   "A[11]", ACC, 0xb, 0xb0 | ACC, Reg_16W, MAXQ20},
  {
   "A[12]", ACC, 0xc, 0xc0 | ACC, Reg_16W, MAXQ20},
  {
   "A[13]", ACC, 0xd, 0xd0 | ACC, Reg_16W, MAXQ20},
  {
   "A[14]", ACC, 0xe, 0xe0 | ACC, Reg_16W, MAXQ20},
  {
   "A[15]", ACC, 0xf, 0xf0 | ACC, Reg_16W, MAXQ20},
  /* The Active Accumulators : Act_Acc[0h-1h] */
  {
   "ACC", Act_ACC, 0x0, 0x00 | Act_ACC, Reg_16W, MAXQ20},
  {
   "A[AP]", Act_ACC, 0x1, 0x10 | Act_ACC, Reg_16W, MAXQ20},
  /* The 16 accumulator registers : ACC[0h-Fh] */
  {
   "A[0]", ACC, 0x0, 0x00 | ACC, Reg_8W, MAXQ10},
  {
   "A[1]", ACC, 0x1, 0x10 | ACC, Reg_8W, MAXQ10},
  {
   "A[2]", ACC, 0x2, 0x20 | ACC, Reg_8W, MAXQ10},
  {
   "A[3]", ACC, 0x3, 0x30 | ACC, Reg_8W, MAXQ10},
  {
   "A[4]", ACC, 0x4, 0x40 | ACC, Reg_8W, MAXQ10},
  {
   "A[5]", ACC, 0x5, 0x50 | ACC, Reg_8W, MAXQ10},
  {
   "A[6]", ACC, 0x6, 0x60 | ACC, Reg_8W, MAXQ10},
  {
   "A[7]", ACC, 0x7, 0x70 | ACC, Reg_8W, MAXQ10},
  {
   "A[8]", ACC, 0x8, 0x80 | ACC, Reg_8W, MAXQ10},
  {
   "A[9]", ACC, 0x9, 0x90 | ACC, Reg_8W, MAXQ10},
  {
   "A[10]", ACC, 0xa, 0xa0 | ACC, Reg_8W, MAXQ10},
  {
   "A[11]", ACC, 0xb, 0xb0 | ACC, Reg_8W, MAXQ10},
  {
   "A[12]", ACC, 0xc, 0xc0 | ACC, Reg_8W, MAXQ10},
  {
   "A[13]", ACC, 0xd, 0xd0 | ACC, Reg_8W, MAXQ10},
  {
   "A[14]", ACC, 0xe, 0xe0 | ACC, Reg_8W, MAXQ10},
  {
   "A[15]", ACC, 0xf, 0xf0 | ACC, Reg_8W, MAXQ10},
  /* The Active Accumulators : Act_Acc[0h-1h] */
  {
   "A[AP]", Act_ACC, 0x1, 0x10 | Act_ACC, Reg_8W, MAXQ10},
  /* The Active Accumulators : Act_Acc[0h-1h] */
  {
   "ACC", Act_ACC, 0x0, 0x00 | Act_ACC, Reg_8W, MAXQ10},
  /* The Prefix Registers : PFX[0h,2h] */
  {
   "PFX[0]", PFX, 0x0, 0x00 | PFX, Reg_16W, MAX},
  {
   "PFX[1]", PFX, 0x1, 0x10 | PFX, Reg_16W, MAX},
  {
   "PFX[2]", PFX, 0x2, 0x20 | PFX, Reg_16W, MAX},
  {
   "PFX[3]", PFX, 0x3, 0x30 | PFX, Reg_16W, MAX},
  {
   "PFX[4]", PFX, 0x4, 0x40 | PFX, Reg_16W, MAX},
  {
   "PFX[5]", PFX, 0x5, 0x50 | PFX, Reg_16W, MAX},
  {
   "PFX[6]", PFX, 0x6, 0x60 | PFX, Reg_16W, MAX},
  {
   "PFX[7]", PFX, 0x7, 0x70 | PFX, Reg_16W, MAX},
  /* The Instruction Pointer Registers : IP[0h,8h] */
  {
   "IP", IP, 0x0, 0x00 | IP, Reg_16W, MAX},
  /* The Stack Pointer Registers : SPIV[1h,9h] */
  {
   "SP", SPIV, 0x1, 0x10 | SPIV, Reg_16W, MAX},
  /* The Interrupt Vector Registers : SPIV[2h,Ah] */
  {
   "IV", SPIV, 0x2, 0x20 | SPIV, Reg_16W, MAX},
  /* ADDED for New Specification */

  /* The Loop Counter Registers : LCHILO[0h-4h,8h-Bh] */
  {
   "LC[0]", LC, 0x6, 0x60 | LC, Reg_16W, MAX},
  {
   "LC[1]", LC, 0x7, 0x70 | LC, Reg_16W, MAX},
  /* MODULE Eh Whole Column has changed */

  {
   "OFFS", MODE, 0x3, 0x30 | MODE, Reg_8W, MAX},
  {
   "DPC", MODE, 0x4, 0x40 | MODE, Reg_16W, MAX},
  {
   "GR", MODE, 0x5, 0x50 | MODE, Reg_16W, MAX},
  {
   "GRL", MODE, 0x6, 0x60 | MODE, Reg_8W, MAX},
  {
   "BP", MODE, 0x7, 0x70 | MODE, Reg_16W, MAX},
  {
   "GRS", MODE, 0x8, 0x80 | MODE, Reg_16W, MAX},
  {
   "GRH", MODE, 0x9, 0x90 | MODE, Reg_8W, MAX},
  {
   "GRXL", MODE, 0xA, 0xA0 | MODE, Reg_8R, MAX},
  {
   "FP", MODE, 0xB, 0xB0 | MODE, Reg_16R, MAX},
  /* The Data Pointer registers : DP[3h,7h,Bh,Fh] */
  {
   "DP[0]", DP, 0x3, 0x30 | DP, Reg_16W, MAX},
  {
   "DP[1]", DP, 0x7, 0x70 | DP, Reg_16W, MAX},
};
typedef struct
{
  char *name;
  int type;
}
match_table;

#define GPIO0   	0x00	/* Gerneral Purpose I/O Module 0.  */
#define GPIO1   	0x01	/* Gerneral Purpose I/O Module 1.  */
#define RTC	  	0x00	/* Real Time Clock Module.  */
#define MAC	  	0x02	/* Hardware Multiplier Module.  */
#define SER0	  	0x02	/* Contains the UART Registers.  */
#define SPI	  	0x03	/* Serial Pheripheral Interface Module.  */
#define OWBM  		0x03	/* One Wire Bus Module.  */
#define SER1	  	0x03	/* Contains the UART Registers.  */
#define TIMER20		0x03	/* Timer Counter Module 2.  */
#define TIMER21		0x04	/* Timer Counter Module 2.  */
#define JTAGD 		0x03	/* In-Circuit Debugging Support.  */
#define LCD		0x03	/* LCD register Modules.  */

/* Plugable modules register table f.  */

reg_entry peripheral_reg_table[] =
{
  /* -------- The GPIO Module Registers -------- */
  /* Port n Output Registers : GPIO[0h-4h] */
  {
   "PO0", GPIO0, 0x0, 0x00 | MOD0, Reg_8W, MAX},
  {
   "PO1", GPIO0, 0x1, 0x10 | MOD0, Reg_8W, MAX},
  {
   "PO2", GPIO0, 0x2, 0x20 | MOD0, Reg_8W, MAX},
  {
   "PO3", GPIO0, 0x3, 0x30 | MOD0, Reg_8W, MAX},
  /* External Interrupt Flag Register : GPIO[6h] */
  {
   "EIF0", GPIO0, 0x6, 0x60 | MOD0, Reg_8W, MAX},
  /* External Interrupt Enable Register : GPIO[7h] */
  {
   "EIE0", GPIO0, 0x7, 0x70 | MOD0, Reg_8W, MAX},
  /* Port n Input Registers : GPIO[8h-Bh] */
  {
   "PI0", GPIO0, 0x8, 0x80 | MOD0, Reg_8W, MAX},
  {
   "PI1", GPIO0, 0x9, 0x90 | MOD0, Reg_8W, MAX},
  {
   "PI2", GPIO0, 0xa, 0xa0 | MOD0, Reg_8W, MAX},
  {
   "PI3", GPIO0, 0xb, 0xb0 | MOD0, Reg_8W, MAX},
  {
   "EIES0", GPIO0, 0xc, 0xc0 | MOD0, Reg_8W, MAX},
  /* Port n Direction Registers : GPIO[Ch-Fh] */
  {
   "PD0", GPIO0, 0x10, 0x10 | MOD0, Reg_8W, MAX},
  {
   "PD1", GPIO0, 0x11, 0x11 | MOD0, Reg_8W, MAX},
  {
   "PD2", GPIO0, 0x12, 0x12 | MOD0, Reg_8W, MAX},
  {
   "PD3", GPIO0, 0x13, 0x13 | MOD0, Reg_8W, MAX},
  /* -------- Real Time Counter Module RTC -------- */
  /* RTC Control Register : [01h] */
  {
   "RCNT", RTC, 0x19, 0x19 | MOD0, Reg_16W, MAX},
  /* RTC Seconds High [02h] */
  {
   "RTSS", RTC, 0x1A, 0x1A | MOD0, Reg_8W, MAX},
  /* RTC Seconds Low [03h] */
  {
   "RTSH", RTC, 0x1b, 0x1b | MOD0, Reg_16W, MAX},
  /* RTC Subsecond Register [04h] */
  {
   "RTSL", RTC, 0x1C, 0x1C | MOD0, Reg_16W, MAX},
  /* RTC Alarm seconds high [05h] */
  {
   "RSSA", RTC, 0x1D, 0x1D | MOD0, Reg_8W, MAX},
  /* RTC Alarm seconds high [06h] */
  {
   "RASH", RTC, 0x1E, 0x1E | MOD0, Reg_8W, MAX},
  /* RTC Subsecond Alarm Register [07h] */
  {
   "RASL", RTC, 0x1F, 0x1F | MOD0, Reg_16W, MAX},
  /* -------- The GPIO Module Registers -------- */
  /* Port n Output Registers : GPIO[0h-4h] */
  {
   "PO4", GPIO1, 0x0, 0x00 | MOD1, Reg_8W, MAX},
  {
   "PO5", GPIO1, 0x1, 0x10 | MOD1, Reg_8W, MAX},
  {
   "PO6", GPIO1, 0x2, 0x20 | MOD1, Reg_8W, MAX},
  {
   "PO7", GPIO1, 0x3, 0x30 | MOD1, Reg_8W, MAX},
  /* External Interrupt Flag Register : GPIO[6h] */
  {
   "EIF1", GPIO0, 0x6, 0x60 | MOD1, Reg_8W, MAX},
  /* External Interrupt Enable Register : GPIO[7h] */
  {
   "EIE1", GPIO0, 0x7, 0x70 | MOD1, Reg_8W, MAX},
  /* Port n Input Registers : GPIO[8h-Bh] */
  {
   "PI4", GPIO1, 0x8, 0x80 | MOD1, Reg_8W, MAX},
  {
   "PI5", GPIO1, 0x9, 0x90 | MOD1, Reg_8W, MAX},
  {
   "PI6", GPIO1, 0xa, 0xa0 | MOD1, Reg_8W, MAX},
  {
   "PI7", GPIO1, 0xb, 0xb0 | MOD1, Reg_8W, MAX},
  {
   "EIES1", GPIO1, 0xc, 0xc0 | MOD1, Reg_8W, MAX},
  /* Port n Direction Registers : GPIO[Ch-Fh] */
  {
   "PD4", GPIO1, 0x10, 0x10 | MOD1, Reg_8W, MAX},
  {
   "PD5", GPIO1, 0x11, 0x11 | MOD1, Reg_8W, MAX},
  {
   "PD6", GPIO1, 0x12, 0x12 | MOD1, Reg_8W, MAX},
  {
   "PD7", GPIO1, 0x13, 0x13 | MOD1, Reg_8W, MAX},
#if 0
  /* Supply Boltage Check Register */
  {
   "SVS", GPIO1, 0x1e, 0x1e | GPIO1, Reg_8W, MAX},
  /* Wake up output register */
  {
   "WK0", GPIO1, 0x1f, 0x1f | GPIO1, Reg_8W, MAX},
#endif /* */

  /* -------- MAC Hardware multiplier module -------- */
  /* MAC Hardware Multiplier control register: [01h] */
  {
   "MCNT", MAC, 0x1, 0x10 | MOD2, Reg_8W, MAX},
  /* MAC Multiplier Operand A Register [02h] */
  {
   "MA", MAC, 0x2, 0x20 | MOD2, Reg_16W, MAX},
  /* MAC Multiplier Operand B Register [03h] */
  {
   "MB", MAC, 0x3, 0x30 | MOD2, Reg_16W, MAX},
  /* MAC Multiplier Accumulator 2 Register [04h] */
  {
   "MC2", MAC, 0x4, 0x40 | MOD2, Reg_16W, MAX},
  /* MAC Multiplier Accumulator 1 Register [05h] */
  {
   "MC1", MAC, 0x5, 0x50 | MOD2, Reg_16W, MAX},
  /* MAC Multiplier Accumulator 0 Register [06h] */
  {
   "MC0", MAC, 0x6, 0x60 | MOD2, Reg_16W, MAX},
  /* -------- The Serial I/O module SER -------- */
  /* UART registers */
  /* Serial Port Control Register : SER[6h] */
  {
   "SCON0", SER0, 0x6, 0x60 | MOD2, Reg_8W, MAX},
  /* Serial Data Buffer Register : SER[7h] */
  {
   "SBUF0", SER0, 0x7, 0x70 | MOD2, Reg_8W, MAX},
  /* Serial Port Mode Register : SER[4h] */
  {
   "SMD0", SER0, 0x8, 0x80 | MOD2, Reg_8W, MAX},
  /* Serial Port Phase Register : SER[4h] */
  {
   "PR0", SER1, 0x9, 0x90 | MOD2, Reg_16W, MAX},
  /* ------ LCD Display Module ---------- */
  {
   "LCRA", LCD, 0xd, 0xd0 | MOD2, Reg_16W, MAX},
  {
   "LCFG", LCD, 0xe, 0xe0 | MOD2, Reg_8W, MAX},
  {
   "LCD16", LCD, 0xf, 0xf0 | MOD2, Reg_8W, MAX},
  {
   "LCD0", LCD, 0x10, 0x10 | MOD2, Reg_8W, MAX},
  {
   "LCD1", LCD, 0x11, 0x11 | MOD2, Reg_8W, MAX},
  {
   "LCD2", LCD, 0x12, 0x12 | MOD2, Reg_8W, MAX},
  {
   "LCD3", LCD, 0x13, 0x13 | MOD2, Reg_8W, MAX},
  {
   "LCD4", LCD, 0x14, 0x14 | MOD2, Reg_8W, MAX},
  {
   "LCD5", LCD, 0x15, 0x15 | MOD2, Reg_8W, MAX},
  {
   "LCD6", LCD, 0x16, 0x16 | MOD2, Reg_8W, MAX},
  {
   "LCD7", LCD, 0x17, 0x17 | MOD2, Reg_8W, MAX},
  {
   "LCD8", LCD, 0x18, 0x18 | MOD2, Reg_8W, MAX},
  {
   "LCD9", LCD, 0x19, 0x19 | MOD2, Reg_8W, MAX},
  {
   "LCD10", LCD, 0x1a, 0x1a | MOD2, Reg_8W, MAX},
  {
   "LCD11", LCD, 0x1b, 0x1b | MOD2, Reg_8W, MAX},
  {
   "LCD12", LCD, 0x1c, 0x1c | MOD2, Reg_8W, MAX},
  {
   "LCD13", LCD, 0x1d, 0x1d | MOD2, Reg_8W, MAX},
  {
   "LCD14", LCD, 0x1e, 0x1e | MOD2, Reg_8W, MAX},
  {
   "LCD15", LCD, 0x1f, 0x1f | MOD2, Reg_8W, MAX},
  /* -------- SPI registers -------- */
  /* SPI data buffer Register : SER[7h] */
  {
   "SPIB", SPI, 0x5, 0x50 | MOD3, Reg_16W, MAX},
  /* SPI Control Register : SER[8h] Note : Bit 7 is a read only bit */
  {
   "SPICN", SPI, 0x15, 0x15 | MOD3, Reg_8W, MAX},
  /* SPI Configuration Register : SER[9h] Note : Bits 4,3 and 2 are read
     only.  */
  {
   "SPICF", SPI, 0x16, 0x16 | MOD3, Reg_8W, MAX},
  /* SPI Clock Register : SER[Ah] */
  {
   "SPICK", SPI, 0x17, 0x17 | MOD3, Reg_8W, MAX},
  /* -------- One Wire Bus Master OWBM -------- */
  /* OWBM One Wire address Register register: [01h] */
  {
   "OWA", OWBM, 0x13, 0x13 | MOD3, Reg_8W, MAX},
  /* OWBM One Wire Data register: [02h] */
  {
   "OWD", OWBM, 0x14, 0x14 | MOD3, Reg_8W, MAX},
  /* -------- The Serial I/O module SER -------- */
  /* UART registers */
  /* Serial Port Control Register : SER[6h] */
  {
   "SCON1", SER1, 0x6, 0x60 | MOD3, Reg_8W, MAX},
  /* Serial Data Buffer Register : SER[7h] */
  {
   "SBUF1", SER1, 0x7, 0x70 | MOD3, Reg_8W, MAX},
  /* Serial Port Mode Register : SER[4h] */
  {
   "SMD1", SER1, 0x8, 0x80 | MOD3, Reg_8W, MAX},
  /* Serial Port Phase Register : SER[4h] */
  {
   "PR1", SER1, 0x9, 0x90 | MOD3, Reg_16W, MAX},
  /* -------- Timer/Counter 2 Module -------- */
  /* Timer 2 configuration Register : TC[3h] */
  {
   "T2CNA0", TIMER20, 0x0, 0x00 | MOD3, Reg_8W, MAX},
  {
   "T2H0", TIMER20, 0x1, 0x10 | MOD3, Reg_8W, MAX},
  {
   "T2RH0", TIMER20, 0x2, 0x20 | MOD3, Reg_8W, MAX},
  {
   "T2CH0", TIMER20, 0x3, 0x30 | MOD3, Reg_8W, MAX},
  {
   "T2CNB0", TIMER20, 0xc, 0xc0 | MOD3, Reg_8W, MAX},
  {
   "T2V0", TIMER20, 0xd, 0xd0 | MOD3, Reg_16W, MAX},
  {
   "T2R0", TIMER20, 0xe, 0xe0 | MOD3, Reg_16W, MAX},
  {
   "T2C0", TIMER20, 0xf, 0xf0 | MOD3, Reg_16W, MAX},
  {
   "T2CFG0", TIMER20, 0x10, 0x10 | MOD3, Reg_8W, MAX},
  /* Timer 2-1 configuration Register : TC[4h] */

  {
   "T2CNA1", TIMER21, 0x0, 0x00 | MOD4, Reg_8W, MAX},
  {
   "T2H1", TIMER21, 0x1, 0x10 | MOD4, Reg_8W, MAX},
  {
   "T2RH1", TIMER21, 0x2, 0x20 | MOD4, Reg_8W, MAX},
  {
   "T2CH1", TIMER21, 0x3, 0x30 | MOD4, Reg_8W, MAX},
  {
   "T2CNA2", TIMER21, 0x4, 0x40 | MOD4, Reg_8W, MAX},
  {
   "T2H2", TIMER21, 0x5, 0x50 | MOD4, Reg_8W, MAX},
  {
   "T2RH2", TIMER21, 0x6, 0x60 | MOD4, Reg_8W, MAX},
  {
   "T2CH2", TIMER21, 0x7, 0x70 | MOD4, Reg_8W, MAX},
  {
   "T2CNB1", TIMER21, 0x8, 0x80 | MOD4, Reg_8W, MAX},
  {
   "T2V1", TIMER21, 0x9, 0x90 | MOD4, Reg_16W, MAX},
  {
   "T2R1", TIMER21, 0xa, 0xa0 | MOD4, Reg_16W, MAX},
  {
   "T2C1", TIMER21, 0xb, 0xb0 | MOD4, Reg_16W, MAX},
  {
   "T2CNB2", TIMER21, 0xc, 0xc0 | MOD4, Reg_8W, MAX},
  {
   "T2V2", TIMER21, 0xd, 0xd0 | MOD4, Reg_16W, MAX},
  {
   "T2R2", TIMER21, 0xe, 0xe0 | MOD4, Reg_16W, MAX},
  {
   "T2C2", TIMER21, 0xf, 0xf0 | MOD4, Reg_16W, MAX},
  {
   "T2CFG1", TIMER21, 0x10, 0x10 | MOD4, Reg_8W, MAX},
  {
   "T2CFG2", TIMER21, 0x11, 0x11 | MOD4, Reg_8W, MAX},
  {
   NULL, 0, 0, 0, 0, 0}
};

/* Memory access argument.  */
struct mem_access
{
  char *name;			/* Name of the Memory access operand.  */
  int opcode;			/* Its corresponding opcode.  */
};
typedef struct mem_access mem_access;

/* The Memory table for accessing the data memory through particular registers.  */
struct mem_access mem_table[] =
{
  /* The Pop Operation on the stack.  */
  {"@SP--", 0x0d},
  /* Data Pointer 0 */
  {"@DP[0]", 0x0f},
  /* Data Ponter 1 */
  {"@DP[1]", 0x4f},
  /* Data Pointer 0 post increment */
  {"@DP[0]++", 0x1f},
  /* Data Pointer 1 post increment */
  {"@DP[1]++", 0x5f},
  /* Data Pointer 0 post decrement */
  {"@DP[0]--", 0x2f},
  /* Data Pointer 1 post decrement */
  {"@DP[1]--", 0x6f},
  /* ADDED According to New Specification.  */

  {"@BP[OFFS]", 0x0E},
  {"@BP[OFFS++]", 0x1E},
  {"@BP[OFFS--]", 0x2E},
  {"NUL", 0x76},
  {"@++SP", 0x0D},
  {"@BP[++OFFS]", 0x1E},
  {"@BP[--OFFS]", 0x2E},
  {"@++DP[0]", 0x1F},
  {"@++DP[1]", 0x5F}, {"@--DP[0]", 0x2F}, {"@--DP[1]", 0x6F}
};

/* Register bit argument.  */
struct reg_bit
{
  reg_entry *reg;
  int bit;
};
typedef struct reg_bit reg_bit;

/* There are certain names given to particular bits of some registers.
   These will be taken care of here.  */
struct bit_name
{
  char *name;
  char *reg_bit;
};
typedef struct bit_name bit_name;

bit_name bit_table[] =
{
  {
   "RI", "SCON.0"},
  /* FOr APC */
  {
   "MOD0", "APC.0"},
  {
   "MOD1", "APC.1"},
  {
   "MOD2", "APC.2"},
  {
   "IDS", "APC.6"},
  {
   "CLR", "APC.6"},
  /* For PSF */
  {
   "E", "PSF.0"},
  {
   "C", "PSF.1"},
  {
   "OV", "PSF.2"},
  {
   "S", "PSF.6"},
  {
   "Z", "PSF.7"},
  /* For IC */

  {
   "IGE", "IC.0"},
  {
   "INS", "IC.1"},
  {
   "CGDS", "IC.5"},
  /* For IMR */

  {
   "IM0", "IMR.0"},
  {
   "IM1", "IMR.1"},
  {
   "IM2", "IMR.2"},
  {
   "IM3", "IMR.3"},
  {
   "IM4", "IMR.4"},
  {
   "IM5", "IMR.5"},
  {
   "IMS", "IMR.7"},
  /* For SC */
  {
   "PWL", "SC.1"},
  {
   "ROD", "SC.2"},
  {
   "UPA", "SC.3"},
  {
   "CDA0", "SC.4"},
  {
   "CDA1", "SC.5"},
  /* For IIR */

  {
   "II0", "IIR.0"},
  {
   "II1", "IIR.1"},
  {
   "II2", "IIR.2"},
  {
   "II3", "IIR.3"},
  {
   "II4", "IIR.4"},
  {
   "II5", "IIR.5"},
  {
   "IIS", "IIR.7"},
  /* For CKCN */

  {
   "CD0", "CKCN.0"},
  {
   "CD1", "CKCN.1"},
  {
   "PMME", "CKCN.2"},
  {
   "SWB", "CKCN.3"},
  {
   "STOP", "CKCN.4"},
  {
   "RGMD", "CKCN.5"},
  {
   "RGSL", "CKCN.6"},
  /* For WDCN */

  {
   "RWT", "WDCN.0"},
  {
   "EWT", "WDCN.1"},
  {
   "WTRF", "WDCN.2"},
  {
   "WDIF", "WDCN.3"},
  {
   "WD0", "WDCN.4"},
  {
   "WD1", "WDCN.5"},
  {
   "EWDI", "WDCN.6"},
  {
   "POR", "WDCN.7"},
  /* For DPC */

  {
   "DPS0", "DPC.0"},
  {
   "DPS1", "DPC.1"},
  {
   "WBS0", "DPC.2"},
  {
   "WBS1", "DPC.3"},
  {
   "WBS2", "DPC.4"},

   /* For SCON */  
  {
   "TI", "SCON.1"},
  {
   "RB8", "SCON.2"},
  {
   "TB8", "SCON.3"},
  {
   "REN", "SCON.4"},
  {
   "SM2", "SCON.5"},
  {
   "SM1", "SCON.6"},
  {
   "SM0", "SCON.7"},
  {
   "FE", "SCON.7"}
};

const char *LSInstr[] =
{
  "LJUMP", "SJUMP", "LDJNZ", "SDJNZ", "LCALL", "SCALL", "JUMP",
  "DJNZ", "CALL", NULL
};

typedef enum
{
  DST,
  SRC,
  BOTH,
}
type1;

struct mem_access_syntax
{
  char name[12];		/* Name of the Memory access operand.  */
  type1 type;
  char *invalid_op[5];
};
typedef struct mem_access_syntax mem_access_syntax;

/* The Memory Access table for accessing the data memory through particular
   registers.  */
const mem_access_syntax mem_access_syntax_table[] =
{
  {
   "@SP--", SRC,
   {
    NULL, NULL, NULL, NULL, NULL}},
  /* Data Pointer 0 */
  {
   "@DP[0]", BOTH,
   {
    "@DP[0]--", "@DP[0]++", NULL, NULL, NULL}},
  /* Data Ponter 1 */
  {
   "@DP[1]", BOTH,
   {
    "@DP[1]--", "@DP[1]++", NULL, NULL, NULL}},
  /* Data Pointer 0 post increment */
  {
   "@DP[0]++", SRC,
   {
    NULL, NULL, NULL, NULL, NULL}},
  /* Data Pointer 1 post increment */
  {
   "@DP[1]++", SRC,
   {
    NULL, NULL, NULL, NULL, NULL}},
  /* Data Pointer 0 post decrement */
  {
   "@DP[0]--", SRC,
   {
    NULL, NULL, NULL, NULL, NULL}},
  /* Data Pointer 1 post decrement */
  {
   "@DP[1]--", SRC,
   {
    NULL, NULL, NULL, NULL, NULL}},
  /* ADDED According to New Specification */

  {
   "@BP[OFFS]", BOTH,
   {
    "@BP[OFFS++]", "@BP[OFFS--]", NULL, NULL, NULL}},
  {
   "@BP[OFFS++]", SRC,
   {
    NULL, NULL, NULL, NULL, NULL}},
  {
   "@BP[OFFS--]", SRC,
   {
    NULL, NULL, NULL, NULL, NULL}},
  {
   "NUL", DST,
   {
    NULL, NULL, NULL, NULL, NULL}},
  {
   "@++SP", DST,
   {
    NULL, NULL, NULL, NULL, NULL}},
  {
   "@BP[++OFFS]", DST,
   {
    "@BP[OFFS--]", "@BP[OFFS++]", NULL, NULL, NULL}},
  {
   "@BP[--OFFS]", DST,
   {
    "@BP[OFFS--]", "@BP[OFFS++]", NULL, NULL, NULL}},
  {
   "@++DP[0]", DST,
   {
    "@DP[0]--", "@DP[0]++", NULL, NULL, NULL}},
  {
   "@++DP[1]", DST,
   {
    "@DP[1]--", "@DP[1]++", NULL, NULL, NULL}},
  {
   "@--DP[0]", DST,
   {
    "@DP[0]++", "@DP[0]--", NULL, NULL, NULL}},
  {
   "@--DP[1]", DST,
   {
    "@DP[1]++", "@DP[1]--", NULL, NULL, NULL}}
};

#endif