Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1126 | savelij | 1 | /* |
2 | * AS-Portierung |
||
3 | * |
||
4 | * AS-Codegeneratormodul fuer die Texas Instruments TMS320C5x-Familie |
||
5 | * |
||
6 | */ |
||
7 | |||
8 | #include "stdinc.h" |
||
9 | #include <string.h> |
||
10 | #include <ctype.h> |
||
11 | |||
12 | #include "nls.h" |
||
13 | #include "bpemu.h" |
||
14 | #include "strutil.h" |
||
15 | #include "chunks.h" |
||
16 | #include "errmsg.h" |
||
17 | #include "asmdef.h" |
||
18 | #include "asmsub.h" |
||
19 | #include "asmpars.h" |
||
20 | #include "asmitree.h" |
||
21 | #include "codepseudo.h" |
||
22 | #include "codevars.h" |
||
23 | #include "tipseudo.h" |
||
24 | #include "be_le.h" |
||
25 | #include "errmsg.h" |
||
26 | |||
27 | #include "code3205x.h" |
||
28 | |||
29 | /* ---------------------------------------------------------------------- */ |
||
30 | |||
31 | typedef struct |
||
32 | { |
||
33 | CPUVar MinCPU; |
||
34 | Word Code; |
||
35 | } FixedOrder; |
||
36 | |||
37 | typedef struct |
||
38 | { |
||
39 | CPUVar MinCPU; |
||
40 | Word Code; |
||
41 | Boolean Cond; |
||
42 | } JmpOrder; |
||
43 | |||
44 | typedef struct |
||
45 | { |
||
46 | const char *Name; |
||
47 | CPUVar MinCPU; |
||
48 | Word Mode; |
||
49 | } tAdrMode; |
||
50 | |||
51 | typedef struct |
||
52 | { |
||
53 | const char *Name; |
||
54 | CPUVar MinCPU; |
||
55 | Word CodeAND; |
||
56 | Word CodeOR; |
||
57 | Byte IsZL; |
||
58 | Byte IsC; |
||
59 | Byte IsV; |
||
60 | Byte IsTP; |
||
61 | } Condition; |
||
62 | |||
63 | typedef struct |
||
64 | { |
||
65 | const char *name; |
||
66 | CPUVar MinCPU; |
||
67 | Word Code; |
||
68 | } tBitTable; |
||
69 | |||
70 | #define NOCONDITION 0xffff |
||
71 | |||
72 | static FixedOrder *FixedOrders; |
||
73 | static FixedOrder *AdrOrders; |
||
74 | static JmpOrder *JmpOrders; |
||
75 | static FixedOrder *PluOrders; |
||
76 | static tAdrMode *AdrModes; |
||
77 | static Condition *Conditions; |
||
78 | static tBitTable *BitTable; |
||
79 | |||
80 | static Word AdrMode; |
||
81 | |||
82 | static CPUVar CPU320203; |
||
83 | static CPUVar CPU32050; |
||
84 | static CPUVar CPU32051; |
||
85 | static CPUVar CPU32053; |
||
86 | |||
87 | /* ---------------------------------------------------------------------- */ |
||
88 | |||
89 | static Word EvalARExpression(const tStrComp *pArg, Boolean *OK) |
||
90 | { |
||
91 | *OK = True; |
||
92 | |||
93 | if ((as_toupper(pArg->str.p_str[0]) == 'A') |
||
94 | && (as_toupper(pArg->str.p_str[1]) == 'R') |
||
95 | && (pArg->str.p_str[2] >= '0') |
||
96 | && (pArg->str.p_str[2] <= '7') |
||
97 | && (pArg->str.p_str[3] <= '\0')) |
||
98 | return pArg->str.p_str[2] - '0'; |
||
99 | return EvalStrIntExpression(pArg, UInt3, OK); |
||
100 | } |
||
101 | |||
102 | /* ---------------------------------------------------------------------- */ |
||
103 | |||
104 | static Boolean DecodeAdr(const tStrComp *pArg, int MinArgCnt, int aux, Boolean Must1) |
||
105 | { |
||
106 | Word h; |
||
107 | tAdrMode *pAdrMode = AdrModes; |
||
108 | tEvalResult EvalResult; |
||
109 | |||
110 | /* Annahme: nicht gefunden */ |
||
111 | |||
112 | Boolean AdrOK = False; |
||
113 | |||
114 | /* Adressierungsmodus suchen */ |
||
115 | |||
116 | while (pAdrMode->Name && as_strcasecmp(pAdrMode->Name, pArg->str.p_str)) |
||
117 | pAdrMode++; |
||
118 | |||
119 | /* nicht gefunden: dann absolut */ |
||
120 | |||
121 | if (!pAdrMode->Name) |
||
122 | { |
||
123 | /* ARn-Register darf dann nicht vorhanden sein */ |
||
124 | |||
125 | if (aux <= ArgCnt) |
||
126 | { |
||
127 | (void)ChkArgCnt(MinArgCnt, aux - 1); |
||
128 | return False; |
||
129 | } |
||
130 | |||
131 | /* Adresse berechnen */ |
||
132 | |||
133 | h = EvalStrIntExpressionWithResult(pArg, Int16, &EvalResult); |
||
134 | if (!EvalResult.OK) |
||
135 | return False; |
||
136 | AdrOK = True; |
||
137 | |||
138 | /* Adresslage pruefen */ |
||
139 | |||
140 | if (Must1 && (h >= 0x80) && !mFirstPassUnknown(EvalResult.Flags)) |
||
141 | { |
||
142 | WrError(ErrNum_UnderRange); |
||
143 | return False; |
||
144 | } |
||
145 | |||
146 | /* nur untere 7 Bit gespeichert */ |
||
147 | |||
148 | AdrMode = h & 0x7f; |
||
149 | ChkSpace(SegData, EvalResult.AddrSpaceMask); |
||
150 | } |
||
151 | |||
152 | /* ansonsten evtl. noch Adressregister dazu */ |
||
153 | |||
154 | else |
||
155 | { |
||
156 | /* auf dieser CPU nicht erlaubter Modus ? */ |
||
157 | |||
158 | if (!ChkMinCPUExt(pAdrMode->MinCPU, ErrNum_AddrModeNotSupported)) |
||
159 | return False; |
||
160 | |||
161 | AdrMode = pAdrMode->Mode; |
||
162 | if (aux <= ArgCnt) |
||
163 | { |
||
164 | h = EvalARExpression(&ArgStr[aux], &AdrOK); |
||
165 | if (AdrOK) AdrMode |= 0x8 | h; |
||
166 | } |
||
167 | else |
||
168 | AdrOK = True; |
||
169 | } |
||
170 | |||
171 | return AdrOK; |
||
172 | } |
||
173 | |||
174 | /* ---------------------------------------------------------------------- */ |
||
175 | |||
176 | static Word DecodeCond(int argp) |
||
177 | { |
||
178 | Condition *pCondition; |
||
179 | Byte cntzl = 0, cntc = 0, cntv = 0, cnttp = 0; |
||
180 | Word ret = 0x300; |
||
181 | |||
182 | while (argp <= ArgCnt) |
||
183 | { |
||
184 | for (pCondition = Conditions; pCondition->Name && as_strcasecmp(pCondition->Name, ArgStr[argp].str.p_str); pCondition++); |
||
185 | |||
186 | if (!pCondition->Name) |
||
187 | { |
||
188 | WrError(ErrNum_UndefCond); |
||
189 | return ret; |
||
190 | } |
||
191 | ret &= pCondition->CodeAND; |
||
192 | ret |= pCondition->CodeOR; |
||
193 | cntzl += pCondition->IsZL; |
||
194 | cntc += pCondition->IsC; |
||
195 | cntv += pCondition->IsV; |
||
196 | cnttp += pCondition->IsTP; |
||
197 | argp++; |
||
198 | } |
||
199 | |||
200 | if ((cnttp > 1) || (cntzl > 1) || (cntv > 1) || (cntc > 1)) |
||
201 | WrStrErrorPos(ErrNum_UndefCond, &ArgStr[argp]); |
||
202 | |||
203 | return ret; |
||
204 | } |
||
205 | |||
206 | /* ---------------------------------------------------------------------- */ |
||
207 | |||
208 | static Word DecodeShift(const tStrComp *pArg, Boolean *OK) |
||
209 | { |
||
210 | Word Shift; |
||
211 | tSymbolFlags Flags; |
||
212 | |||
213 | Shift = EvalStrIntExpressionWithFlags(pArg, UInt5, OK, &Flags); |
||
214 | if (*OK) |
||
215 | { |
||
216 | if (mFirstPassUnknown(Flags)) Shift &= 15; |
||
217 | *OK = ChkRange(Shift, 0, 16); |
||
218 | } |
||
219 | return Shift; |
||
220 | } |
||
221 | |||
222 | /* ---------------------------------------------------------------------- */ |
||
223 | |||
224 | static void DecodeFixed(Word Index) |
||
225 | { |
||
226 | const FixedOrder *pOrder = FixedOrders + Index; |
||
227 | |||
228 | if (ChkArgCnt(0, 0) |
||
229 | && ChkMinCPU(pOrder->MinCPU)) |
||
230 | { |
||
231 | CodeLen = 1; |
||
232 | WAsmCode[0] = pOrder->Code; |
||
233 | } |
||
234 | } |
||
235 | |||
236 | static void DecodeCmdAdr(Word Index) |
||
237 | { |
||
238 | const FixedOrder *pOrder = AdrOrders + Index; |
||
239 | |||
240 | if (ChkArgCnt(1, 2) |
||
241 | && ChkMinCPU(pOrder->MinCPU) |
||
242 | && DecodeAdr(&ArgStr[1], 1, 2, False)) |
||
243 | { |
||
244 | CodeLen = 1; |
||
245 | WAsmCode[0] = pOrder->Code | AdrMode; |
||
246 | } |
||
247 | } |
||
248 | |||
249 | static void DecodeCmdJmp(Word Index) |
||
250 | { |
||
251 | const JmpOrder *pOrder = JmpOrders + Index; |
||
252 | |||
253 | if (ChkMinCPU(pOrder->MinCPU) |
||
254 | && ChkArgCnt(1, pOrder->Cond ? ArgCntMax : 3)) |
||
255 | { |
||
256 | Boolean OK; |
||
257 | |||
258 | AdrMode = 0; |
||
259 | if (pOrder->Cond) |
||
260 | { |
||
261 | AdrMode = DecodeCond(2); |
||
262 | OK = AdrMode != NOCONDITION; |
||
263 | } |
||
264 | else if (ArgCnt > 1) |
||
265 | { |
||
266 | OK = DecodeAdr(&ArgStr[2], 1, 3, False); |
||
267 | if ((AdrMode < 0x80) && (OK)) |
||
268 | { |
||
269 | WrError(ErrNum_InvAddrMode); |
||
270 | OK = FALSE; |
||
271 | } |
||
272 | AdrMode &= 0x7f; |
||
273 | } |
||
274 | else |
||
275 | OK = TRUE; |
||
276 | |||
277 | if (OK) |
||
278 | { |
||
279 | WAsmCode[1] = EvalStrIntExpression(&ArgStr[1], Int16, &OK); |
||
280 | if (OK) |
||
281 | { |
||
282 | CodeLen = 2; |
||
283 | WAsmCode[0] = pOrder->Code | AdrMode; |
||
284 | } |
||
285 | } |
||
286 | } |
||
287 | } |
||
288 | |||
289 | static void DecodeCmdPlu(Word Index) |
||
290 | { |
||
291 | Boolean OK; |
||
292 | const FixedOrder *pOrder = PluOrders + Index; |
||
293 | |||
294 | if (!ChkMinCPU(pOrder->MinCPU)); |
||
295 | else if (*ArgStr[1].str.p_str == '#') |
||
296 | { |
||
297 | if (ChkArgCnt(2, 3)) |
||
298 | { |
||
299 | WAsmCode[1] = EvalStrIntExpressionOffs(&ArgStr[1], 1, Int16, &OK); |
||
300 | if ((OK) && (DecodeAdr(&ArgStr[2], 2, 3, False))) |
||
301 | { |
||
302 | CodeLen = 2; |
||
303 | WAsmCode[0] = pOrder->Code | 0x0400 | AdrMode; |
||
304 | } |
||
305 | } |
||
306 | } |
||
307 | else if (strlen(OpPart.str.p_str) == 4) WrError(ErrNum_OnlyImmAddr); |
||
308 | else |
||
309 | { |
||
310 | if (ChkArgCnt(1, 2)) |
||
311 | { |
||
312 | if (DecodeAdr(&ArgStr[1], 1, 2, False)) |
||
313 | { |
||
314 | CodeLen = 1; |
||
315 | WAsmCode[0] = pOrder->Code | AdrMode; |
||
316 | } |
||
317 | } |
||
318 | } |
||
319 | } |
||
320 | |||
321 | static void DecodeADDSUB(Word Index) |
||
322 | { |
||
323 | Word Shift; |
||
324 | LongInt AdrLong; |
||
325 | Boolean OK; |
||
326 | |||
327 | if (ChkArgCnt(1, 3)) |
||
328 | { |
||
329 | if (*ArgStr[1].str.p_str == '#') |
||
330 | { |
||
331 | if (ChkArgCnt(1, 2)) |
||
332 | { |
||
333 | OK = True; |
||
334 | Shift = (ArgCnt == 1) ? 0 : EvalStrIntExpression(&ArgStr[2], UInt4, &OK); |
||
335 | if (OK) |
||
336 | { |
||
337 | AdrLong = EvalStrIntExpressionOffs(&ArgStr[1], 1, UInt16, &OK); |
||
338 | if (OK) |
||
339 | { |
||
340 | if ((Shift == 0) && (Hi(AdrLong) == 0)) |
||
341 | { |
||
342 | CodeLen = 1; |
||
343 | WAsmCode[0] = (Index << 9) | 0xb800 | (AdrLong & 0xff); |
||
344 | } |
||
345 | else |
||
346 | { |
||
347 | CodeLen = 2; |
||
348 | WAsmCode[0] = ((Index << 4) + 0xbf90) | (Shift & 0xf); |
||
349 | WAsmCode[1] = AdrLong; |
||
350 | } |
||
351 | } |
||
352 | } |
||
353 | } |
||
354 | } |
||
355 | else |
||
356 | { |
||
357 | if (DecodeAdr(&ArgStr[1], 1, 3, False)) |
||
358 | { |
||
359 | OK = True; |
||
360 | Shift = (ArgCnt >= 2) ? DecodeShift(&ArgStr[2], &OK) : 0; |
||
361 | if (OK) |
||
362 | { |
||
363 | CodeLen = 1; |
||
364 | if (Shift == 16) |
||
365 | WAsmCode[0] = ((Index << 10) | 0x6100) | AdrMode; |
||
366 | else |
||
367 | WAsmCode[0] = ((Index << 12) | 0x2000) | ((Shift & 0xf) << 8) | AdrMode; |
||
368 | } |
||
369 | } |
||
370 | } |
||
371 | } |
||
372 | } |
||
373 | |||
374 | static void DecodeADRSBRK(Word Index) |
||
375 | { |
||
376 | Word adr_word; |
||
377 | Boolean OK; |
||
378 | |||
379 | if (!ChkArgCnt(1, 1)) |
||
380 | return; |
||
381 | |||
382 | if (*ArgStr[1].str.p_str != '#') |
||
383 | { |
||
384 | WrError(ErrNum_OnlyImmAddr); /*invalid parameter*/ |
||
385 | return; |
||
386 | } |
||
387 | |||
388 | adr_word = EvalStrIntExpressionOffs(&ArgStr[1], 1, UInt8, &OK); |
||
389 | if (OK) |
||
390 | { |
||
391 | CodeLen = 1; |
||
392 | WAsmCode[0] = (Index << 10)| 0x7800 | (adr_word & 0xff); |
||
393 | } |
||
394 | } |
||
395 | |||
396 | static void DecodeLogic(Word Index) |
||
397 | { |
||
398 | Boolean OK; |
||
399 | Word Shift; |
||
400 | |||
401 | if (!ChkArgCnt(1, 2)); |
||
402 | else if (*ArgStr[1].str.p_str == '#') |
||
403 | { |
||
404 | WAsmCode[1] = EvalStrIntExpressionOffs(&ArgStr[1], 1, UInt16, &OK); |
||
405 | if (OK) |
||
406 | { |
||
407 | OK = True; |
||
408 | Shift = (ArgCnt >= 2) ? DecodeShift(&ArgStr[2], &OK) : 0; |
||
409 | if (OK) |
||
410 | { |
||
411 | CodeLen = 2; |
||
412 | if (Shift >= 16) |
||
413 | WAsmCode[0] = 0xbe80 | Lo(Index); |
||
414 | else |
||
415 | WAsmCode[0] = 0xbfa0 + ((Index & 3) << 4) + (Shift & 0xf); |
||
416 | } |
||
417 | } |
||
418 | } |
||
419 | else |
||
420 | { |
||
421 | if (DecodeAdr(&ArgStr[1], 1, 2, False)) |
||
422 | { |
||
423 | CodeLen = 1; |
||
424 | WAsmCode[0] = (Index & 0xff00) | AdrMode; |
||
425 | } |
||
426 | } |
||
427 | } |
||
428 | |||
429 | static void DecodeBIT(Word Index) |
||
430 | { |
||
431 | Word bit; |
||
432 | Boolean OK; |
||
433 | UNUSED(Index); |
||
434 | |||
435 | if (ChkArgCnt(2, 3)) |
||
436 | { |
||
437 | bit = EvalStrIntExpression(&ArgStr[2], UInt4, &OK); |
||
438 | if ((OK) && (DecodeAdr(&ArgStr[1], 2, 3, False))) |
||
439 | { |
||
440 | CodeLen = 1; |
||
441 | WAsmCode[0] = 0x4000 | AdrMode | ((bit & 0xf) << 8); |
||
442 | } |
||
443 | } |
||
444 | } |
||
445 | |||
446 | static void DecodeBLDD(Word Index) |
||
447 | { |
||
448 | Boolean OK; |
||
449 | UNUSED(Index); |
||
450 | |||
451 | if (!ChkArgCnt(2, 3)); |
||
452 | else if (!as_strcasecmp(ArgStr[1].str.p_str, "BMAR")) |
||
453 | { |
||
454 | if (ChkMinCPU(CPU32050)) |
||
455 | { |
||
456 | if (DecodeAdr(&ArgStr[2], 2, 3, False)) |
||
457 | { |
||
458 | CodeLen = 1; |
||
459 | WAsmCode[0] = 0xac00 | AdrMode; |
||
460 | } |
||
461 | } |
||
462 | } |
||
463 | else if (!as_strcasecmp(ArgStr[2].str.p_str, "BMAR")) |
||
464 | { |
||
465 | if (ChkMinCPU(CPU32050)) |
||
466 | { |
||
467 | if (DecodeAdr(&ArgStr[1], 2, 3, False)) |
||
468 | { |
||
469 | CodeLen = 1; |
||
470 | WAsmCode[0] = 0xad00 | AdrMode; |
||
471 | } |
||
472 | } |
||
473 | } |
||
474 | else if (*ArgStr[1].str.p_str == '#') |
||
475 | { |
||
476 | WAsmCode[1] = EvalStrIntExpressionOffs(&ArgStr[1], 1, Int16, &OK); |
||
477 | if ((OK) && (DecodeAdr(&ArgStr[2], 2, 3, False))) |
||
478 | { |
||
479 | CodeLen = 2; |
||
480 | WAsmCode[0] = 0xa800 | AdrMode; |
||
481 | } |
||
482 | } |
||
483 | else if (*ArgStr[2].str.p_str == '#') |
||
484 | { |
||
485 | WAsmCode[1] = EvalStrIntExpressionOffs(&ArgStr[2], 1, Int16, &OK); |
||
486 | if ((OK) && (DecodeAdr(&ArgStr[1], 2, 3, False))) |
||
487 | { |
||
488 | CodeLen = 2; |
||
489 | WAsmCode[0] = 0xa900 | AdrMode; |
||
490 | } |
||
491 | } |
||
492 | else |
||
493 | WrError(ErrNum_InvAddrMode); /* invalid addr mode */ |
||
494 | } |
||
495 | |||
496 | static void DecodeBLPD(Word Index) |
||
497 | { |
||
498 | Boolean OK; |
||
499 | UNUSED(Index); |
||
500 | |||
501 | if (!ChkArgCnt(2, 3)); |
||
502 | else if (!as_strcasecmp(ArgStr[1].str.p_str, "BMAR")) |
||
503 | { |
||
504 | if (ChkMinCPU(CPU32050) |
||
505 | && DecodeAdr(&ArgStr[2], 2, 3, False)) |
||
506 | { |
||
507 | CodeLen = 1; |
||
508 | WAsmCode[0] = 0xa400 | AdrMode; |
||
509 | } |
||
510 | } |
||
511 | else if (*ArgStr[1].str.p_str == '#') |
||
512 | { |
||
513 | WAsmCode[1] = EvalStrIntExpressionOffs(&ArgStr[1], 1, Int16, &OK); |
||
514 | if ((OK) && (DecodeAdr(&ArgStr[2], 2, 3, False))) |
||
515 | { |
||
516 | CodeLen = 2; |
||
517 | WAsmCode[0] = 0xa500 | AdrMode; |
||
518 | } |
||
519 | } |
||
520 | else |
||
521 | WrError(ErrNum_InvAddrMode); /* invalid addressing mode */ |
||
522 | } |
||
523 | |||
524 | static void DecodeCLRSETC(Word Index) |
||
525 | { |
||
526 | tBitTable *pBitTable; |
||
527 | |||
528 | if (ChkArgCnt(1, 1)) |
||
529 | { |
||
530 | WAsmCode[0] = Index; |
||
531 | NLS_UpString(ArgStr[1].str.p_str); |
||
532 | |||
533 | for (pBitTable = BitTable; pBitTable->name; pBitTable++) |
||
534 | if (!strcmp(ArgStr[1].str.p_str, pBitTable->name)) |
||
535 | { |
||
536 | if (ChkMinCPU(pBitTable->MinCPU)) |
||
537 | { |
||
538 | WAsmCode[0] |= pBitTable->Code; |
||
539 | CodeLen = 1; |
||
540 | } |
||
541 | return; |
||
542 | } |
||
543 | WrStrErrorPos(ErrNum_InvReg, &ArgStr[1]); /* invalid instruction */ |
||
544 | } |
||
545 | } |
||
546 | |||
547 | static void DecodeCMPRSPM(Word Index) |
||
548 | { |
||
549 | Boolean OK; |
||
550 | |||
551 | if (ChkArgCnt(1, 1)) |
||
552 | { |
||
553 | WAsmCode[0] = Index | (EvalStrIntExpression(&ArgStr[1], UInt2, &OK) & 3); |
||
554 | if (OK) |
||
555 | CodeLen = 1; |
||
556 | } |
||
557 | } |
||
558 | |||
559 | static void DecodeIO(Word Index) |
||
560 | { |
||
561 | if (ChkArgCnt(2, 3) |
||
562 | && DecodeAdr(&ArgStr[1], 2, 3, False)) |
||
563 | { |
||
564 | tEvalResult EvalResult; |
||
565 | WAsmCode[1] = EvalStrIntExpressionWithResult(&ArgStr[2], UInt16, &EvalResult); |
||
566 | if (EvalResult.OK) |
||
567 | { |
||
568 | ChkSpace(SegIO, EvalResult.AddrSpaceMask); |
||
569 | CodeLen = 2; |
||
570 | WAsmCode[0] = Index | AdrMode; |
||
571 | } |
||
572 | } |
||
573 | } |
||
574 | |||
575 | static void DecodeINTR(Word Index) |
||
576 | { |
||
577 | Boolean OK; |
||
578 | UNUSED(Index); |
||
579 | |||
580 | if (ChkArgCnt(1, 1)) |
||
581 | { |
||
582 | WAsmCode[0] = EvalStrIntExpression(&ArgStr[1], UInt5, &OK) | 0xbe60; |
||
583 | if (OK) |
||
584 | CodeLen = 1; |
||
585 | } |
||
586 | } |
||
587 | |||
588 | static void DecodeLACC(Word Index) |
||
589 | { |
||
590 | Boolean OK; |
||
591 | LongWord AdrLong; |
||
592 | Word Shift; |
||
593 | UNUSED(Index); |
||
594 | |||
595 | if (!ChkArgCnt(1, 3)); |
||
596 | else if (*ArgStr[1].str.p_str == '#') |
||
597 | { |
||
598 | if (ChkArgCnt(1, 2)) |
||
599 | { |
||
600 | AdrLong = EvalStrIntExpressionOffs(&ArgStr[1], 1, Int16, &OK); |
||
601 | if (OK) |
||
602 | { |
||
603 | OK = True; |
||
604 | Shift = (ArgCnt > 1) ? EvalStrIntExpression(&ArgStr[2], UInt4, &OK) : 0; |
||
605 | if (OK) |
||
606 | { |
||
607 | CodeLen = 2; |
||
608 | WAsmCode[0] = 0xbf80 | (Shift & 0xf); |
||
609 | WAsmCode[1] = AdrLong; |
||
610 | } |
||
611 | } |
||
612 | } |
||
613 | } |
||
614 | else |
||
615 | { |
||
616 | if (DecodeAdr(&ArgStr[1], 1, 3, False)) |
||
617 | { |
||
618 | OK = True; |
||
619 | Shift = (ArgCnt >= 2) ? DecodeShift(&ArgStr[2], &OK) : 0; |
||
620 | if (OK) |
||
621 | { |
||
622 | CodeLen = 1; |
||
623 | if (Shift >= 16) |
||
624 | WAsmCode[0] = 0x6a00 | AdrMode; |
||
625 | else |
||
626 | WAsmCode[0] = 0x1000 | ((Shift & 0xf) << 8) | AdrMode; |
||
627 | } |
||
628 | } |
||
629 | } |
||
630 | } |
||
631 | |||
632 | static void DecodeLACL(Word Index) |
||
633 | { |
||
634 | Boolean OK; |
||
635 | UNUSED(Index); |
||
636 | |||
637 | if (*ArgStr[1].str.p_str == '#') |
||
638 | { |
||
639 | if (ChkArgCnt(1, 1)) |
||
640 | { |
||
641 | WAsmCode[0] = EvalStrIntExpressionOffs(&ArgStr[1], 1, UInt8, &OK); |
||
642 | if (OK) |
||
643 | { |
||
644 | CodeLen = 1; |
||
645 | WAsmCode[0] |= 0xb900; |
||
646 | } |
||
647 | } |
||
648 | } |
||
649 | else |
||
650 | { |
||
651 | if (ChkArgCnt(1, 2)) |
||
652 | { |
||
653 | if (DecodeAdr(&ArgStr[1], 1, 2, False)) |
||
654 | { |
||
655 | WAsmCode[0] = 0x6900 | AdrMode; |
||
656 | CodeLen = 1; |
||
657 | } |
||
658 | } |
||
659 | } |
||
660 | } |
||
661 | |||
662 | static void DecodeLAR(Word Index) |
||
663 | { |
||
664 | Word Reg; |
||
665 | LongWord AdrLong; |
||
666 | Boolean OK; |
||
667 | UNUSED(Index); |
||
668 | |||
669 | if (ChkArgCnt(2, 3)) |
||
670 | { |
||
671 | Reg = EvalARExpression(&ArgStr[1], &OK); |
||
672 | if (OK) |
||
673 | { |
||
674 | if (*ArgStr[2].str.p_str == '#') |
||
675 | { |
||
676 | if (!ChkArgCnt(2, 2)) |
||
677 | return; |
||
678 | AdrLong = EvalStrIntExpressionOffs(&ArgStr[2], 1, Int16, &OK) & 0xffff; |
||
679 | if (OK) |
||
680 | { |
||
681 | if (AdrLong > 255) |
||
682 | { |
||
683 | CodeLen = 2; |
||
684 | WAsmCode[0] = 0xbf08 | (Reg & 7); |
||
685 | WAsmCode[1] = AdrLong; |
||
686 | } |
||
687 | else |
||
688 | { |
||
689 | CodeLen = 1; |
||
690 | WAsmCode[0] = 0xb000 | ((Reg & 7) << 8) | (AdrLong & 0xff); |
||
691 | } |
||
692 | } |
||
693 | } |
||
694 | else |
||
695 | { |
||
696 | if (DecodeAdr(&ArgStr[2], 2, 3, False)) |
||
697 | { |
||
698 | CodeLen = 1; |
||
699 | WAsmCode[0] = 0x0000 | ((Reg & 7) << 8) | AdrMode; |
||
700 | } |
||
701 | } |
||
702 | } |
||
703 | } |
||
704 | } |
||
705 | |||
706 | static void DecodeLDP(Word Index) |
||
707 | { |
||
708 | Word konst; |
||
709 | Boolean OK; |
||
710 | UNUSED(Index); |
||
711 | |||
712 | if (*ArgStr[1].str.p_str == '#') |
||
713 | { |
||
714 | if (ChkArgCnt(1, 1)) |
||
715 | { |
||
716 | konst = EvalStrIntExpressionOffs(&ArgStr[1], 1, UInt9, &OK); |
||
717 | if (OK) |
||
718 | { |
||
719 | CodeLen = 1; |
||
720 | WAsmCode[0] = (konst & 0x1ff) | 0xbc00; |
||
721 | } |
||
722 | } |
||
723 | } |
||
724 | else |
||
725 | { |
||
726 | if (ChkArgCnt(1, 2)) |
||
727 | { |
||
728 | if (DecodeAdr(&ArgStr[1], 1, 2, False)) |
||
729 | { |
||
730 | CodeLen = 1; |
||
731 | WAsmCode[0] = 0x0d00 | AdrMode; |
||
732 | } |
||
733 | } |
||
734 | } |
||
735 | } |
||
736 | |||
737 | static void DecodeLSST(Word Index) |
||
738 | { |
||
739 | Word konst; |
||
740 | Boolean OK; |
||
741 | |||
742 | if (!ChkArgCnt(2, 3)); |
||
743 | else if (*ArgStr[1].str.p_str != '#') WrError(ErrNum_OnlyImmAddr); /* invalid instruction */ |
||
744 | else |
||
745 | { |
||
746 | konst = EvalStrIntExpressionOffs(&ArgStr[1], 1, UInt1, &OK); |
||
747 | if ((OK) && (DecodeAdr(&ArgStr[2], 2, 3, Index))) |
||
748 | { |
||
749 | CodeLen = 1; |
||
750 | WAsmCode[0] = 0x0e00 | (Index << 15) | ((konst & 1) << 8) | AdrMode; |
||
751 | } |
||
752 | } |
||
753 | } |
||
754 | |||
755 | static void DecodeMAC(Word Index) |
||
756 | { |
||
757 | if (ChkArgCnt(2, 3)) |
||
758 | { |
||
759 | tEvalResult EvalResult; |
||
760 | WAsmCode[1] = EvalStrIntExpressionWithResult(&ArgStr[1], Int16, &EvalResult); |
||
761 | |||
762 | if (EvalResult.OK && DecodeAdr(&ArgStr[2], 2, 3, False)) |
||
763 | { |
||
764 | ChkSpace(SegCode, EvalResult.AddrSpaceMask); |
||
765 | CodeLen = 2; |
||
766 | WAsmCode[0] = 0xa200 | (Index << 8) | AdrMode; |
||
767 | } |
||
768 | } |
||
769 | } |
||
770 | |||
771 | static void DecodeMPY(Word Index) |
||
772 | { |
||
773 | LongInt Imm; |
||
774 | Boolean OK; |
||
775 | tSymbolFlags Flags; |
||
776 | |||
777 | if (*ArgStr[1].str.p_str == '#') |
||
778 | { |
||
779 | if (ChkArgCnt(1, 1)) |
||
780 | { |
||
781 | Imm = EvalStrIntExpressionOffsWithFlags(&ArgStr[1], 1, SInt16, &OK, &Flags); |
||
782 | if (mFirstPassUnknown(Flags)) |
||
783 | Imm &= 0xfff; |
||
784 | if (OK) |
||
785 | { |
||
786 | if ((Imm < -4096) || (Imm > 4095)) |
||
787 | { |
||
788 | if (ChkMinCPU(CPU32050)) |
||
789 | { |
||
790 | CodeLen = 2; /* What does that mean? */ |
||
791 | WAsmCode[0] = 0xbe80; |
||
792 | WAsmCode[1] = Imm; |
||
793 | } |
||
794 | } |
||
795 | else |
||
796 | { |
||
797 | CodeLen = 1; |
||
798 | WAsmCode[0] = 0xc000 | (Imm & 0x1fff); |
||
799 | } |
||
800 | } |
||
801 | } |
||
802 | } |
||
803 | else |
||
804 | { |
||
805 | if (ChkArgCnt(1, 2) |
||
806 | && DecodeAdr(&ArgStr[1], 1, 2, Index)) |
||
807 | { |
||
808 | CodeLen = 1; |
||
809 | WAsmCode[0] = 0x5400 | AdrMode; |
||
810 | } |
||
811 | } |
||
812 | } |
||
813 | |||
814 | static void DecodeNORM(Word Index) |
||
815 | { |
||
816 | UNUSED(Index); |
||
817 | |||
818 | if (ChkArgCnt(1, 2) |
||
819 | && DecodeAdr(&ArgStr[1], 1, 2, False)) |
||
820 | { |
||
821 | if (AdrMode < 0x80) WrError(ErrNum_InvAddrMode); |
||
822 | else |
||
823 | { |
||
824 | CodeLen = 1; |
||
825 | WAsmCode[0] = 0xa080 | (AdrMode & 0x7f); |
||
826 | } |
||
827 | } |
||
828 | } |
||
829 | |||
830 | static void DecodeRETC(Word Index) |
||
831 | { |
||
832 | if (!ChkArgCnt(1, 1)); |
||
833 | else if (Index && !ChkMinCPU(CPU32050)); |
||
834 | else |
||
835 | { |
||
836 | CodeLen = 1; |
||
837 | WAsmCode[0] = 0xec00 | (Index << 12) | DecodeCond(1); |
||
838 | } |
||
839 | } |
||
840 | |||
841 | static void DecodeRPT(Word Index) |
||
842 | { |
||
843 | Word Imm; |
||
844 | Boolean OK; |
||
845 | UNUSED(Index); |
||
846 | |||
847 | if (*ArgStr[1].str.p_str == '#') |
||
848 | { |
||
849 | if (ChkArgCnt(1, 1)) |
||
850 | { |
||
851 | Imm = EvalStrIntExpressionOffs(&ArgStr[1], 1, (MomCPU >= CPU32050) ? UInt16 : UInt8, &OK); |
||
852 | if (OK) |
||
853 | { |
||
854 | if (Imm > 255) |
||
855 | { |
||
856 | CodeLen = 2; |
||
857 | WAsmCode[0] = 0xbec4; |
||
858 | WAsmCode[1] = Imm; |
||
859 | } |
||
860 | else |
||
861 | { |
||
862 | CodeLen = 1; |
||
863 | WAsmCode[0] = 0xbb00 | (Imm & 0xff); |
||
864 | } |
||
865 | } |
||
866 | } |
||
867 | } |
||
868 | else |
||
869 | { |
||
870 | if (ChkArgCnt(1, 2)) |
||
871 | { |
||
872 | if (DecodeAdr(&ArgStr[1], 1, 2, False)) |
||
873 | { |
||
874 | CodeLen = 1; |
||
875 | WAsmCode[0] = 0x0b00 | AdrMode; |
||
876 | } |
||
877 | } |
||
878 | } |
||
879 | } |
||
880 | |||
881 | static void DecodeSAC(Word Index) |
||
882 | { |
||
883 | Boolean OK; |
||
884 | Word Shift; |
||
885 | |||
886 | if (ChkArgCnt(1, 3)) |
||
887 | { |
||
888 | OK = True; |
||
889 | Shift = (ArgCnt >= 2) ? EvalStrIntExpression(&ArgStr[2], UInt3, &OK) : 0; |
||
890 | |||
891 | if ((DecodeAdr(&ArgStr[1], 1, 3, False)) && (OK)) |
||
892 | { |
||
893 | CodeLen = 1; |
||
894 | WAsmCode[0] = (Index << 11) | 0x9000 | AdrMode | ((Shift & 7) << 8); |
||
895 | } |
||
896 | } |
||
897 | } |
||
898 | |||
899 | static void DecodeSAR(Word Index) |
||
900 | { |
||
901 | Word Reg; |
||
902 | Boolean OK; |
||
903 | UNUSED(Index); |
||
904 | |||
905 | if (ChkArgCnt(2, 3)) |
||
906 | { |
||
907 | Reg = EvalARExpression(&ArgStr[1], &OK); |
||
908 | |||
909 | if ((OK) && (DecodeAdr(&ArgStr[2], 2, 3, False))) |
||
910 | { |
||
911 | CodeLen = 1; |
||
912 | WAsmCode[0] = 0x8000 | ((Reg & 7) << 8) | AdrMode; |
||
913 | } |
||
914 | } |
||
915 | } |
||
916 | |||
917 | static void DecodeBSAR(Word Index) |
||
918 | { |
||
919 | Word Shift; |
||
920 | Boolean OK; |
||
921 | tSymbolFlags Flags; |
||
922 | |||
923 | UNUSED(Index); |
||
924 | |||
925 | if (ChkArgCnt(1, 1) |
||
926 | && ChkMinCPU(CPU32050)) |
||
927 | { |
||
928 | Shift = EvalStrIntExpressionWithFlags(&ArgStr[1], UInt5, &OK, &Flags); |
||
929 | if (mFirstPassUnknown(Flags)) |
||
930 | Shift = 1; |
||
931 | if (OK) |
||
932 | { |
||
933 | if (ChkRange(Shift, 1, 16)) |
||
934 | { |
||
935 | CodeLen = 1; |
||
936 | WAsmCode[0] = 0xbfe0 | ((Shift - 1) & 0xf); |
||
937 | } |
||
938 | } |
||
939 | } |
||
940 | } |
||
941 | |||
942 | static void DecodeLSAMM(Word Index) |
||
943 | { |
||
944 | if (ChkArgCnt(1, 2) |
||
945 | && ChkMinCPU(CPU32050) |
||
946 | && DecodeAdr(&ArgStr[1], 1, 2, True)) |
||
947 | { |
||
948 | CodeLen = 1; |
||
949 | WAsmCode[0] = 0x0800 | (Index << 15) | AdrMode; |
||
950 | } |
||
951 | } |
||
952 | |||
953 | static void DecodeLSMMR(Word Index) |
||
954 | { |
||
955 | Boolean OK; |
||
956 | |||
957 | if (!ChkArgCnt(2, 3)); |
||
958 | else if (!ChkMinCPU(CPU32050)); |
||
959 | else if (ArgStr[2].str.p_str[0] != '#') WrError(ErrNum_OnlyImmAddr); |
||
960 | else |
||
961 | { |
||
962 | WAsmCode[1] = EvalStrIntExpressionOffs(&ArgStr[2], 1, Int16, &OK); |
||
963 | if ((OK) && (DecodeAdr(&ArgStr[1], 2, 3, True))) |
||
964 | { |
||
965 | CodeLen = 2; |
||
966 | WAsmCode[0] = 0x0900 | (Index << 15) | AdrMode; |
||
967 | } |
||
968 | } |
||
969 | } |
||
970 | |||
971 | static void DecodeRPTB(Word Index) |
||
972 | { |
||
973 | Boolean OK; |
||
974 | UNUSED(Index); |
||
975 | |||
976 | if (ChkArgCnt(1, 1) |
||
977 | && ChkMinCPU(CPU32050)) |
||
978 | { |
||
979 | WAsmCode[1] = EvalStrIntExpression(&ArgStr[1], Int16, &OK); |
||
980 | if (OK) |
||
981 | { |
||
982 | CodeLen = 2; |
||
983 | WAsmCode[0] = 0xbec6; |
||
984 | } |
||
985 | } |
||
986 | } |
||
987 | |||
988 | static void DecodeRPTZ(Word Index) |
||
989 | { |
||
990 | Boolean OK; |
||
991 | UNUSED(Index); |
||
992 | |||
993 | if (!ChkArgCnt(1, 1)); |
||
994 | else if (!ChkMinCPU(CPU32050)); |
||
995 | else if (*ArgStr[1].str.p_str != '#') WrError(ErrNum_OnlyImmAddr); |
||
996 | else |
||
997 | { |
||
998 | WAsmCode[1] = EvalStrIntExpressionOffs(&ArgStr[1], 1, Int16, &OK); |
||
999 | if (OK) |
||
1000 | { |
||
1001 | CodeLen = 2; |
||
1002 | WAsmCode[0] = 0xbec5; |
||
1003 | } |
||
1004 | } |
||
1005 | } |
||
1006 | |||
1007 | static void DecodeXC(Word Index) |
||
1008 | { |
||
1009 | Word Mode; |
||
1010 | Boolean OK; |
||
1011 | tSymbolFlags Flags; |
||
1012 | |||
1013 | UNUSED(Index); |
||
1014 | |||
1015 | if (ChkArgCnt(2, 2) |
||
1016 | && ChkMinCPU(CPU32050)) |
||
1017 | { |
||
1018 | Mode = EvalStrIntExpressionWithFlags(&ArgStr[1], UInt2, &OK, &Flags); |
||
1019 | if (OK) |
||
1020 | { |
||
1021 | if ((Mode != 1) && (Mode != 2) && !mFirstPassUnknown(Flags)) WrError(ErrNum_UnderRange); |
||
1022 | else |
||
1023 | { |
||
1024 | CodeLen = 1; |
||
1025 | WAsmCode[0] = (0xd400 + (Mode << 12)) | DecodeCond(2); |
||
1026 | } |
||
1027 | } |
||
1028 | } |
||
1029 | } |
||
1030 | |||
1031 | static void DecodePORT(Word Code) |
||
1032 | { |
||
1033 | UNUSED(Code); |
||
1034 | |||
1035 | CodeEquate(SegIO, 0, 65535); |
||
1036 | } |
||
1037 | |||
1038 | /* ---------------------------------------------------------------------- */ |
||
1039 | |||
1040 | static void AddFixed(const char *NName, CPUVar MinCPU, Word NCode) |
||
1041 | { |
||
1042 | order_array_rsv_end(FixedOrders, FixedOrder); |
||
1043 | FixedOrders[InstrZ].MinCPU = MinCPU; |
||
1044 | FixedOrders[InstrZ].Code = NCode; |
||
1045 | AddInstTable(InstTable, NName, InstrZ++, DecodeFixed); |
||
1046 | } |
||
1047 | |||
1048 | static void AddAdr(const char *NName, CPUVar MinCPU, Word NCode) |
||
1049 | { |
||
1050 | order_array_rsv_end(AdrOrders, FixedOrder); |
||
1051 | AdrOrders[InstrZ].MinCPU = MinCPU; |
||
1052 | AdrOrders[InstrZ].Code = NCode; |
||
1053 | AddInstTable(InstTable, NName, InstrZ++, DecodeCmdAdr); |
||
1054 | } |
||
1055 | |||
1056 | static void AddJmp(const char *NName, CPUVar MinCPU, Word NCode, Boolean NCond) |
||
1057 | { |
||
1058 | order_array_rsv_end(JmpOrders, JmpOrder); |
||
1059 | JmpOrders[InstrZ].MinCPU = MinCPU; |
||
1060 | JmpOrders[InstrZ].Code = NCode; |
||
1061 | JmpOrders[InstrZ].Cond = NCond; |
||
1062 | AddInstTable(InstTable, NName, InstrZ++, DecodeCmdJmp); |
||
1063 | } |
||
1064 | |||
1065 | static void AddPlu(const char *NName, CPUVar MinCPU, Word NCode) |
||
1066 | { |
||
1067 | order_array_rsv_end(PluOrders, FixedOrder); |
||
1068 | PluOrders[InstrZ].MinCPU = MinCPU; |
||
1069 | PluOrders[InstrZ].Code = NCode; |
||
1070 | AddInstTable(InstTable, NName, InstrZ++, DecodeCmdPlu); |
||
1071 | } |
||
1072 | |||
1073 | static void AddAdrMode(const char *NName, CPUVar MinCPU, Word NMode) |
||
1074 | { |
||
1075 | order_array_rsv_end(AdrModes, tAdrMode); |
||
1076 | AdrModes[InstrZ].Name = NName; |
||
1077 | AdrModes[InstrZ].MinCPU = MinCPU; |
||
1078 | AdrModes[InstrZ++].Mode = NMode; |
||
1079 | } |
||
1080 | |||
1081 | static void AddCond(const char *NName, CPUVar MinCPU, Word NCodeAND, Word NCodeOR, Byte NIsZL, |
||
1082 | Byte NIsC, Byte NIsV, Byte NIsTP) |
||
1083 | { |
||
1084 | order_array_rsv_end(Conditions, Condition); |
||
1085 | Conditions[InstrZ].Name = NName; |
||
1086 | Conditions[InstrZ].MinCPU = MinCPU; |
||
1087 | Conditions[InstrZ].CodeAND = NCodeAND; |
||
1088 | Conditions[InstrZ].CodeOR = NCodeOR; |
||
1089 | Conditions[InstrZ].IsZL = NIsZL; |
||
1090 | Conditions[InstrZ].IsC = NIsC; |
||
1091 | Conditions[InstrZ].IsV = NIsV; |
||
1092 | Conditions[InstrZ++].IsTP = NIsTP; |
||
1093 | } |
||
1094 | |||
1095 | static void AddBit(const char *NName, CPUVar MinCPU, Word NCode) |
||
1096 | { |
||
1097 | order_array_rsv_end(BitTable, tBitTable); |
||
1098 | BitTable[InstrZ].name = NName; |
||
1099 | BitTable[InstrZ].MinCPU = MinCPU; |
||
1100 | BitTable[InstrZ++].Code = NCode; |
||
1101 | } |
||
1102 | |||
1103 | static void InitFields(void) |
||
1104 | { |
||
1105 | InstTable = CreateInstTable(203); |
||
1106 | |||
1107 | InstrZ = 0; |
||
1108 | AddFixed("ABS", CPU320203, 0xbe00); AddFixed("ADCB", CPU32050 , 0xbe11); |
||
1109 | AddFixed("ADDB", CPU32050 , 0xbe10); AddFixed("ANDB", CPU32050 , 0xbe12); |
||
1110 | AddFixed("CMPL", CPU320203, 0xbe01); AddFixed("CRGT", CPU32050 , 0xbe1b); |
||
1111 | AddFixed("CRLT", CPU32050 , 0xbe1c); AddFixed("EXAR", CPU32050 , 0xbe1d); |
||
1112 | AddFixed("LACB", CPU32050 , 0xbe1f); AddFixed("NEG", CPU320203, 0xbe02); |
||
1113 | AddFixed("ORB", CPU32050 , 0xbe13); AddFixed("ROL", CPU320203, 0xbe0c); |
||
1114 | AddFixed("ROLB", CPU32050 , 0xbe14); AddFixed("ROR", CPU320203, 0xbe0d); |
||
1115 | AddFixed("RORB", CPU32050 , 0xbe15); AddFixed("SACB", CPU32050 , 0xbe1e); |
||
1116 | AddFixed("SATH", CPU32050 , 0xbe5a); AddFixed("SATL", CPU32050 , 0xbe5b); |
||
1117 | AddFixed("SBB", CPU32050 , 0xbe18); AddFixed("SBBB", CPU32050 , 0xbe19); |
||
1118 | AddFixed("SFL", CPU320203, 0xbe09); AddFixed("SFLB", CPU32050 , 0xbe16); |
||
1119 | AddFixed("SFR", CPU320203, 0xbe0a); AddFixed("SFRB", CPU32050 , 0xbe17); |
||
1120 | AddFixed("XORB", CPU32050 , 0xbe1a); AddFixed("ZAP", CPU32050 , 0xbe59); |
||
1121 | AddFixed("APAC", CPU320203, 0xbe04); AddFixed("PAC", CPU320203, 0xbe03); |
||
1122 | AddFixed("SPAC", CPU320203, 0xbe05); AddFixed("ZPR", CPU32050 , 0xbe58); |
||
1123 | AddFixed("BACC", CPU320203, 0xbe20); AddFixed("BACCD", CPU32050 , 0xbe21); |
||
1124 | AddFixed("CALA", CPU320203, 0xbe30); AddFixed("CALAD", CPU32050 , 0xbe3d); |
||
1125 | AddFixed("NMI", CPU320203, 0xbe52); AddFixed("RET", CPU320203, 0xef00); |
||
1126 | AddFixed("RETD", CPU32050 , 0xff00); AddFixed("RETE", CPU32050 , 0xbe3a); |
||
1127 | AddFixed("RETI", CPU32050 , 0xbe38); AddFixed("TRAP", CPU320203, 0xbe51); |
||
1128 | AddFixed("IDLE", CPU320203, 0xbe22); AddFixed("NOP", CPU320203, 0x8b00); |
||
1129 | AddFixed("POP", CPU320203, 0xbe32); AddFixed("PUSH", CPU320203, 0xbe3c); |
||
1130 | AddFixed("IDLE2", CPU32050 , 0xbe23); |
||
1131 | |||
1132 | InstrZ = 0; |
||
1133 | AddAdr("ADDC", CPU320203, 0x6000); AddAdr("ADDS", CPU320203, 0x6200); |
||
1134 | AddAdr("ADDT", CPU320203, 0x6300); AddAdr("LACT", CPU320203, 0x6b00); |
||
1135 | AddAdr("SUBB", CPU320203, 0x6400); AddAdr("SUBC", CPU320203, 0x0a00); |
||
1136 | AddAdr("SUBS", CPU320203, 0x6600); AddAdr("SUBT", CPU320203, 0x6700); |
||
1137 | AddAdr("ZALR", CPU320203, 0x6800); AddAdr("MAR", CPU320203, 0x8b00); |
||
1138 | AddAdr("LPH", CPU320203, 0x7500); AddAdr("LT", CPU320203, 0x7300); |
||
1139 | AddAdr("LTA", CPU320203, 0x7000); AddAdr("LTD", CPU320203, 0x7200); |
||
1140 | AddAdr("LTP", CPU320203, 0x7100); AddAdr("LTS", CPU320203, 0x7400); |
||
1141 | AddAdr("MADD", CPU32050 , 0xab00); AddAdr("MADS", CPU32050 , 0xaa00); |
||
1142 | AddAdr("MPYA", CPU320203, 0x5000); AddAdr("MPYS", CPU320203, 0x5100); |
||
1143 | AddAdr("MPYU", CPU320203, 0x5500); AddAdr("SPH", CPU320203, 0x8d00); |
||
1144 | AddAdr("SPL", CPU320203, 0x8c00); AddAdr("SQRA", CPU320203, 0x5200); |
||
1145 | AddAdr("SQRS", CPU320203, 0x5300); AddAdr("BLDP", CPU32050 , 0x5700); |
||
1146 | AddAdr("DMOV", CPU320203, 0x7700); AddAdr("TBLR", CPU320203, 0xa600); |
||
1147 | AddAdr("TBLW", CPU320203, 0xa700); AddAdr("BITT", CPU320203, 0x6f00); |
||
1148 | AddAdr("POPD", CPU320203, 0x8a00); AddAdr("PSHD", CPU320203, 0x7600); |
||
1149 | |||
1150 | InstrZ = 0; |
||
1151 | AddJmp("B", CPU320203, 0x7980, False); |
||
1152 | AddJmp("BD", CPU32050 , 0x7d80, False); |
||
1153 | AddJmp("BANZ", CPU320203, 0x7b80, False); |
||
1154 | AddJmp("BANZD", CPU32050 , 0x7f80, False); |
||
1155 | AddJmp("BCND", CPU320203, 0xe000, True); |
||
1156 | AddJmp("BCNDD", CPU32050 , 0xf000, True); |
||
1157 | AddJmp("CALL", CPU320203, 0x7a80, False); |
||
1158 | AddJmp("CALLD", CPU32050 , 0x7e80, False); |
||
1159 | AddJmp("CC", CPU320203, 0xe800, True); |
||
1160 | AddJmp("CCD", CPU32050 , 0xf800, True); |
||
1161 | |||
1162 | InstrZ = 0; |
||
1163 | AddPlu("APL", CPU32050 , 0x5a00); AddPlu("CPL", CPU32050 , 0x5b00); |
||
1164 | AddPlu("OPL", CPU32050 , 0x5900); AddPlu("SPLK", CPU320203, 0xaa00); |
||
1165 | AddPlu("XPL", CPU32050 , 0x5800); |
||
1166 | |||
1167 | InstrZ = 0; |
||
1168 | AddAdrMode( "*-", CPU320203, 0x90 ); AddAdrMode( "*+", CPU320203, 0xa0 ); |
||
1169 | AddAdrMode( "*BR0-", CPU320203, 0xc0 ); AddAdrMode( "*0-", CPU320203, 0xd0 ); |
||
1170 | AddAdrMode( "*AR0-", CPU32050 , 0xd0 ); AddAdrMode( "*0+", CPU320203, 0xe0 ); |
||
1171 | AddAdrMode( "*AR0+", CPU32050 , 0xe0 ); AddAdrMode( "*BR0+", CPU320203, 0xf0 ); |
||
1172 | AddAdrMode( "*", CPU320203, 0x80 ); AddAdrMode( NULL, CPU32050 , 0); |
||
1173 | |||
1174 | InstrZ = 0; |
||
1175 | AddCond("EQ", CPU32050 , 0xf33, 0x088, 1, 0, 0, 0); |
||
1176 | AddCond("NEQ", CPU32050 , 0xf33, 0x008, 1, 0, 0, 0); |
||
1177 | AddCond("LT", CPU32050 , 0xf33, 0x044, 1, 0, 0, 0); |
||
1178 | AddCond("LEQ", CPU32050 , 0xf33, 0x0cc, 1, 0, 0, 0); |
||
1179 | AddCond("GT", CPU32050 , 0xf33, 0x004, 1, 0, 0, 0); |
||
1180 | AddCond("GEQ", CPU32050 , 0xf33, 0x08c, 1, 0, 0, 0); |
||
1181 | AddCond("NC", CPU32050 , 0xfee, 0x001, 0, 1, 0, 0); |
||
1182 | AddCond("C", CPU32050 , 0xfee, 0x011, 0, 1, 0, 0); |
||
1183 | AddCond("NOV", CPU32050 , 0xfdd, 0x002, 0, 0, 1, 0); |
||
1184 | AddCond("OV", CPU32050 , 0xfdd, 0x022, 0, 0, 1, 0); |
||
1185 | AddCond("BIO", CPU32050 , 0x0ff, 0x000, 0, 0, 0, 1); |
||
1186 | AddCond("NTC", CPU32050 , 0x0ff, 0x200, 0, 0, 0, 1); |
||
1187 | AddCond("TC", CPU32050 , 0x0ff, 0x100, 0, 0, 0, 1); |
||
1188 | AddCond("UNC", CPU32050 , 0x0ff, 0x300, 0, 0, 0, 1); |
||
1189 | AddCond(NULL, CPU32050 , 0xfff, 0x000, 0, 0, 0, 0); |
||
1190 | |||
1191 | InstrZ = 0; |
||
1192 | AddBit("OVM", CPU320203, 0xbe42 ); AddBit("SXM", CPU320203, 0xbe46 ); |
||
1193 | AddBit("HM", CPU32050 , 0xbe48 ); AddBit("TC", CPU320203, 0xbe4a ); |
||
1194 | AddBit("C", CPU320203, 0xbe4e ); AddBit("XF", CPU320203, 0xbe4c ); |
||
1195 | AddBit("CNF", CPU320203, 0xbe44 ); AddBit("INTM", CPU320203, 0xbe40 ); |
||
1196 | AddBit(NULL, CPU32050 , 0 ); |
||
1197 | |||
1198 | AddInstTable(InstTable, "ADD" , 0, DecodeADDSUB); |
||
1199 | AddInstTable(InstTable, "SUB" , 1, DecodeADDSUB); |
||
1200 | AddInstTable(InstTable, "ADRK" , 0, DecodeADRSBRK); |
||
1201 | AddInstTable(InstTable, "SBRK" , 1, DecodeADRSBRK); |
||
1202 | AddInstTable(InstTable, "AND" , 0x6e01, DecodeLogic); |
||
1203 | AddInstTable(InstTable, "OR" , 0x6d02, DecodeLogic); |
||
1204 | AddInstTable(InstTable, "XOR" , 0x6c03, DecodeLogic); |
||
1205 | AddInstTable(InstTable, "BIT" , 0, DecodeBIT); |
||
1206 | AddInstTable(InstTable, "BLDD" , 0, DecodeBLDD); |
||
1207 | AddInstTable(InstTable, "BLPD" , 0, DecodeBLPD); |
||
1208 | AddInstTable(InstTable, "CLRC" , 0, DecodeCLRSETC); |
||
1209 | AddInstTable(InstTable, "SETC" , 1, DecodeCLRSETC); |
||
1210 | AddInstTable(InstTable, "CMPR" , 0xbf44, DecodeCMPRSPM); |
||
1211 | AddInstTable(InstTable, "SPM" , 0xbf00, DecodeCMPRSPM); |
||
1212 | AddInstTable(InstTable, "IN" , 0xaf00, DecodeIO); |
||
1213 | AddInstTable(InstTable, "OUT" , 0x0c00, DecodeIO); |
||
1214 | AddInstTable(InstTable, "INTR" , 0, DecodeINTR); |
||
1215 | AddInstTable(InstTable, "LACC" , 0, DecodeLACC); |
||
1216 | AddInstTable(InstTable, "LACL" , 0, DecodeLACL); |
||
1217 | AddInstTable(InstTable, "LAR" , 0, DecodeLAR); |
||
1218 | AddInstTable(InstTable, "LDP" , 0, DecodeLDP); |
||
1219 | AddInstTable(InstTable, "SST" , 1, DecodeLSST); |
||
1220 | AddInstTable(InstTable, "LST" , 0, DecodeLSST); |
||
1221 | AddInstTable(InstTable, "MAC" , 0, DecodeMAC); |
||
1222 | AddInstTable(InstTable, "MACD" , 1, DecodeMAC); |
||
1223 | AddInstTable(InstTable, "MPY" , 0, DecodeMPY); |
||
1224 | AddInstTable(InstTable, "NORM" , 0, DecodeNORM); |
||
1225 | AddInstTable(InstTable, "RETC" , 0, DecodeRETC); |
||
1226 | AddInstTable(InstTable, "RETCD", 1, DecodeRETC); |
||
1227 | AddInstTable(InstTable, "RPT" , 0, DecodeRPT); |
||
1228 | AddInstTable(InstTable, "SACL" , 0, DecodeSAC); |
||
1229 | AddInstTable(InstTable, "SACH" , 1, DecodeSAC); |
||
1230 | AddInstTable(InstTable, "SAR" , 0, DecodeSAR); |
||
1231 | AddInstTable(InstTable, "BSAR" , 0, DecodeBSAR); |
||
1232 | AddInstTable(InstTable, "LAMM" , 0, DecodeLSAMM); |
||
1233 | AddInstTable(InstTable, "SAMM" , 1, DecodeLSAMM); |
||
1234 | AddInstTable(InstTable, "LMMR" , 1, DecodeLSMMR); |
||
1235 | AddInstTable(InstTable, "SMMR" , 0, DecodeLSMMR); |
||
1236 | AddInstTable(InstTable, "RPTB" , 0, DecodeRPTB); |
||
1237 | AddInstTable(InstTable, "RPTZ" , 0, DecodeRPTZ); |
||
1238 | AddInstTable(InstTable, "XC" , 0, DecodeXC); |
||
1239 | AddInstTable(InstTable, "PORT" , 0, DecodePORT); |
||
1240 | } |
||
1241 | |||
1242 | static void DeinitFields(void) |
||
1243 | { |
||
1244 | DestroyInstTable(InstTable); |
||
1245 | order_array_free(FixedOrders); |
||
1246 | order_array_free(AdrOrders); |
||
1247 | order_array_free(JmpOrders); |
||
1248 | order_array_free(PluOrders); |
||
1249 | order_array_free(AdrModes); |
||
1250 | order_array_free(Conditions); |
||
1251 | order_array_free(BitTable); |
||
1252 | } |
||
1253 | |||
1254 | /* ---------------------------------------------------------------------- */ |
||
1255 | |||
1256 | static void MakeCode_3205x(void) |
||
1257 | { |
||
1258 | CodeLen = 0; |
||
1259 | DontPrint = False; |
||
1260 | |||
1261 | /* zu ignorierendes */ |
||
1262 | |||
1263 | if (Memo("")) |
||
1264 | return; |
||
1265 | |||
1266 | /* Pseudoanweisungen */ |
||
1267 | |||
1268 | if (DecodeTIPseudo()) |
||
1269 | return; |
||
1270 | |||
1271 | /* per Hash-Tabelle */ |
||
1272 | |||
1273 | if (!LookupInstTable(InstTable, OpPart.str.p_str)) |
||
1274 | WrStrErrorPos(ErrNum_UnknownInstruction, &OpPart); |
||
1275 | } |
||
1276 | |||
1277 | /* ---------------------------------------------------------------------- */ |
||
1278 | |||
1279 | static Boolean IsDef_3205x(void) |
||
1280 | { |
||
1281 | return Memo("PORT") || IsTIDef(); |
||
1282 | } |
||
1283 | |||
1284 | /* ---------------------------------------------------------------------- */ |
||
1285 | |||
1286 | static void SwitchFrom_3205x(void) |
||
1287 | { |
||
1288 | DeinitFields(); |
||
1289 | } |
||
1290 | |||
1291 | /* ---------------------------------------------------------------------- */ |
||
1292 | |||
1293 | static void SwitchTo_3205x(void) |
||
1294 | { |
||
1295 | TurnWords = False; |
||
1296 | SetIntConstMode(eIntConstModeIntel); |
||
1297 | |||
1298 | PCSymbol = "$"; |
||
1299 | HeaderID = 0x77; |
||
1300 | NOPCode = 0x8b00; |
||
1301 | DivideChars = ","; |
||
1302 | HasAttrs = False; |
||
1303 | |||
1304 | ValidSegs = (1 << SegCode) | (1 << SegData) | (1 << SegIO); |
||
1305 | Grans[SegCode] = 2; ListGrans[SegCode] = 2; SegInits[SegCode] = 0; |
||
1306 | SegLimits[SegCode] = 0xffff; |
||
1307 | Grans[SegData] = 2; ListGrans[SegData] = 2; SegInits[SegData] = 0; |
||
1308 | SegLimits[SegData] = 0xffff; |
||
1309 | Grans[SegIO ] = 2; ListGrans[SegIO ] = 2; SegInits[SegIO ] = 0; |
||
1310 | SegLimits[SegIO ] = 0xffff; |
||
1311 | |||
1312 | MakeCode = MakeCode_3205x; |
||
1313 | IsDef = IsDef_3205x; |
||
1314 | SwitchFrom = SwitchFrom_3205x; |
||
1315 | InitFields(); |
||
1316 | } |
||
1317 | |||
1318 | /* ---------------------------------------------------------------------- */ |
||
1319 | |||
1320 | void code3205x_init(void) |
||
1321 | { |
||
1322 | CPU320203 = AddCPU("320C203", SwitchTo_3205x); |
||
1323 | CPU32050 = AddCPU("320C50", SwitchTo_3205x); |
||
1324 | CPU32051 = AddCPU("320C51", SwitchTo_3205x); |
||
1325 | CPU32053 = AddCPU("320C53", SwitchTo_3205x); |
||
1326 | |||
1327 | AddCopyright("TMS320C5x-Generator (C) 1995/96 Thomas Sailer"); |
||
1328 | } |