Subversion Repositories pentevo

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1186 savelij 1
/* codeol40.c */
2
/*****************************************************************************/
3
/* SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only                     */
4
/*                                                                           */
5
/* AS-Portierung                                                             */
6
/*                                                                           */
7
/* Codegenerator OKI OLMS-40-Familie                                         */
8
/*                                                                           */
9
/*****************************************************************************/
10
 
11
#include "stdinc.h"
12
#include <string.h>
13
#include <ctype.h>
14
 
15
#include "bpemu.h"
16
#include "strutil.h"
17
#include "asmdef.h"
18
#include "asmsub.h"
19
#include "asmpars.h"
20
#include "asmitree.h"
21
#include "codepseudo.h"
22
#include "fourpseudo.h"
23
#include "codevars.h"
24
#include "headids.h"
25
#include "errmsg.h"
26
 
27
#include "codeol40.h"
28
 
29
typedef enum
30
{
31
  ModA = 0,
32
  ModDPL = 1,
33
  ModDPH = 2,
34
  ModW = 3,
35
  ModX = 4,
36
  ModY = 5,
37
  ModZ = 6,
38
  ModM = 7,
39
  ModImm = 10,
40
  ModPP = 11,
41
  ModT = 12,
42
  ModTL = 13,
43
  ModTH = 14,
44
  ModPPI = 15,
45
  ModNone = 0x7f
46
} tAdrMode;
47
 
48
#define MModA (1 << ModA)
49
#define MModDPL (1 << ModDPL)
50
#define MModDPH (1 << ModDPH)
51
#define MModW (1 << ModW)
52
#define MModX (1 << ModX)
53
#define MModY (1 << ModY)
54
#define MModZ (1 << ModZ)
55
#define MModM (1 << ModM)
56
#define MModImm (1 << ModImm)
57
#define MModPP (1 << ModPP)
58
#define MModT (1 << ModT)
59
#define MModTL (1 << ModTL)
60
#define MModTH (1 << ModTH)
61
#define MModPPI (1 << ModPPI)
62
 
63
static CPUVar CPU5840, CPU5842, CPU58421, CPU58422, CPU5847;
64
static IntType CodeIntType, DataIntType, OpSizeType;
65
static tAdrMode AdrMode;
66
static Byte AdrVal;
67
 
68
/*-------------------------------------------------------------------------*/
69
 
70
typedef struct
71
{
72
  const char *pAsc;
73
  tAdrMode AdrMode;
74
} tNotation;
75
 
76
static void DecodeAdr(const tStrComp *pArg, Word Mask)
77
{
78
  static const tNotation Notations[] =
79
  {
80
    { "A",    ModA    },
81
    { "M",    ModM    },
82
    { "(DP)", ModM    },
83
    { "W",    ModW    },
84
    { "X",    ModX    },
85
    { "Y",    ModY    },
86
    { "Z",    ModZ    },
87
    { "DPL",  ModDPL  },
88
    { "DPH",  ModDPH  },
89
    { "PP",   ModPP   },
90
    { "T",    ModT    },
91
    { "TL",   ModTL   },
92
    { "TH",   ModTH   },
93
    { "(PP)", ModPPI  },
94
    { NULL,   ModNone },
95
  };
96
  const tNotation *pNot;
97
  Boolean OK;
98
 
99
  if (MomCPU != CPU5840)
100
    Mask &= ~(MModX | MModY | MModZ | MModTL | MModTH);
101
  if (MomCPU  == CPU5847)
102
    Mask &= ~(MModW);
103
 
104
  for (pNot = Notations; pNot->pAsc; pNot++)
105
    if (!as_strcasecmp(pArg->str.p_str, pNot->pAsc))
106
    {
107
      AdrMode = pNot->AdrMode;
108
      goto AdrFound;
109
    }
110
 
111
  AdrVal = EvalStrIntExpressionOffs(pArg, !!(0[pArg->str.p_str] == '#'), OpSizeType, &OK);
112
  if (OK)
113
  {
114
    AdrMode = ModImm;
115
    AdrVal &= IntTypeDefs[OpSizeType].Mask;
116
  }
117
 
118
AdrFound:
119
 
120
  if ((AdrMode != ModNone) && (!(Mask & (1 << AdrMode))))
121
  {
122
    WrError(ErrNum_InvAddrMode);
123
    AdrMode = ModNone; AdrCnt = 0;
124
  }
125
}
126
 
127
/*-------------------------------------------------------------------------*/
128
 
129
static void DecodeLD(Word Code)
130
{
131
  UNUSED(Code);
132
 
133
  if (ChkArgCnt(2, 2))
134
  {
135
    DecodeAdr(&ArgStr[1], MModA | MModDPL | MModDPH | MModW | MModX | MModY | MModZ | MModPP | MModT);
136
    switch (AdrMode)
137
    {
138
      case ModA:
139
        DecodeAdr(&ArgStr[2], MModImm | MModW | MModX | MModY | MModZ | MModM | MModDPL | MModTL | MModTH);
140
        switch (AdrMode)
141
        {
142
          case ModW:
143
          case ModX:
144
          case ModY:
145
          case ModZ:
146
            BAsmCode[CodeLen++] = 0x84 | (AdrMode - ModW);
147
            break;
148
          case ModM:
149
            BAsmCode[CodeLen++] = 0x94;
150
            break;
151
          case ModDPL:
152
            BAsmCode[CodeLen++] = 0x55;
153
            break;
154
          case ModImm:
155
            BAsmCode[CodeLen++] = 0x10 | AdrVal;
156
            break;
157
          case ModTL:
158
          case ModTH:
159
            BAsmCode[CodeLen++] = 0x6b - (AdrMode - ModTL);
160
            break;
161
          default:
162
            break;
163
        }
164
        break;
165
      case ModDPL:
166
        DecodeAdr(&ArgStr[2], MModImm | MModA);
167
        switch (AdrMode)
168
        {
169
          case ModImm:
170
            BAsmCode[CodeLen++] = 0x20 | AdrVal;
171
            break;
172
          case ModA:
173
            BAsmCode[CodeLen++] = 0x54;
174
            break;
175
          default:
176
            break;
177
        }
178
        break;
179
      case ModDPH:
180
        DecodeAdr(&ArgStr[2], MModImm);
181
        switch (AdrMode)
182
        {
183
          case ModImm:
184
            BAsmCode[CodeLen++] = 0x60 | AdrVal;
185
            break;
186
          default:
187
            break;
188
        }
189
        break;
190
      case ModW:
191
      case ModX:
192
      case ModY:
193
      case ModZ:
194
      {
195
        tAdrMode HMode = AdrMode;
196
 
197
        DecodeAdr(&ArgStr[2], MModA);
198
        switch (AdrMode)
199
        {
200
          case ModA:
201
            BAsmCode[CodeLen++] = 0x80 | (HMode - ModW);
202
            break;
203
          default:
204
            break;
205
        }
206
        break;
207
      }
208
      case ModPP:
209
        DecodeAdr(&ArgStr[2], MModA);
210
        switch (AdrMode)
211
        {
212
          case ModA:
213
            BAsmCode[CodeLen++] = 0x58;
214
            break;
215
          default:
216
            break;
217
        }
218
        break;
219
      case ModT:
220
        OpSizeType = Int8;
221
        DecodeAdr(&ArgStr[2], MModImm);
222
        switch (AdrMode)
223
        {
224
          case ModImm:
225
            if (MomCPU == CPU5840)
226
            {
227
              BAsmCode[CodeLen++] = 0x68;
228
              BAsmCode[CodeLen++] = AdrVal;
229
            }
230
            else if (AdrVal) WrError(ErrNum_OverRange);
231
            else
232
              BAsmCode[CodeLen++] = 0x68;
233
            break;
234
          default:
235
            break;
236
        }
237
        break;
238
      default:
239
        break;
240
    }
241
  }
242
}
243
 
244
static void DecodeINCDEC(Word IsDEC)
245
{
246
  if (ChkArgCnt(1, 1))
247
  {
248
    DecodeAdr(&ArgStr[1], MModA | MModW | MModX | MModY | MModZ | MModDPL | MModM
249
                       | ((IsDEC && (MomCPU == CPU5840)) ? MModDPH : 0));
250
    switch (AdrMode)
251
    {
252
      case ModA:
253
        BAsmCode[CodeLen++] = IsDEC ? 0x0f : 0x01;
254
        break;
255
      case ModW:
256
      case ModX:
257
      case ModY:
258
      case ModZ:
259
        BAsmCode[CodeLen++] = (IsDEC ? 0x8c : 0x88) | (AdrMode - ModW);
260
        break;
261
      case ModM:
262
        BAsmCode[CodeLen++] = IsDEC ? 0x5c : 0x5d;
263
        break;
264
      case ModDPL:
265
        BAsmCode[CodeLen++] = IsDEC ? 0x56 : 0x57;
266
        break;
267
      case ModDPH:
268
        BAsmCode[CodeLen++] = 0x5f;
269
        break;
270
      default:
271
        break;
272
    }
273
  }
274
}
275
 
276
static void DecodeBit(Word Code)
277
{
278
  if (ArgCnt == 1)
279
  {
280
    if (!as_strcasecmp(ArgStr[1].str.p_str, "C"))
281
      BAsmCode[CodeLen++] = Hi(Code);
282
    else
283
      WrError(ErrNum_InvAddrMode);
284
  }
285
  else if (ChkArgCnt(1, 2))
286
  {
287
    Boolean OK;
288
    unsigned BitNo = EvalStrIntExpression(&ArgStr[2], UInt2, &OK);
289
 
290
    Code = Lo(Code);
291
 
292
    if (OK)
293
    {
294
      DecodeAdr(&ArgStr[1], ((Code == 2) ? MModA : MModPPI) | MModM);
295
      switch (AdrMode)
296
      {
297
        case ModA:
298
          BAsmCode[CodeLen++] = 0xa0 | BitNo;
299
          break;
300
        case ModM:
301
          if (Code == 2)
302
            BAsmCode[CodeLen++] = 0xa4 | BitNo;
303
          else
304
            BAsmCode[CodeLen++] = 0xb8 | (Code << 2) | BitNo;
305
          break;
306
        case ModPPI:
307
          BAsmCode[CodeLen++] = 0xb0 | (Code << 2) | BitNo;
308
          break;
309
        default:
310
          break;
311
      }
312
    }
313
  }
314
}
315
 
316
static void CodeFixed(Word Code)
317
{
318
  if (ChkArgCnt(0, 0)
319
   && (ChkExactCPUMask(Hi(Code), CPU5840) >= 0))
320
    BAsmCode[CodeLen++] = Lo(Code);
321
}
322
 
323
static void CodeTHB(Word Code)
324
{
325
  if (ChkArgCnt(1, 1)
326
   && (ChkExactCPUMask(Hi(Code), CPU5840) >= 0))
327
  {
328
    Boolean OK = True;
329
    Word ImmVal = ArgCnt ? EvalStrIntExpression(&ArgStr[1], UInt1, &OK) : 0;
330
 
331
    if (OK)
332
    {
333
      if ((MomCPU == CPU5840) || (MomCPU == CPU5842))
334
        BAsmCode[CodeLen++] = Lo(Code) | (ImmVal & 1);
335
      else if (ImmVal) WrError(ErrNum_OverRange);
336
      else
337
        BAsmCode[CodeLen++] = Lo(Code);
338
    }
339
  }
340
}
341
 
342
static void CodeImm2(Word Code)
343
{
344
  if (ChkArgCnt(1, 1)
345
   && (ChkExactCPUMask(Hi(Code), CPU5840) >= 0))
346
  {
347
    Boolean OK;
348
    Word ImmVal = EvalStrIntExpression(&ArgStr[1], UInt2, &OK);
349
 
350
    if (OK)
351
      BAsmCode[CodeLen++] = Lo(Code) | (ImmVal & 3);
352
  }
353
}
354
 
355
static void CodeImm4(Word Code)
356
{
357
  if (ChkArgCnt(1, 1)
358
   && (ChkExactCPUMask(Hi(Code), CPU5840) >= 0))
359
  {
360
    Boolean OK;
361
    Word ImmVal = EvalStrIntExpression(&ArgStr[1], Int4, &OK);
362
 
363
    if (OK)
364
      BAsmCode[CodeLen++] = Lo(Code) | (ImmVal & 15);
365
  }
366
}
367
 
368
static void CodeLTI(Word Code)
369
{
370
  if (ChkArgCnt(0, 1)
371
   && (ChkExactCPUMask(Hi(Code), CPU5840) >= 0))
372
  {
373
    Boolean OK = True;
374
    Word ImmVal = ArgCnt ? EvalStrIntExpression(&ArgStr[1], Int8, &OK) : 0;
375
 
376
    if (OK)
377
    {
378
      /* LTI can only load 0 into timer on smaller devices */
379
 
380
      if (MomCPU == CPU5840)
381
      {
382
        BAsmCode[CodeLen++] = Lo(Code);
383
        BAsmCode[CodeLen++] = Lo(ImmVal);
384
      }
385
      else if (ImmVal != 0) WrError(ErrNum_OverRange);
386
      else
387
        BAsmCode[CodeLen++] = Lo(Code);
388
    }
389
  }
390
}
391
 
392
static void CodeJC(Word Code)
393
{
394
  if (ChkArgCnt(1, 1)
395
   && (ChkExactCPUMask(Hi(Code), CPU5840) >= 0))
396
  {
397
    tEvalResult EvalResult;
398
    Word Address = EvalStrIntExpressionWithResult(&ArgStr[1], CodeIntType, &EvalResult);
399
    if (EvalResult.OK && ChkSamePage(EProgCounter() + 1, Address, 6, EvalResult.Flags))
400
    {
401
      ChkSpace(SegCode, EvalResult.AddrSpaceMask);
402
      BAsmCode[CodeLen++] = Lo(Code) | (Address & 0x3f);
403
    }
404
  }
405
}
406
 
407
static void CodeJMP(Word Code)
408
{
409
  if (ChkArgCnt(1, 1)
410
   && (ChkExactCPUMask(Hi(Code), CPU5840) >= 0))
411
  {
412
    tEvalResult EvalResult;
413
    Word Address= EvalStrIntExpressionWithResult(&ArgStr[1], CodeIntType, &EvalResult);
414
    if (EvalResult.OK)
415
    {
416
      ChkSpace(SegCode, EvalResult.AddrSpaceMask);
417
      BAsmCode[CodeLen++] = Lo(Code) | (Hi(Address) & 0x07);
418
      BAsmCode[CodeLen++] = Lo(Address);
419
    }
420
  }
421
}
422
 
423
static void DecodeDATA_OLMS40(Word Code)
424
{
425
  UNUSED(Code);
426
 
427
  DecodeDATA(Int8, Int4);
428
}
429
 
430
static void DecodeSFR(Word Code)
431
{
432
  UNUSED(Code);
433
 
434
  CodeEquate(SegData, 0, SegLimits[SegData]);
435
}
436
 
437
/*-------------------------------------------------------------------------*/
438
 
439
static void InitFields(void)
440
{
441
  InstTable = CreateInstTable(201);
442
 
443
  add_null_pseudo(InstTable);
444
 
445
  AddInstTable(InstTable, "LD", 0, DecodeLD);
446
  AddInstTable(InstTable, "INC", 0, DecodeINCDEC);
447
  AddInstTable(InstTable, "DEC", 1, DecodeINCDEC);
448
  AddInstTable(InstTable, "BSET", 0x4000, DecodeBit);
449
  AddInstTable(InstTable, "BCLR", 0x4101, DecodeBit);
450
  AddInstTable(InstTable, "BTST", 0x4202, DecodeBit);
451
 
452
  AddInstTable(InstTable, "CLA",    0x1f10, CodeFixed);
453
  AddInstTable(InstTable, "CLL",    0x1f20, CodeFixed);
454
  AddInstTable(InstTable, "CLH",    0x1f60, CodeFixed);
455
  AddInstTable(InstTable, "L",      0x1f94, CodeFixed);
456
  AddInstTable(InstTable, "LAL",    0x1f55, CodeFixed);
457
  AddInstTable(InstTable, "LLA",    0x1f54, CodeFixed);
458
  AddInstTable(InstTable, "LAW",    0x0f84, CodeFixed);
459
  AddInstTable(InstTable, "LAX",    0x0185, CodeFixed);
460
  AddInstTable(InstTable, "LAY",    0x0186, CodeFixed);
461
  AddInstTable(InstTable, "LAZ",    0x0187, CodeFixed);
462
  AddInstTable(InstTable, "SI",     0x1f90, CodeFixed);
463
  AddInstTable(InstTable, "LWA",    0x0f80, CodeFixed);
464
  AddInstTable(InstTable, "LXA",    0x0181, CodeFixed);
465
  AddInstTable(InstTable, "LYA",    0x0182, CodeFixed);
466
  AddInstTable(InstTable, "LZA",    0x0183, CodeFixed);
467
  AddInstTable(InstTable, "LPA",    0x1f58, CodeFixed);
468
  AddInstTable(InstTable, "RTH",    0x016a, CodeFixed);
469
  AddInstTable(InstTable, "RTL",    0x016b, CodeFixed);
470
  AddInstTable(InstTable, "XA",     0x0149, CodeFixed);
471
  AddInstTable(InstTable, "XL",     0x014a, CodeFixed);
472
  AddInstTable(InstTable, "XCH",    0x0148, CodeFixed);
473
  AddInstTable(InstTable, "X",      0x1f98, CodeFixed);
474
  AddInstTable(InstTable, "XAX",    0x014b, CodeFixed);
475
  AddInstTable(InstTable, "INA",    0x0f01, CodeFixed);
476
  AddInstTable(InstTable, "INL",    0x0f57, CodeFixed);
477
  AddInstTable(InstTable, "INM",    0x1f5d, CodeFixed);
478
  AddInstTable(InstTable, "INW",    0x0f88, CodeFixed);
479
  AddInstTable(InstTable, "INX",    0x0189, CodeFixed);
480
  AddInstTable(InstTable, "INY",    0x018a, CodeFixed);
481
  AddInstTable(InstTable, "INZ",    0x018b, CodeFixed);
482
  AddInstTable(InstTable, "DCA",    0x0f0f, CodeFixed);
483
  AddInstTable(InstTable, "DCL",    0x0f56, CodeFixed);
484
  AddInstTable(InstTable, "DCM",    0x1f5c, CodeFixed);
485
  AddInstTable(InstTable, "DCW",    0x018c, CodeFixed);
486
  AddInstTable(InstTable, "DCX",    0x018d, CodeFixed);
487
  AddInstTable(InstTable, "DCY",    0x018e, CodeFixed);
488
  AddInstTable(InstTable, "DCZ",    0x018f, CodeFixed);
489
  AddInstTable(InstTable, "DCH",    0x015f, CodeFixed);
490
  AddInstTable(InstTable, "CAO",    0x1f50, CodeFixed);
491
  AddInstTable(InstTable, "AND",    0x0144, CodeFixed);
492
  AddInstTable(InstTable, "OR",     0x0145, CodeFixed);
493
  AddInstTable(InstTable, "EOR",    0x0146, CodeFixed);
494
  AddInstTable(InstTable, "RAL",    0x1f47, CodeFixed);
495
  AddInstTable(InstTable, "AC",     0x1f4c, CodeFixed);
496
  AddInstTable(InstTable, "ACS",    0x014d, CodeFixed);
497
  AddInstTable(InstTable, "AS",     0x1f4e, CodeFixed);
498
  AddInstTable(InstTable, "DAS",    0x1f5a, CodeFixed);
499
  AddInstTable(InstTable, "CM",     0x1f5e, CodeFixed);
500
  AddInstTable(InstTable, "AWS",    0x019c, CodeFixed);
501
  AddInstTable(InstTable, "AXS",    0x019d, CodeFixed);
502
  AddInstTable(InstTable, "AYS",    0x019e, CodeFixed);
503
  AddInstTable(InstTable, "AZS",    0x019f, CodeFixed);
504
  AddInstTable(InstTable, "TI",     0x01af, CodeFixed);
505
  AddInstTable(InstTable, "TTM",    0x1fae, CodeFixed);
506
  AddInstTable(InstTable, "TC",     0x1f42, CodeFixed);
507
  AddInstTable(InstTable, "SC",     0x1f40, CodeFixed);
508
  AddInstTable(InstTable, "RC",     0x1f41, CodeFixed);
509
  AddInstTable(InstTable, "JA",     0x1f43, CodeFixed);
510
  AddInstTable(InstTable, "RT",     0x1f59, CodeFixed);
511
  AddInstTable(InstTable, "OBS",    0x0170, CodeFixed);
512
  AddInstTable(InstTable, "OTD",    0x1f71, CodeFixed);
513
  AddInstTable(InstTable, "OA",     0x1f72, CodeFixed);
514
  AddInstTable(InstTable, "OB",     0x1f73, CodeFixed);
515
  AddInstTable(InstTable, "OP",     0x1f74, CodeFixed);
516
  AddInstTable(InstTable, "OAB",    0x0175, CodeFixed);
517
  AddInstTable(InstTable, "OPM",    0x1f76, CodeFixed);
518
  AddInstTable(InstTable, "IA",     0x1f7a, CodeFixed);
519
  AddInstTable(InstTable, "IB",     0x1f7b, CodeFixed);
520
  AddInstTable(InstTable, "IK",     0x0f7c, CodeFixed);
521
  AddInstTable(InstTable, "IAB",    0x017d, CodeFixed);
522
  AddInstTable(InstTable, "EI",     0x0153, CodeFixed);
523
  AddInstTable(InstTable, "DI",     0x0152, CodeFixed);
524
  AddInstTable(InstTable, "ET",     0x016f, CodeFixed);
525
  AddInstTable(InstTable, "DT",     0x016e, CodeFixed);
526
  AddInstTable(InstTable, "ECT",    0x017f, CodeFixed);
527
  AddInstTable(InstTable, "DCT",    0x017e, CodeFixed);
528
  AddInstTable(InstTable, "HLT",    0x016d, CodeFixed);
529
  AddInstTable(InstTable, "EXP",    0x0169, CodeFixed);
530
  AddInstTable(InstTable, "NOP",    0x1f00, CodeFixed);
531
 
532
  AddInstTable(InstTable, "THB",    0x0fac, CodeTHB);
533
 
534
  AddInstTable(InstTable, "LM",     0x0194, CodeImm2);
535
  AddInstTable(InstTable, "SMI",    0x0190, CodeImm2);
536
  AddInstTable(InstTable, "XM",     0x0198, CodeImm2);
537
  AddInstTable(InstTable, "SPB",    0x01b0, CodeImm2);
538
  AddInstTable(InstTable, "RPB",    0x01b4, CodeImm2);
539
  AddInstTable(InstTable, "SMB",    0x1fb8, CodeImm2);
540
  AddInstTable(InstTable, "RMB",    0x1fbc, CodeImm2);
541
  AddInstTable(InstTable, "TAB",    0x1fa0, CodeImm2);
542
  AddInstTable(InstTable, "TMB",    0x1fa4, CodeImm2);
543
  AddInstTable(InstTable, "TKB",    0x01a8, CodeImm2);
544
 
545
  AddInstTable(InstTable, "LAI",    0x1f10, CodeImm4);
546
  AddInstTable(InstTable, "LLI",    0x1f20, CodeImm4);
547
  AddInstTable(InstTable, "LHI",    0x1f60, CodeImm4);
548
  AddInstTable(InstTable, "AIS",    0x1f00, CodeImm4);
549
 
550
  AddInstTable(InstTable, "LTI",    0x1f68, CodeLTI);
551
 
552
  AddInstTable(InstTable, "JC",     0x1fc0, CodeJC);
553
 
554
  AddInstTable(InstTable, "J",      0x1f30, CodeJMP);
555
  AddInstTable(InstTable, "CAL",    0x1f38, CodeJMP);
556
 
557
  AddInstTable(InstTable, "RES", 0, DecodeRES);
558
  AddInstTable(InstTable, "DATA", 0, DecodeDATA_OLMS40);
559
  AddInstTable(InstTable, "SFR", 0, DecodeSFR);
560
}
561
 
562
static void DeinitFields(void)
563
{
564
  DestroyInstTable(InstTable);
565
}
566
 
567
/*-------------------------------------------------------------------------*/
568
 
569
static void  MakeCode_OLMS40(void)
570
{
571
  OpSizeType = Int4;
572
 
573
  if (!LookupInstTable(InstTable, OpPart.str.p_str))
574
    WrStrErrorPos(ErrNum_UnknownInstruction, &OpPart);
575
}
576
 
577
 
578
static Boolean IsDef_OLMS40(void)
579
{
580
  return False;
581
}
582
 
583
static void SwitchFrom_OLMS40(void)
584
{
585
  DeinitFields();
586
}
587
 
588
static void SwitchTo_OLMS40(void)
589
{
590
  const TFamilyDescr *pDescr;
591
 
592
  pDescr = FindFamilyByName("OLMS-40");
593
 
594
  TurnWords = False;
595
  SetIntConstMode(eIntConstModeIntel);
596
 
597
  PCSymbol = "$";
598
  HeaderID = pDescr->Id;
599
  NOPCode = 0x00;
600
  DivideChars = ",";
601
  HasAttrs = False;
602
 
603
  ValidSegs = (1 << SegCode) | (1 << SegData);
604
  Grans[SegCode] = 1; ListGrans[SegCode] = 1; SegInits[SegCode] = 0;
605
  Grans[SegData] = 1; ListGrans[SegData] = 1; SegInits[SegCode] = 0;
606
  if (MomCPU == CPU5840)
607
  {
608
    CodeIntType = UInt11;
609
    DataIntType = UInt7;
610
    SegLimits[SegData] = IntTypeDefs[DataIntType].Max;
611
    SegLimits[SegCode] = IntTypeDefs[CodeIntType].Max;
612
  }
613
  else if (MomCPU == CPU5842)
614
  {
615
    CodeIntType = UInt10;
616
    DataIntType = UInt5;
617
    SegLimits[SegData] = IntTypeDefs[DataIntType].Max;
618
    SegLimits[SegCode] = 767;
619
  }
620
  else if ((MomCPU == CPU58421) || (MomCPU == CPU58422))
621
  {
622
    CodeIntType = UInt11;
623
    DataIntType = UInt6;
624
    SegLimits[SegData] = 39;
625
    SegLimits[SegCode] = 1535;
626
  }
627
  else if (MomCPU == CPU5847)
628
  {
629
    CodeIntType = UInt11;
630
    DataIntType = UInt7;
631
    SegLimits[SegData] = 95;
632
    SegLimits[SegCode] = 1535;
633
  }
634
 
635
  MakeCode = MakeCode_OLMS40;
636
  IsDef = IsDef_OLMS40;
637
  SwitchFrom = SwitchFrom_OLMS40; InitFields();
638
 
639
}
640
 
641
void codeolms40_init(void)
642
{
643
  CPU5840  = AddCPU("MSM5840" , SwitchTo_OLMS40);
644
  CPU5842  = AddCPU("MSM5842" , SwitchTo_OLMS40);
645
  CPU58421 = AddCPU("MSM58421", SwitchTo_OLMS40);
646
  CPU58422 = AddCPU("MSM58422", SwitchTo_OLMS40);
647
  CPU5847  = AddCPU("MSM5847" , SwitchTo_OLMS40);
648
}