Subversion Repositories pentevo

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1186 savelij 1
/* code1750.c */
2
/*****************************************************************************/
3
/* SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only                     */
4
/*                                                                           */
5
/* AS-Portierung                                                             */
6
/*                                                                           */
7
/* Code Generator MIL-STD-1750                                               */
8
/*                                                                           */
9
/* This generator is heavily based on the as1750 assembler written by        */
10
/* Oliver M. Kellogg, Dornier Satellite Systems.  Yes, I know, it's been     */
11
/* floating around on my hard drive for almost two decades before I got my   */
12
/* a** up to finally do it.  But maybe someone still reads it...             */
13
/*                                                                           */
14
/*****************************************************************************/
15
 
16
#include "stdinc.h"
17
#include <string.h>
18
#include <ctype.h>
19
 
20
#include "bpemu.h"
21
#include "strutil.h"
22
#include "asmdef.h"
23
#include "asmsub.h"
24
#include "asmpars.h"
25
#include "asmitree.h"
26
#include "codepseudo.h"
27
#include "fourpseudo.h"
28
#include "codevars.h"
29
#include "headids.h"
30
#include "be_le.h"
31
#include "ieeefloat.h"
32
#include "milfloat.h"
33
#include "errmsg.h"
34
 
35
#include "code1750.h"
36
 
37
/*-------------------------------------------------------------------------*/
38
 
39
typedef struct
40
{
41
  const char *pName;
42
  Word Code;
43
} tCondition;
44
 
45
static CPUVar CPU1750;
46
static Word AdrReg, AdrWord;
47
 
48
/*-------------------------------------------------------------------------*/
49
/* Utility Functions */
50
 
51
static void PutCode(Word Code)
52
{
53
  WAsmCode[CodeLen++] = Code;
54
}
55
 
56
static Boolean DecodeReg(const char *pAsc, Word *pResult)
57
{
58
  if (toupper(*pAsc) != 'R')
59
    return False;
60
  pAsc++;
61
 
62
  *pResult = 0;
63
  while (*pAsc)
64
  {
65
    if (!isdigit(*pAsc))
66
      return False;
67
    *pResult = (*pResult * 10) + (*pAsc - '0');
68
    if (*pResult > 15)
69
      return False;
70
    pAsc++;
71
  }
72
  return True;
73
}
74
 
75
static Boolean DecodeBaseReg(const char *pAsc, Word *pResult)
76
{
77
  if ((toupper(*pAsc) != 'R') && (toupper(*pAsc) != 'B'))
78
    return False;
79
  pAsc++;
80
 
81
  *pResult = 0;
82
  while (*pAsc)
83
  {
84
    if (!isdigit(*pAsc))
85
      return False;
86
    *pResult = (*pResult * 10) + (*pAsc - '0');
87
    if (*pResult > 15)
88
      return False;
89
    pAsc++;
90
  }
91
  if (*pResult < 12)
92
    return False;
93
  *pResult -= 12;
94
  return True;
95
}
96
 
97
static Boolean DecodeArgReg(unsigned Index, Word *pResult)
98
{
99
  Boolean Result = DecodeReg(ArgStr[Index].str.p_str, pResult);
100
 
101
  if (!Result)
102
    WrStrErrorPos(ErrNum_InvReg, &ArgStr[Index]);
103
  return Result;
104
}
105
 
106
static Boolean DecodeArgBaseReg(unsigned Index, Word *pResult)
107
{
108
  Boolean Result = DecodeBaseReg(ArgStr[Index].str.p_str, pResult);
109
 
110
  if (!Result)
111
    WrStrErrorPos(ErrNum_InvReg, &ArgStr[Index]);
112
  return Result;
113
}
114
 
115
static Boolean DecodeAdr(int StartIdx, int StopIdx)
116
{
117
  Boolean OK;
118
 
119
  AdrWord = EvalStrIntExpression(&ArgStr[StartIdx], Int16, &OK);
120
  if (!OK)
121
    return False;
122
 
123
  if (StopIdx > StartIdx)
124
  {
125
    OK = False;
126
    if (!DecodeArgReg(StartIdx + 1, &AdrReg));
127
    else if (AdrReg == 0)
128
      WrXErrorPos(ErrNum_InvAddrMode, "!R0", &ArgStr[StartIdx + 1].Pos);
129
    else
130
      OK = True;
131
    return OK;
132
  }
133
  else
134
    AdrReg = 0;
135
  return OK;
136
}
137
 
138
static Boolean DecodeCondition(const char *pAsc, Word *pResult)
139
{
140
  static const tCondition Conditions[] =
141
  {
142
    { "LT",  0x1 },             /* 0001 */
143
    { "LZ",  0x1 },             /* 0001 */
144
    { "EQ",  0x2 },             /* 0010 */
145
    { "EZ",  0x2 },             /* 0010 */
146
    { "LE",  0x3 },             /* 0011 */
147
    { "LEZ", 0x3 },             /* 0011 */
148
    { "GT",  0x4 },             /* 0100 */
149
    { "GTZ", 0x4 },             /* 0100 */
150
    { "NE",  0x5 },             /* 0101 */
151
    { "NZ",  0x5 },             /* 0101 */
152
    { "GE",  0x6 },             /* 0110 */
153
    { "GEZ", 0x6 },             /* 0110 */
154
    { "ALL", 0x7 },             /* 0111 */
155
    { "CY",  0x8 },             /* 1000 */
156
    { "CLT", 0x9 },             /* 1001 */
157
    { "CEQ", 0xA },             /* 1010 */
158
    { "CEZ", 0xA },             /* 1010 */
159
    { "CLE", 0xB },             /* 1011 */
160
    { "CGT", 0xC },             /* 1100 */
161
    { "CNZ", 0xD },             /* 1101 */
162
    { "CGE", 0xE },             /* 1110 */
163
    { "UC",  0xF },             /* 1111 */
164
    { NULL,  0x0 },
165
  };
166
  const tCondition *pCond;
167
 
168
  for (pCond = Conditions; pCond->pName; pCond++)
169
    if (!as_strcasecmp(pAsc, pCond->pName))
170
    {
171
      *pResult = pCond->Code;
172
      return True;
173
    }
174
  return False;
175
}
176
 
177
static Boolean DecodeArgCondition(unsigned Index, Word *pResult)
178
{
179
  Boolean Result = DecodeCondition(ArgStr[Index].str.p_str, pResult);
180
 
181
  if (!Result)
182
    WrStrErrorPos(ErrNum_UndefCond, &ArgStr[Index]);
183
  return Result;
184
}
185
 
186
static Boolean DecodeArgXIOCmd(unsigned Index, Word *pResult)
187
{
188
  static const tCondition XIO[] =
189
  {
190
    { "SMK",  0x2000 },
191
    { "CLIR", 0x2001 },
192
    { "ENBL", 0x2002 },
193
    { "DSBL", 0x2003 },
194
    { "RPI",  0x2004 },
195
    { "SPI",  0x2005 },
196
    { "OD",   0x2008 },
197
    { "RNS",  0x200A },
198
    { "WSW",  0x200E },
199
    { "CO",   0x4000 },
200
    { "CLC",  0x4001 },
201
    { "MPEN", 0x4003 },
202
    { "ESUR", 0x4004 },
203
    { "DSUR", 0x4005 },
204
    { "DMAE", 0x4006 },
205
    { "DMAD", 0x4007 },
206
    { "TAS",  0x4008 },
207
    { "TAH",  0x4009 },
208
    { "OTA",  0x400A },
209
    { "GO",   0x400B },
210
    { "TBS",  0x400C },
211
    { "TBH",  0x400D },
212
    { "OTB",  0x400E },
213
    { "LMP",  0x5000 },
214
    { "WIPR", 0x5100 },
215
    { "WOPR", 0x5200 },
216
    { "RMP",  0xD000 },
217
    { "RIPR", 0xD100 },
218
    { "ROPR", 0xD200 },
219
    { "RMK",  0xA000 },
220
    { "RIC1", 0xA001 },
221
    { "RIC2", 0xA002 },
222
    { "RPIR", 0xA004 },
223
    { "RDOR", 0xA008 },
224
    { "RDI",  0xA009 },
225
    { "TPIO", 0xA00B },
226
    { "RMFS", 0xA00D },
227
    { "RSW",  0xA00E },
228
    { "RCFR", 0xA00F },
229
    { "CI",   0xC000 },
230
    { "RCS",  0xC001 },
231
    { "ITA",  0xC00A },
232
    { "ITB",  0xC00E },
233
    { NULL,   0xFFFF }
234
  };
235
  const tCondition *pRun;
236
  Boolean OK;
237
 
238
  if (isalpha(ArgStr[Index].str.p_str[0]))
239
  {
240
    for (pRun = XIO; pRun->pName; pRun++)
241
      if (!as_strcasecmp(ArgStr[Index].str.p_str, pRun->pName))
242
      {
243
        *pResult = pRun->Code;
244
        return True;
245
      }
246
  }
247
  *pResult = EvalStrIntExpression(&ArgStr[Index], UInt16, &OK);
248
  return OK;
249
}
250
 
251
/*-------------------------------------------------------------------------*/
252
/* Code Generators */
253
 
254
static void DecodeNone(Word Code)
255
{
256
  if (ChkArgCnt(0, 0))
257
    PutCode(Code);
258
}
259
 
260
static void DecodeR(Word Code)
261
{
262
  Word Ra, Rb;
263
 
264
  if (ChkArgCnt(2, 2)
265
   && DecodeArgReg(1, &Ra)
266
   && DecodeArgReg(2, &Rb))
267
    PutCode(Code | (Ra << 4) | Rb);
268
}
269
 
270
static void DecodeRImm(Word Code)
271
{
272
  Word N, Rb;
273
  Boolean OK;
274
 
275
  if (ChkArgCnt(2, 2) && DecodeArgReg(1, &Rb))
276
  {
277
    N = EvalStrIntExpression(&ArgStr[2], UInt4, &OK);
278
    if (OK)
279
      PutCode(Code | (N << 4) | Rb);
280
  }
281
}
282
 
283
static void DecodeIS(Word Code)
284
{
285
  Word N, Ra;
286
  Boolean OK;
287
  tSymbolFlags Flags;
288
 
289
  if (ChkArgCnt(2, 2) && DecodeArgReg(1, &Ra))
290
  {
291
    N = EvalStrIntExpressionWithFlags(&ArgStr[2], UInt5, &OK, &Flags);
292
    if (OK && mFirstPassUnknown(Flags))
293
      N = 1;
294
    if (OK && ChkRange(N, 1, 16))
295
      PutCode(Code | (Ra << 4) | (N - 1));
296
  }
297
}
298
 
299
static void DecodeMem(Word Code)
300
{
301
  Word Ra;
302
 
303
  if (ChkArgCnt(2, 3)
304
   && DecodeArgReg(1, &Ra)
305
   && DecodeAdr(2, ArgCnt))
306
  {
307
    PutCode(Code | (Ra << 4) | AdrReg);
308
    PutCode(AdrWord);
309
  }
310
}
311
 
312
static void DecodeImOcx(Word Code)
313
{
314
  Word Ra;
315
 
316
  if (ChkArgCnt(2, 2) && DecodeArgReg(1, &Ra))
317
  {
318
    Boolean OK;
319
    Word ImmVal = EvalStrIntExpression(&ArgStr[2], Int16, &OK);
320
 
321
    if (OK)
322
    {
323
      PutCode(Code | (Ra << 4));
324
      PutCode(ImmVal);
325
    }
326
  }
327
}
328
 
329
static void DecodeB(Word Code)
330
{
331
  Word Br;
332
 
333
  if (ChkArgCnt(2, 2) && DecodeArgBaseReg(1, &Br))
334
  {
335
    Boolean OK;
336
    Word LoByte = EvalStrIntExpression(&ArgStr[2], UInt8, &OK);
337
 
338
    if (OK)
339
      PutCode(Code | (Br << 8) | LoByte);
340
  }
341
}
342
 
343
static void DecodeBX(Word Code)
344
{
345
  Word Br, Rx;
346
 
347
  if (!ChkArgCnt(2, 2));
348
  else if (!DecodeArgBaseReg(1, &Br));
349
  else if (!DecodeArgReg(2, &Rx));
350
  else if (0 == Rx) WrXErrorPos(ErrNum_InvAddrMode, "!R0", &ArgStr[2].Pos);
351
  else
352
    PutCode(Code | (Br << 8) | Rx);
353
}
354
 
355
static void DecodeICR(Word Code)
356
{
357
  if (ChkArgCnt(1, 1))
358
  {
359
    Boolean OK;
360
    tSymbolFlags Flags;
361
    LargeInt Diff = EvalStrIntExpressionWithFlags(&ArgStr[1], UInt16, &OK, &Flags) - EProgCounter();
362
 
363
    if (OK)
364
    {
365
      if (!mSymbolQuestionable(Flags) && ((Diff < -128) || (Diff > 127))) WrError(ErrNum_JmpDistTooBig);
366
      else
367
        PutCode(Code | (Diff & 0xff));
368
    }
369
  }
370
}
371
 
372
static void DecodeS(Word Code)
373
{
374
  if (ChkArgCnt(1, 1))
375
  {
376
    Boolean OK;
377
    Word Value = EvalStrIntExpression(&ArgStr[1], UInt4, &OK);
378
 
379
    if (OK)
380
      PutCode(Code | Value);
381
  }
382
}
383
 
384
static void DecodeIM1_16(Word Code)
385
{
386
  if (ChkArgCnt(2, 3) && DecodeAdr(2, ArgCnt))
387
  {
388
    Boolean OK;
389
    Word N;
390
    tSymbolFlags Flags;
391
 
392
    N = EvalStrIntExpressionWithFlags(&ArgStr[1], UInt5, &OK, &Flags);
393
    if (OK && mFirstPassUnknown(Flags))
394
      N = 1;
395
 
396
    if (OK && ChkRange(N, 1, 16))
397
    {
398
      PutCode(Code | ((N - 1) << 4) | AdrReg);
399
      PutCode(AdrWord);
400
    }
401
  }
402
}
403
 
404
static void DecodeXMem(Word Code)
405
{
406
  Word Ra;
407
 
408
  if (ChkArgCnt(2, 3)
409
   && DecodeArgReg(1, &Ra)
410
   && DecodeAdr(2, ArgCnt))
411
  {
412
    PutCode(Code | (Ra << 4) | AdrReg);
413
    PutCode(AdrWord);
414
  }
415
}
416
 
417
static void DecodeImmR(Word Code)
418
{
419
  Word Rb, N;
420
  Boolean OK;
421
 
422
  if (ChkArgCnt(2, 2) && DecodeArgReg(2, &Rb))
423
  {
424
    N = EvalStrIntExpression(&ArgStr[1], UInt4, &OK);
425
 
426
    if (OK)
427
      PutCode(Code | (N << 4) | Rb);
428
  }
429
}
430
 
431
static void DecodeJump(Word Code)
432
{
433
  Word Cond;
434
 
435
  if (ChkArgCnt(2, 3)
436
   && DecodeArgCondition(1, &Cond)
437
   && DecodeAdr(2, ArgCnt))
438
  {
439
    PutCode(Code | (Cond << 4) | AdrReg);
440
    PutCode(AdrWord);
441
  }
442
}
443
 
444
static void DecodeAddr(Word Code)
445
{
446
  if (ChkArgCnt(1, 2) && DecodeAdr(1, ArgCnt))
447
  {
448
    PutCode(Code | AdrReg);
449
    PutCode(AdrWord);
450
  }
451
}
452
 
453
static void DecodeIM_0_15(Word Code)
454
{
455
  if (ChkArgCnt(2, 3) && DecodeAdr(2, ArgCnt))
456
  {
457
    Boolean OK;
458
    Word N = EvalStrIntExpression(&ArgStr[1], UInt4, &OK);
459
 
460
    if (OK)
461
    {
462
      PutCode(Code | (N << 4) | AdrReg);
463
      PutCode(AdrWord);
464
    }
465
  }
466
}
467
 
468
static void DecodeSR(Word Code)
469
{
470
  Word R;
471
 
472
  if (ChkArgCnt(1, 1)  && DecodeArgReg(1, &R))
473
    PutCode(Code | (R << 4));
474
}
475
 
476
static void DecodeXIO(Word Code)
477
{
478
  Word Ra, Cmd;
479
 
480
  if (ChkArgCnt(2, 3)
481
   && DecodeArgReg(1, &Ra)
482
   && DecodeArgXIOCmd(2, &Cmd))
483
  {
484
    if (ArgCnt == 3)
485
    {
486
      Word Ri;
487
 
488
      if (!DecodeArgReg(3, &Ri));
489
      else if (Ri == 0) WrXErrorPos(ErrNum_InvAddrMode, "!R0", &ArgStr[3].Pos);
490
      else
491
      {
492
        PutCode(Code | (Ra << 4) | Ri);
493
        PutCode(Cmd);
494
      }
495
    }
496
    else
497
    {
498
      PutCode(Code | (Ra << 4));
499
      PutCode(Cmd);
500
    }
501
  }
502
}
503
 
504
static void DecodeFLOAT(Word Extended)
505
{
506
  int z;
507
  Boolean OK;
508
  as_float_t Value;
509
  Word Words[3];
510
 
511
  if (!ChkArgCnt(1, ArgCntMax))
512
    return;
513
 
514
  for (z = 1; z <= ArgCnt; z++)
515
  {
516
    int ret, z2;
517
    Value = EvalStrFloatExpression(&ArgStr[z], &OK);
518
    if (!OK)
519
      break;
520
 
521
    ret = as_float_2_mil1750(Value, Words, Extended);
522
    if (ret < 0)
523
    {
524
      asmerr_check_fp_dispose_result(ret, &ArgStr[z]);
525
      break;
526
    }
527
    for (z2 = 0; z2 < ret; z2++)
528
      PutCode(Words[z2]);
529
  }
530
}
531
 
532
static void DecodeDATA_1750(Word Code)
533
{
534
  UNUSED(Code);
535
 
536
  DecodeDATA(UInt16, UInt16);
537
}
538
 
539
/*-------------------------------------------------------------------------*/
540
/* dynamic code table handling */
541
 
542
static void InitFields(void)
543
{
544
  InstTable = CreateInstTable(403);
545
 
546
  add_null_pseudo(InstTable);
547
 
548
  AddInstTable(InstTable, "AISP", 0xA200, DecodeIS);
549
  AddInstTable(InstTable, "AIM",  0x4A01, DecodeImOcx);
550
  AddInstTable(InstTable, "AR",   0xA100, DecodeR);
551
  AddInstTable(InstTable, "A",    0xA000, DecodeMem);
552
  AddInstTable(InstTable, "ANDM", 0x4A07, DecodeImOcx);
553
  AddInstTable(InstTable, "ANDR", 0xE300, DecodeR);
554
  AddInstTable(InstTable, "AND",  0xE200, DecodeMem);
555
  AddInstTable(InstTable, "ABS",  0xA400, DecodeR);
556
  AddInstTable(InstTable, "AB",   0x1000, DecodeB);
557
  AddInstTable(InstTable, "ANDB", 0x3400, DecodeB);
558
  AddInstTable(InstTable, "ABX",  0x4040, DecodeBX);
559
  AddInstTable(InstTable, "ANDX", 0x40E0, DecodeBX);
560
  AddInstTable(InstTable, "BEZ",  0x7500, DecodeICR);
561
  AddInstTable(InstTable, "BNZ",  0x7A00, DecodeICR);
562
  AddInstTable(InstTable, "BGT",  0x7900, DecodeICR);
563
  AddInstTable(InstTable, "BLE",  0x7800, DecodeICR);
564
  AddInstTable(InstTable, "BGE",  0x7B00, DecodeICR);
565
  AddInstTable(InstTable, "BLT",  0x7600, DecodeICR);
566
  AddInstTable(InstTable, "BR",   0x7400, DecodeICR);
567
  AddInstTable(InstTable, "BEX",  0x7700, DecodeS);
568
  AddInstTable(InstTable, "BPT",  0xFFFF, DecodeNone);
569
  AddInstTable(InstTable, "BIF",  0x4F00, DecodeS);
570
  AddInstTable(InstTable, "CISP", 0xF200, DecodeIS);
571
  AddInstTable(InstTable, "CIM",  0x4A0A, DecodeImOcx);
572
  AddInstTable(InstTable, "CR",   0xF100, DecodeR);
573
  AddInstTable(InstTable, "C",    0xF000, DecodeMem);
574
  AddInstTable(InstTable, "CISN", 0xF300, DecodeIS);
575
  AddInstTable(InstTable, "CB",   0x3800, DecodeB);
576
  AddInstTable(InstTable, "CBL",  0xF400, DecodeMem);
577
  AddInstTable(InstTable, "CBX",  0x40C0, DecodeBX);
578
  AddInstTable(InstTable, "DLR",  0x8700, DecodeR);
579
  AddInstTable(InstTable, "DL",   0x8600, DecodeMem);
580
  AddInstTable(InstTable, "DST",  0x9600, DecodeMem);
581
  AddInstTable(InstTable, "DSLL", 0x6500, DecodeRImm);
582
  AddInstTable(InstTable, "DSRL", 0x6600, DecodeRImm);
583
  AddInstTable(InstTable, "DSRA", 0x6700, DecodeRImm);
584
  AddInstTable(InstTable, "DSLC", 0x6800, DecodeRImm);
585
  AddInstTable(InstTable, "DSLR", 0x6D00, DecodeR);
586
  AddInstTable(InstTable, "DSAR", 0x6E00, DecodeR);
587
  AddInstTable(InstTable, "DSCR", 0x6F00, DecodeR);
588
  AddInstTable(InstTable, "DECM", 0xB300, DecodeIM1_16);
589
  AddInstTable(InstTable, "DAR",  0xA700, DecodeR);
590
  AddInstTable(InstTable, "DA",   0xA600, DecodeMem);
591
  AddInstTable(InstTable, "DSR",  0xB700, DecodeR);
592
  AddInstTable(InstTable, "DS",   0xB600, DecodeMem);
593
  AddInstTable(InstTable, "DMR",  0xC700, DecodeR);
594
  AddInstTable(InstTable, "DM",   0xC600, DecodeMem);
595
  AddInstTable(InstTable, "DDR",  0xD700, DecodeR);
596
  AddInstTable(InstTable, "DD",   0xD600, DecodeMem);
597
  AddInstTable(InstTable, "DCR",  0xF700, DecodeR);
598
  AddInstTable(InstTable, "DC",   0xF600, DecodeMem);
599
  AddInstTable(InstTable, "DLB",  0x0400, DecodeB);
600
  AddInstTable(InstTable, "DSTB", 0x0C00, DecodeB);
601
  AddInstTable(InstTable, "DNEG", 0xB500, DecodeR);
602
  AddInstTable(InstTable, "DABS", 0xA500, DecodeR);
603
  AddInstTable(InstTable, "DR",   0xD500, DecodeR);
604
  AddInstTable(InstTable, "D",    0xD400, DecodeMem);
605
  AddInstTable(InstTable, "DISP", 0xD200, DecodeIS);
606
  AddInstTable(InstTable, "DIM",  0x4A05, DecodeImOcx);
607
  AddInstTable(InstTable, "DISN", 0xD300, DecodeIS);
608
  AddInstTable(InstTable, "DVIM", 0x4A06, DecodeImOcx);
609
  AddInstTable(InstTable, "DVR",  0xD100, DecodeR);
610
  AddInstTable(InstTable, "DV",   0xD000, DecodeMem);
611
  AddInstTable(InstTable, "DLI",  0x8800, DecodeMem);
612
  AddInstTable(InstTable, "DSTI", 0x9800, DecodeMem);
613
  AddInstTable(InstTable, "DB",   0x1C00, DecodeB);
614
  AddInstTable(InstTable, "DBX",  0x4070, DecodeBX);
615
  AddInstTable(InstTable, "DLBX", 0x4010, DecodeBX);
616
  AddInstTable(InstTable, "DSTX", 0x4030, DecodeBX);
617
  AddInstTable(InstTable, "DLE",  0xDF00, DecodeXMem);
618
  AddInstTable(InstTable, "DSTE", 0xDD00, DecodeXMem);
619
  AddInstTable(InstTable, "EFL",  0x8A00, DecodeMem);
620
  AddInstTable(InstTable, "EFST", 0x9A00, DecodeMem);
621
  AddInstTable(InstTable, "EFCR", 0xFB00, DecodeR);
622
  AddInstTable(InstTable, "EFC",  0xFA00, DecodeMem);
623
  AddInstTable(InstTable, "EFAR", 0xAB00, DecodeR);
624
  AddInstTable(InstTable, "EFA",  0xAA00, DecodeMem);
625
  AddInstTable(InstTable, "EFSR", 0xBB00, DecodeR);
626
  AddInstTable(InstTable, "EFS",  0xBA00, DecodeMem);
627
  AddInstTable(InstTable, "EFMR", 0xCB00, DecodeR);
628
  AddInstTable(InstTable, "EFM",  0xCA00, DecodeMem);
629
  AddInstTable(InstTable, "EFDR", 0xDB00, DecodeR);
630
  AddInstTable(InstTable, "EFD",  0xDA00, DecodeMem);
631
  AddInstTable(InstTable, "EFLT", 0xEB00, DecodeR);
632
  AddInstTable(InstTable, "EFIX", 0xEA00, DecodeR);
633
  AddInstTable(InstTable, "FAR",  0xA900, DecodeR);
634
  AddInstTable(InstTable, "FA",   0xA800, DecodeMem);
635
  AddInstTable(InstTable, "FSR",  0xB900, DecodeR);
636
  AddInstTable(InstTable, "FS",   0xB800, DecodeMem);
637
  AddInstTable(InstTable, "FMR",  0xC900, DecodeR);
638
  AddInstTable(InstTable, "FM",   0xC800, DecodeMem);
639
  AddInstTable(InstTable, "FDR",  0xD900, DecodeR);
640
  AddInstTable(InstTable, "FD",   0xD800, DecodeMem);
641
  AddInstTable(InstTable, "FCR",  0xF900, DecodeR);
642
  AddInstTable(InstTable, "FC",   0xF800, DecodeMem);
643
  AddInstTable(InstTable, "FABS", 0xAC00, DecodeR);
644
  AddInstTable(InstTable, "FIX",  0xE800, DecodeR);
645
  AddInstTable(InstTable, "FLT",  0xE900, DecodeR);
646
  AddInstTable(InstTable, "FNEG", 0xBC00, DecodeR);
647
  AddInstTable(InstTable, "FAB",  0x2000, DecodeB);
648
  AddInstTable(InstTable, "FABX", 0x4080, DecodeBX);
649
  AddInstTable(InstTable, "FSB",  0x2400, DecodeB);
650
  AddInstTable(InstTable, "FSBX", 0x4090, DecodeBX);
651
  AddInstTable(InstTable, "FMB",  0x2800, DecodeB);
652
  AddInstTable(InstTable, "FMBX", 0x40A0, DecodeBX);
653
  AddInstTable(InstTable, "FDB",  0x2C00, DecodeB);
654
  AddInstTable(InstTable, "FDBX", 0x40B0, DecodeBX);
655
  AddInstTable(InstTable, "FCB",  0x3C00, DecodeB);
656
  AddInstTable(InstTable, "FCBX", 0x40D0, DecodeBX);
657
  AddInstTable(InstTable, "INCM", 0xA300, DecodeIM1_16);
658
  AddInstTable(InstTable, "JC",   0x7000, DecodeJump);
659
  AddInstTable(InstTable, "J",    0x7400, DecodeICR);   /* TBD (GAS) */
660
  AddInstTable(InstTable, "JEZ",  0x7500, DecodeICR);   /* TBD (GAS) */
661
  AddInstTable(InstTable, "JLE",  0x7800, DecodeICR);   /* TBD (GAS) */
662
  AddInstTable(InstTable, "JGT",  0x7900, DecodeICR);   /* TBD (GAS) */
663
  AddInstTable(InstTable, "JNZ",  0x7A00, DecodeICR);   /* TBD (GAS) */
664
  AddInstTable(InstTable, "JGE",  0x7B00, DecodeICR);   /* TBD (GAS) */
665
  AddInstTable(InstTable, "JLT",  0x7600, DecodeICR);   /* TBD (GAS) */
666
  AddInstTable(InstTable, "JCI",  0x7100, DecodeJump);
667
  AddInstTable(InstTable, "JS",   0x7200, DecodeMem);
668
  AddInstTable(InstTable, "LISP", 0x8200, DecodeIS);
669
  AddInstTable(InstTable, "LIM",  0x8500, DecodeMem);
670
  AddInstTable(InstTable, "LR",   0x8100, DecodeR);
671
  AddInstTable(InstTable, "L",    0x8000, DecodeMem);
672
  AddInstTable(InstTable, "LISN", 0x8300, DecodeIS);
673
  AddInstTable(InstTable, "LB",   0x0000, DecodeB);
674
  AddInstTable(InstTable, "LBX",  0x4000, DecodeBX);
675
  AddInstTable(InstTable, "LSTI", 0x7C00, DecodeAddr);
676
  AddInstTable(InstTable, "LST",  0x7D00, DecodeAddr);
677
  AddInstTable(InstTable, "LI",   0x8400, DecodeMem);
678
  AddInstTable(InstTable, "LM",   0x8900, DecodeIM_0_15);
679
  AddInstTable(InstTable, "LUB",  0x8B00, DecodeMem);
680
  AddInstTable(InstTable, "LLB",  0x8C00, DecodeMem);
681
  AddInstTable(InstTable, "LUBI", 0x8D00, DecodeMem);
682
  AddInstTable(InstTable, "LLBI", 0x8E00, DecodeMem);
683
  AddInstTable(InstTable, "LE",   0xDE00, DecodeXMem);
684
  AddInstTable(InstTable, "MISP", 0xC200, DecodeIS);
685
  AddInstTable(InstTable, "MSIM", 0x4A04, DecodeImOcx);
686
  AddInstTable(InstTable, "MSR",  0xC100, DecodeR);
687
  AddInstTable(InstTable, "MS",   0xC000, DecodeMem);
688
  AddInstTable(InstTable, "MISN", 0xC300, DecodeIS);
689
  AddInstTable(InstTable, "MIM",  0x4A03, DecodeImOcx);
690
  AddInstTable(InstTable, "MR",   0xC500, DecodeR);
691
  AddInstTable(InstTable, "M",    0xC400, DecodeMem);
692
  AddInstTable(InstTable, "MOV",  0x9300, DecodeR);
693
  AddInstTable(InstTable, "MB",   0x1800, DecodeB);
694
  AddInstTable(InstTable, "MBX",  0x4060, DecodeBX);
695
  AddInstTable(InstTable, "NEG",  0xB400, DecodeR);
696
  AddInstTable(InstTable, "NOP",  0xFF00, DecodeNone);
697
  AddInstTable(InstTable, "NIM",  0x4A0B, DecodeImOcx);
698
  AddInstTable(InstTable, "NR",   0xE700, DecodeR);
699
  AddInstTable(InstTable, "N",    0xE600, DecodeMem);
700
  AddInstTable(InstTable, "ORIM", 0x4A08, DecodeImOcx);
701
  AddInstTable(InstTable, "ORR",  0xE100, DecodeR);
702
  AddInstTable(InstTable, "OR",   0xE000, DecodeMem);
703
  AddInstTable(InstTable, "ORB",  0x3000, DecodeB);
704
  AddInstTable(InstTable, "ORBX", 0x40F0, DecodeBX);
705
  AddInstTable(InstTable, "PSHM", 0x9F00, DecodeR);
706
  AddInstTable(InstTable, "POPM", 0x8F00, DecodeR);
707
  AddInstTable(InstTable, "RBR",  0x5400, DecodeImmR);
708
  AddInstTable(InstTable, "RVBR", 0x5C00, DecodeR);
709
  AddInstTable(InstTable, "RB",   0x5300, DecodeIM_0_15);
710
  AddInstTable(InstTable, "RBI",  0x5500, DecodeIM_0_15);
711
  AddInstTable(InstTable, "ST",   0x9000, DecodeMem);
712
  AddInstTable(InstTable, "STC",  0x9100, DecodeIM_0_15);
713
  AddInstTable(InstTable, "SISP", 0xB200, DecodeIS);
714
  AddInstTable(InstTable, "SIM",  0x4A02, DecodeImOcx);
715
  AddInstTable(InstTable, "SR",   0xB100, DecodeR);
716
  AddInstTable(InstTable, "S",    0xB000, DecodeMem);
717
  AddInstTable(InstTable, "SLL",  0x6000, DecodeRImm);
718
  AddInstTable(InstTable, "SRL",  0x6100, DecodeRImm);
719
  AddInstTable(InstTable, "SRA",  0x6200, DecodeRImm);
720
  AddInstTable(InstTable, "SLC",  0x6300, DecodeRImm);
721
  AddInstTable(InstTable, "SLR",  0x6A00, DecodeR);
722
  AddInstTable(InstTable, "SAR",  0x6B00, DecodeR);
723
  AddInstTable(InstTable, "SCR",  0x6C00, DecodeR);
724
  AddInstTable(InstTable, "SJS",  0x7E00, DecodeMem);
725
  AddInstTable(InstTable, "STB",  0x0800, DecodeB);
726
  AddInstTable(InstTable, "SBR",  0x5100, DecodeImmR);
727
  AddInstTable(InstTable, "SB",   0x5000, DecodeIM_0_15);
728
  AddInstTable(InstTable, "SVBR", 0x5A00, DecodeR);
729
  AddInstTable(InstTable, "SOJ",  0x7300, DecodeMem);
730
  AddInstTable(InstTable, "SBB",  0x1400, DecodeB);
731
  AddInstTable(InstTable, "STBX", 0x4020, DecodeBX);
732
  AddInstTable(InstTable, "SBBX", 0x4050, DecodeBX);
733
  AddInstTable(InstTable, "SBI",  0x5200, DecodeIM_0_15);
734
  AddInstTable(InstTable, "STZ",  0x9100, DecodeAddr);
735
  AddInstTable(InstTable, "STCI", 0x9200, DecodeIM_0_15);
736
  AddInstTable(InstTable, "STI",  0x9400, DecodeMem);
737
  AddInstTable(InstTable, "SFBS", 0x9500, DecodeR);
738
  AddInstTable(InstTable, "SRM",  0x9700, DecodeMem);
739
  AddInstTable(InstTable, "STM",  0x9900, DecodeIM_0_15);
740
  AddInstTable(InstTable, "STUB", 0x9B00, DecodeMem);
741
  AddInstTable(InstTable, "STLB", 0x9C00, DecodeMem);
742
  AddInstTable(InstTable, "SUBI", 0x9D00, DecodeMem);
743
  AddInstTable(InstTable, "SLBI", 0x9E00, DecodeMem);
744
  AddInstTable(InstTable, "STE",  0xDC00, DecodeXMem);
745
  AddInstTable(InstTable, "TBR",  0x5700, DecodeImmR);
746
  AddInstTable(InstTable, "TB",   0x5600, DecodeIM_0_15);
747
  AddInstTable(InstTable, "TBI",  0x5800, DecodeIM_0_15);
748
  AddInstTable(InstTable, "TSB",  0x5900, DecodeIM_0_15);
749
  AddInstTable(InstTable, "TVBR", 0x5E00, DecodeR);
750
  AddInstTable(InstTable, "URS",  0x7F00, DecodeSR);
751
  AddInstTable(InstTable, "UAR",  0xAD00, DecodeR);
752
  AddInstTable(InstTable, "UA",   0xAE00, DecodeMem);
753
  AddInstTable(InstTable, "USR",  0xBD00, DecodeR);
754
  AddInstTable(InstTable, "US",   0xBE00, DecodeMem);
755
  AddInstTable(InstTable, "UCIM", 0xF500, DecodeImOcx);
756
  AddInstTable(InstTable, "UCR",  0xFC00, DecodeR);
757
  AddInstTable(InstTable, "UC",   0xFD00, DecodeMem);
758
  AddInstTable(InstTable, "VIO",  0x4900, DecodeMem);
759
  AddInstTable(InstTable, "XORR", 0xE500, DecodeR);
760
  AddInstTable(InstTable, "XORM", 0x4A09, DecodeImOcx);
761
  AddInstTable(InstTable, "XOR",  0xE400, DecodeMem);
762
  AddInstTable(InstTable, "XWR",  0xED00, DecodeR);
763
  AddInstTable(InstTable, "XBR",  0xEC00, DecodeSR);
764
  AddInstTable(InstTable, "XIO",  0x4800, DecodeXIO);
765
 
766
  AddInstTable(InstTable, "FLOAT", 0, DecodeFLOAT);
767
  AddInstTable(InstTable, "EXTENDED", 1, DecodeFLOAT);
768
  AddInstTable(InstTable, "DATA", 0, DecodeDATA_1750);
769
}
770
 
771
static void DeinitFields(void)
772
{
773
  DestroyInstTable(InstTable);
774
}
775
 
776
/*-------------------------------------------------------------------------*/
777
/* interface to common layer */
778
 
779
static void MakeCode_1750(void)
780
{
781
  if (!LookupInstTable(InstTable, OpPart.str.p_str))
782
    WrStrErrorPos(ErrNum_UnknownInstruction, &OpPart);
783
}
784
 
785
static Boolean IsDef_1750(void)
786
{
787
  return Memo("BIT");
788
}
789
 
790
static void SwitchFrom_1750(void)
791
{
792
  DeinitFields();
793
}
794
 
795
static void SwitchTo_1750(void)
796
{
797
  const TFamilyDescr *pDescr;
798
 
799
  pDescr = FindFamilyByName("1750");
800
 
801
  TurnWords = False;
802
  SetIntConstMode(eIntConstModeIntel);
803
 
804
  PCSymbol = "$";
805
  HeaderID = pDescr->Id;
806
  NOPCode = 0xff00;
807
  DivideChars = ",";
808
  HasAttrs = False;
809
 
810
  ValidSegs = 1 << SegCode;
811
  Grans[SegCode] = 2; ListGrans[SegCode] = 2; SegInits[SegCode] = 0;
812
  SegLimits[SegCode] = 0xffff;
813
 
814
  ASSUMERecCnt = 0;
815
 
816
  MakeCode = MakeCode_1750;
817
  IsDef = IsDef_1750;
818
  SwitchFrom = SwitchFrom_1750; InitFields();
819
}
820
 
821
void code1750_init(void)
822
{
823
  CPU1750 = AddCPU("1750", SwitchTo_1750);
824
  AddCopyright("MIL-STD 1750 Generator also (C) 2019 Oliver Kellogg");
825
}