aboutsummaryrefslogtreecommitdiffstats
path: root/code96.c
blob: 7c13b584183c3da2671f0f56cd5b602a8d5bf878 (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
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
/* code96.c */
/*****************************************************************************/
/* AS-Portierung                                                             */
/*                                                                           */
/* Codegenerator MCS/96-Familie                                              */
/*                                                                           */
/* Historie: 10.11.1996                                                      */
/*           16. 3.1997 80196N/80296                                         */
/*            3. 1.1999 ChkPC-Anpassung                                      */
/*                                                                           */
/*****************************************************************************/

#include "stdinc.h"
#include <string.h>

#include "bpemu.h"
#include "asmdef.h"
#include "asmsub.h"
#include "asmpars.h"
#include "codepseudo.h"
#include "codevars.h"

typedef struct 
         {
          char *Name;
          Byte Code;
         } FixedOrder;

typedef struct 
         {
          char *Name;
          Byte Code;
          CPUVar MinCPU,MaxCPU;
         } BaseOrder;

typedef struct 
         {
          char *Name; 
          Byte Code;
          Boolean Reloc;
         } MacOrder;

#define FixedOrderCnt 16

#define ALU3OrderCnt 5

#define ALU2OrderCnt 9

#define ALU1OrderCnt 6

#define ShiftOrderCnt 3

#define RelOrderCnt 16

#define MacOrderCnt 8

#define RptOrderCnt 34


static char *ShiftOrders[ShiftOrderCnt]={"SHR","SHL","SHRA"};

#define ModNone (-1)
#define ModDir 0
#define MModDir (1 << ModDir)
#define ModMem 1
#define MModMem (1 << ModMem)
#define ModImm 2
#define MModImm (1 << ModImm)

#define SFRStart 2
#define SFRStop 0x17

static BaseOrder *FixedOrders;
static FixedOrder *ALU3Orders;
static FixedOrder *ALU2Orders;
static FixedOrder *ALU1Orders;
static FixedOrder *RelOrders;
static MacOrder *MacOrders;
static FixedOrder *RptOrders;

static CPUVar CPU8096,CPU80196,CPU80196N,CPU80296;
static SimpProc SaveInitProc;

static Byte AdrMode;
static ShortInt AdrType;
static Byte AdrVals[4];
static ShortInt OpSize;

static LongInt WSRVal,WSR1Val;
static Word WinStart,WinStop,WinEnd,WinBegin;
static Word Win1Start,Win1Stop,Win1Begin,Win1End;

IntType MemInt;

/*---------------------------------------------------------------------------*/


   	static void AddFixed(char *NName, Byte NCode, CPUVar NMin, CPUVar NMax)
BEGIN
   if (InstrZ>=FixedOrderCnt) exit(255);
   FixedOrders[InstrZ].Name=NName;
   FixedOrders[InstrZ].Code=NCode;
   FixedOrders[InstrZ].MinCPU=NMin;
   FixedOrders[InstrZ++].MaxCPU=NMax;
END

        static void AddALU3(char *NName, Byte NCode)
BEGIN
   if (InstrZ>=ALU3OrderCnt) exit(255);
   ALU3Orders[InstrZ].Name=NName;
   ALU3Orders[InstrZ++].Code=NCode;
END

        static void AddALU2(char *NName, Byte NCode)
BEGIN
   if (InstrZ>=ALU2OrderCnt) exit(255);
   ALU2Orders[InstrZ].Name=NName;
   ALU2Orders[InstrZ++].Code=NCode;
END

        static void AddALU1(char *NName, Byte NCode)
BEGIN
   if (InstrZ>=ALU1OrderCnt) exit(255);
   ALU1Orders[InstrZ].Name=NName;
   ALU1Orders[InstrZ++].Code=NCode;
END

        static void AddRel(char *NName, Byte NCode)
BEGIN
   if (InstrZ>=RelOrderCnt) exit(255);
   RelOrders[InstrZ].Name=NName;
   RelOrders[InstrZ++].Code=NCode;
END

        static void AddMac(char *NName, Byte NCode, Boolean NRel)
BEGIN
   if (InstrZ>=MacOrderCnt) exit(255);
   MacOrders[InstrZ].Name=NName;
   MacOrders[InstrZ].Code=NCode;
   MacOrders[InstrZ++].Reloc=NRel;
END

        static void AddRpt(char *NName, Byte NCode)
BEGIN
   if (InstrZ>=RptOrderCnt) exit(255);
   RptOrders[InstrZ].Name=NName;
   RptOrders[InstrZ++].Code=NCode;
END

   	static void InitFields(void)
BEGIN
   FixedOrders=(BaseOrder *) malloc(sizeof(BaseOrder)*FixedOrderCnt); InstrZ=0;
   AddFixed("CLRC" ,0xf8,CPU8096  ,CPU80296 );
   AddFixed("CLRVT",0xfc,CPU8096  ,CPU80296 );
   AddFixed("DI"   ,0xfa,CPU8096  ,CPU80296 );
   AddFixed("DPTS" ,0xea,CPU80196 ,CPU80196N);
   AddFixed("EI"   ,0xfb,CPU8096  ,CPU80296 );
   AddFixed("EPTS" ,0xeb,CPU80196 ,CPU80196N);
   AddFixed("NOP"  ,0xfd,CPU8096  ,CPU80296 );
   AddFixed("POPA" ,0xf5,CPU80196 ,CPU80296 );
   AddFixed("POPF" ,0xf3,CPU8096  ,CPU80296 );
   AddFixed("PUSHA",0xf4,CPU80196 ,CPU80296 );
   AddFixed("PUSHF",0xf2,CPU8096  ,CPU80296 );
   AddFixed("RET"  ,0xf0,CPU8096  ,CPU80296 );
   AddFixed("RSC"  ,0xff,CPU8096  ,CPU80296 );
   AddFixed("SETC" ,0xf9,CPU8096  ,CPU80296 );
   AddFixed("TRAP" ,0xf7,CPU8096  ,CPU80296 );
   AddFixed("RETI" ,0xe5,CPU80196N,CPU80296 );

   ALU3Orders=(FixedOrder *) malloc(sizeof(FixedOrder)*ALU3OrderCnt); InstrZ=0;
   AddALU3("ADD" , 0x01);
   AddALU3("AND" , 0x00);
   AddALU3("MUL" , 0x83);   /* ** */
   AddALU3("MULU", 0x03);
   AddALU3("SUB" , 0x02);

   ALU2Orders=(FixedOrder *) malloc(sizeof(FixedOrder)*ALU2OrderCnt); InstrZ=0;
   AddALU2("ADDC", 0xa4);
   AddALU2("CMP" , 0x88);
   AddALU2("DIV" , 0x8c);   /* ** */
   AddALU2("DIVU", 0x8c);
   AddALU2("LD"  , 0xa0);
   AddALU2("OR"  , 0x80);
   AddALU2("ST"  , 0xc0);
   AddALU2("SUBC", 0xa8);
   AddALU2("XOR" , 0x84);

   ALU1Orders=(FixedOrder *) malloc(sizeof(FixedOrder)*ALU1OrderCnt); InstrZ=0;
   AddALU1("CLR", 0x01);
   AddALU1("DEC", 0x05);
   AddALU1("EXT", 0x06);
   AddALU1("INC", 0x07);
   AddALU1("NEG", 0x03);
   AddALU1("NOT", 0x02);

   RelOrders=(FixedOrder *) malloc(sizeof(FixedOrder)*RelOrderCnt); InstrZ=0;
   AddRel("JC"   , 0xdb);
   AddRel("JE"   , 0xdf);
   AddRel("JGE"  , 0xd6);
   AddRel("JGT"  , 0xd2);
   AddRel("JH"   , 0xd9);
   AddRel("JLE"  , 0xda);
   AddRel("JLT"  , 0xde);
   AddRel("JNC"  , 0xd3);
   AddRel("JNE"  , 0xd7);
   AddRel("JNH"  , 0xd1);
   AddRel("JNST" , 0xd0);
   AddRel("JNV"  , 0xd5);
   AddRel("JNVT" , 0xd4);
   AddRel("JST"  , 0xd8);
   AddRel("JV"   , 0xdd);
   AddRel("JVT"  , 0xdc);

   MacOrders=(MacOrder *) malloc(sizeof(MacOrder)*MacOrderCnt); InstrZ=0;
   AddMac("MAC"   ,0x00,False); AddMac("SMAC"  ,0x01,False);
   AddMac("MACR"  ,0x04,True ); AddMac("SMACR" ,0x05,True ); 
   AddMac("MACZ"  ,0x08,False); AddMac("SMACZ" ,0x09,False);
   AddMac("MACRZ" ,0x0c,True ); AddMac("SMACRZ",0x0d,True );

   RptOrders=(FixedOrder *) malloc(sizeof(FixedOrder)*RptOrderCnt); InstrZ=0;
   AddRpt("RPT"    ,0x00); AddRpt("RPTNST" ,0x10); AddRpt("RPTNH"  ,0x11);
   AddRpt("RPTGT"  ,0x12); AddRpt("RPTNC"  ,0x13); AddRpt("RPTNVT" ,0x14);
   AddRpt("RPTNV"  ,0x15); AddRpt("RPTGE"  ,0x16); AddRpt("RPTNE"  ,0x17);
   AddRpt("RPTST"  ,0x18); AddRpt("RPTH"   ,0x19); AddRpt("RPTLE"  ,0x1a);
   AddRpt("RPTC"   ,0x1b); AddRpt("RPTVT"  ,0x1c); AddRpt("RPTV"   ,0x1d);
   AddRpt("RPTLT"  ,0x1e); AddRpt("RPTE"   ,0x1f); AddRpt("RPTI"   ,0x20);
   AddRpt("RPTINST",0x30); AddRpt("RPTINH" ,0x31); AddRpt("RPTIGT" ,0x32);
   AddRpt("RPTINC" ,0x33); AddRpt("RPTINVT",0x34); AddRpt("RPTINV" ,0x35);
   AddRpt("RPTIGE" ,0x36); AddRpt("RPTINE" ,0x37); AddRpt("RPTIST" ,0x38);
   AddRpt("RPTIH"  ,0x39); AddRpt("RPTILE" ,0x3a); AddRpt("RPTIC"  ,0x3b);
   AddRpt("RPTIVT" ,0x3c); AddRpt("RPTIV"  ,0x3d); AddRpt("RPTILT" ,0x3e);
   AddRpt("RPTIE"  ,0x3f);
END

	static void DeinitFields(void)
BEGIN
   free(FixedOrders);
   free(ALU3Orders);
   free(ALU2Orders);
   free(ALU1Orders);
   free(RelOrders);
   free(MacOrders);
   free(RptOrders);
END

/*-------------------------------------------------------------------------*/

	static void ChkSFR(Word Adr)
BEGIN
   if ((Adr>=SFRStart) & (Adr<=SFRStop)) WrError(190);
END

        static void Chk296(Word Adr)
BEGIN
   if ((MomCPU==CPU80296) AND (Adr<=1)) WrError(190);
END

	static Boolean ChkWork(Word *Adr)
BEGIN
   /* Registeradresse, die von Fenstern ueberdeckt wird ? */

   if ((*Adr>=WinBegin) AND (*Adr<=WinEnd)) return False;

   else if ((*Adr>=Win1Begin) AND (*Adr<=Win1End)) return False;

   /* Speicheradresse in Fenster ? */

   else if ((*Adr>=WinStart) AND (*Adr<=WinStop))
    BEGIN
     *Adr=(*Adr)-WinStart+WinBegin; return True;
    END

   else if ((*Adr>=Win1Start) AND (*Adr<=Win1Stop))
    BEGIN
     *Adr=(*Adr)-Win1Start+Win1Begin; return True;
    END

   /* Default */

   else return (*Adr<=0xff);
END

	static void ChkAlign(Byte Adr)
BEGIN
   if (((OpSize==0) AND ((Adr & 1)!=0))
   OR  ((OpSize==1) AND ((Adr & 3)!=0))) WrError(180);
END

	static void ChkAdr(Byte Mask)
BEGIN
   if ((AdrType==ModDir) AND ((Mask & MModDir)==0))
    BEGIN
     AdrType=ModMem; AdrMode=0;
    END

   if ((AdrType!=ModNone) AND ((Mask & (1 << AdrType))==0))
    BEGIN
     WrError(1350); AdrType=ModNone; AdrCnt=0;
    END
END

	static void DecodeAdr(char *Asc, Byte Mask, Boolean AddrWide)
BEGIN
   LongInt AdrInt;
   LongWord AdrWord;
   Word BReg;
   Boolean OK;
   char *p,*p2;
   int l;
   Byte Reg;
   LongWord OMask;

   AdrType=ModNone; AdrCnt=0;
   OMask=(1 << OpSize)-1;

   if (*Asc=='#')
    BEGIN
     switch (OpSize)
      BEGIN
       case -1:
        WrError(1132); break;
       case 0:
	AdrVals[0]=EvalIntExpression(Asc+1,Int8,&OK);
	if (OK)
	 BEGIN
	  AdrType=ModImm; AdrCnt=1; AdrMode=1;
	 END
        break;
       case 1:
	AdrWord=EvalIntExpression(Asc+1,Int16,&OK);
	if (OK)
	 BEGIN
	  AdrType=ModImm; AdrCnt=2; AdrMode=1;
	  AdrVals[0]=Lo(AdrWord); AdrVals[1]=Hi(AdrWord);
	 END
        break;
      END
     ChkAdr(Mask); return;
    END

   p=QuotPos(Asc,'[');
   if (p!=Nil)
    BEGIN
     p2=RQuotPos(Asc,']'); l=strlen(Asc);
     if ((p2>Asc+l-1) OR (p2<Asc+l-2)) WrError(1350);
     else
      BEGIN
       FirstPassUnknown=False; *p2='\0';
       BReg=EvalIntExpression(p+1,Int16,&OK);
       if (FirstPassUnknown) BReg=0;
       if (OK)
        if (NOT ChkWork(&BReg)) WrError(1320);
        else
	 BEGIN
	  Reg=Lo(BReg); ChkSFR(Reg);
	  if ((Reg&1)==1) WrError(1351);
	  else if ((p==Asc) AND (p2==Asc+l-2) AND (Asc[l-1]=='+'))
	   BEGIN
	    AdrType=ModMem; AdrMode=2; AdrCnt=1; AdrVals[0]=Reg+1;
	   END
	  else if (p2!=Asc+l-1) WrError(1350);
	  else if (p==Asc)
	   BEGIN
	    AdrType=ModMem; AdrMode=2; AdrCnt=1; AdrVals[0]=Reg;
	   END
	  else
	   BEGIN
            *p='\0';
	    if (NOT AddrWide) AdrInt=EvalIntExpression(Asc,Int16,&OK); 
            else AdrInt=EvalIntExpression(Asc,Int24,&OK);
	    if (OK)
	     if (AdrInt==0)
	      BEGIN
	       AdrType=ModMem; AdrMode=2; AdrCnt=1; AdrVals[0]=Reg;
	      END
             else if (AddrWide)
              BEGIN
               AdrType=ModMem; AdrMode=3; AdrCnt=4;
               AdrVals[0]=Reg; AdrVals[1]=AdrInt & 0xff;
               AdrVals[2]=(AdrInt >> 8) & 0xff;
               AdrVals[3]=(AdrInt >> 16) & 0xff;
              END
	     else if ((AdrInt>=-128) AND (AdrInt<127))
	      BEGIN
	       AdrType=ModMem; AdrMode=3; AdrCnt=2;
	       AdrVals[0]=Reg; AdrVals[1]=Lo(AdrInt);
	      END
	     else
	      BEGIN
	       AdrType=ModMem; AdrMode=3; AdrCnt=3;
	       AdrVals[0]=Reg+1; AdrVals[1]=Lo(AdrInt); AdrVals[2]=Hi(AdrInt);
	      END
	   END
	 END
      END
    END
   else
    BEGIN
     FirstPassUnknown=False;
     AdrWord=EvalIntExpression(Asc,MemInt,&OK);
     if (FirstPassUnknown) AdrWord&=(0xffffffff-OMask);
     if (OK)
      if ((AdrWord & OMask)!=0) WrError(1325);
      else
       BEGIN
        BReg=AdrWord & 0xffff;
        if (((BReg & 0xffff0000)==0) AND (ChkWork(&BReg)))
 	 BEGIN
 	  AdrType=ModDir; AdrCnt=1; AdrVals[0]=Lo(BReg);
 	 END
        else if (AddrWide)
         BEGIN
          AdrType=ModMem; AdrMode=3; AdrCnt=4; AdrVals[0]=0;
          AdrVals[1]=AdrWord & 0xff; 
          AdrVals[2]=(AdrWord >> 8) & 0xff;
          AdrVals[3]=(AdrWord >> 16) & 0xff;
         END
        else if (AdrWord>=0xff80)
 	 BEGIN
 	  AdrType=ModMem; AdrMode=3; AdrCnt=2; AdrVals[0]=0;
 	  AdrVals[1]=Lo(AdrWord);
 	 END
        else
 	 BEGIN
 	  AdrType=ModMem; AdrMode=3; AdrCnt=3; AdrVals[0]=1;
 	  AdrVals[1]=Lo(AdrWord); AdrVals[2]=Hi(AdrWord);
 	 END
       END
    END

   ChkAdr(Mask);
END

	static void CalcWSRWindow(void)
BEGIN
   if (WSRVal<=0x0f)
    BEGIN
     WinStart=0xffff; WinStop=0; WinBegin=0xff; WinEnd=0;
    END
   else if (WSRVal<=0x1f)
    BEGIN
     WinBegin=0x80; WinEnd=0xff;
     if (WSRVal<0x18) WinStart=(WSRVal-0x10) << 7;
     else WinStart=(WSRVal+0x20) << 7;
     WinStop=WinStart+0x7f;
    END
   else if (WSRVal<=0x3f)
    BEGIN
     WinBegin=0xc0; WinEnd=0xff;
     if (WSRVal<0x30) WinStart=(WSRVal-0x20) << 6;
     else WinStart=(WSRVal+0x40) << 6;
     WinStop=WinStart+0x3f;
    END
   else if (WSRVal<=0x7f)
    BEGIN
     WinBegin=0xe0; WinEnd=0xff;
     if (WSRVal<0x60) WinStart=(WSRVal-0x40) << 5;
     else WinStart=(WSRVal+0x80) << 5;
     WinStop=WinStart+0x1f;
    END
   if ((WinStop>0x1fdf) AND (MomCPU<CPU80296)) WinStop=0x1fdf;
END

        static void CalcWSR1Window(void)
BEGIN
   if (WSR1Val<=0x1f)
    BEGIN
     Win1Start=0xffff; Win1Stop=0; Win1Begin=0xff; Win1End=0;
    END
   else if (WSR1Val<=0x3f)
    BEGIN
     Win1Begin=0x40; Win1End=0x7f;
     if (WSR1Val<0x30) Win1Start=(WSR1Val-0x20) << 6;
     else Win1Start=(WSR1Val+0x40) << 6;
     Win1Stop=Win1Start+0x3f;
    END
   else if (WSR1Val<=0x7f)
    BEGIN
     Win1Begin=0x60; Win1End=0x7f;
     if (WSR1Val<0x60) Win1Start=(WSR1Val-0x40) << 5;
     else Win1Start=(WSR1Val+0x80) << 5;
     Win1Stop=Win1Start+0x1f;
    END
   else
    BEGIN
     Win1Begin=0x40; Win1End=0x7f;
     Win1Start=(WSR1Val+0x340) << 6;
     Win1Stop=Win1Start+0x3f;
    END
END

	static Boolean DecodePseudo(void)
BEGIN
#define ASSUME96Count 2
   static ASSUMERec ASSUME96s[ASSUME96Count]=
	     {{"WSR", &WSRVal, 0, 0xff, 0x00},
              {"WSR1", &WSR1Val, 0, 0xbf, 0x00}};

   if (Memo("ASSUME"))
    BEGIN
     if (MomCPU<CPU80196) WrError(1500);
     else CodeASSUME(ASSUME96s,(MomCPU>=CPU80296)?ASSUME96Count:1);
     WSRVal&=0x7f;
     CalcWSRWindow(); CalcWSR1Window();
     return True;
    END

   return False;
END

	static Boolean BMemo(char *Name)
BEGIN
   int l;

   if (strncmp(OpPart,Name,l=strlen(Name))!=0) return False;
   switch (OpPart[l])
    BEGIN
     case '\0':
      OpSize=1; return True;
     case 'B':
      if (OpPart[l+1]=='\0')
       BEGIN
        OpSize=0; return True;
       END
      else return False;
     default:
      return False;
    END
END

	static Boolean LMemo(char *Name)
BEGIN
   int l;

   if (strncmp(OpPart,Name,l=strlen(Name))!=0) return False;
   switch (OpPart[l])
    BEGIN
     case '\0':
      OpSize=1; return True;
     case 'B':
      if (OpPart[l+1]=='\0')
       BEGIN
        OpSize=0; return True;
       END
      else return False;
     case 'L':
      if (OpPart[l+1]=='\0')
       BEGIN
        OpSize=2; return True;
       END
      else return False;
     default:
      return False;
    END
END

	static void MakeCode_96(void)
BEGIN
   Boolean OK,Special,IsShort;
   Word AdrWord;
   int z;
   LongInt AdrInt;
   Byte Start,HReg,Mask;

   CodeLen=0; DontPrint=False; OpSize=(-1);

   /* zu ignorierendes */

   if (Memo("")) return;

   /* Pseudoanweisungen */

   if (DecodePseudo()) return;

   if (DecodeIntelPseudo(False)) return;

   /* ohne Argument */

   for (z=0; z<FixedOrderCnt; z++)
    if (Memo(FixedOrders[z].Name))
     BEGIN
      if (ArgCnt!=0) WrError(1110);
      else if (MomCPU<FixedOrders[z].MinCPU) WrError(1500);
      else BAsmCode[(CodeLen=1)-1]=FixedOrders[z].Code;
      return;
     END

   /* Arithmetik */

   for (z=0; z<ALU3OrderCnt; z++)
    if (BMemo(ALU3Orders[z].Name))
     BEGIN
      if ((ArgCnt!=2) AND (ArgCnt!=3)) WrError(1110);
      else
       BEGIN
        Start=0; Special=(strncmp(ALU3Orders[z].Name,"MUL",3)==0);
        if ((ALU3Orders[z].Code & 0x80)!=0) BAsmCode[Start++]=0xfe;
        BAsmCode[Start++]=0x40+(Ord(ArgCnt==2) << 5)
       		          +((1-OpSize) << 4)
       		          +((ALU3Orders[z].Code & 0x7f) << 2);
        DecodeAdr(ArgStr[ArgCnt],MModImm+MModMem,False);
        if (AdrType!=ModNone)
         BEGIN
          BAsmCode[Start-1]+=AdrMode;
          memcpy(BAsmCode+Start,AdrVals,AdrCnt); Start+=AdrCnt;
          if ((Special) AND (AdrMode==0)) ChkSFR(AdrVals[0]);
          if (ArgCnt==3)
           BEGIN
            DecodeAdr(ArgStr[2],MModDir,False);
            OK=(AdrType!=ModNone);
            if (OK)
             BEGIN
              BAsmCode[Start++]=AdrVals[0];
              if (Special) ChkSFR(AdrVals[0]);
             END
           END
          else OK=True;
          if (OK)
           BEGIN
            DecodeAdr(ArgStr[1],MModDir,False);
            if (AdrType!=ModNone)
             BEGIN
              BAsmCode[Start]=AdrVals[0]; CodeLen=Start+1;
              if (Special)
       	       BEGIN
       	        ChkSFR(AdrVals[0]);
                Chk296(AdrVals[0]);
                ChkAlign(AdrVals[0]);
       	       END
             END
           END
         END
       END
      return;
     END

   for (z=0; z<ALU2OrderCnt; z++)
    if (BMemo(ALU2Orders[z].Name))
     BEGIN
      if (ArgCnt!=2) WrError(1110);
      else
       BEGIN
        Start=0; Special=(strncmp(OpPart,"DIV",3)==0);
        if (strcmp(ALU2Orders[z].Name,"DIV")==0) BAsmCode[Start++]=0xfe;
        HReg=(1+Ord(strcmp(ALU2Orders[z].Name,"ST")!=0)) << 1;
        BAsmCode[Start++]=ALU2Orders[z].Code+((1-OpSize) << HReg);
        Mask=MModMem; if (NOT BMemo("ST")) Mask+=MModImm;
        DecodeAdr(ArgStr[2],Mask,False);
        if (AdrType!=ModNone)
         BEGIN
          BAsmCode[Start-1]+=AdrMode;
          memcpy(BAsmCode+Start,AdrVals,AdrCnt); Start+=AdrCnt;
          if ((Special) AND (AdrMode==0)) ChkSFR(AdrVals[0]);
          DecodeAdr(ArgStr[1],MModDir,False);
          if (AdrType!=ModNone)
           BEGIN
            BAsmCode[Start]=AdrVals[0]; CodeLen=1+Start;
            if (Special)
             BEGIN
              ChkSFR(AdrVals[0]); ChkAlign(AdrVals[0]);
             END
           END
         END
       END
      return;
     END

   if (Memo("CMPL"))
    BEGIN
     if (ArgCnt!=2) WrError(1110);
     else if (MomCPU<CPU80196) WrError(1500);
     else
      BEGIN
       OpSize=2;
       DecodeAdr(ArgStr[1],MModDir,False);
       if (AdrType!=ModNone)
        BEGIN
         BAsmCode[2]=AdrVals[0];
         DecodeAdr(ArgStr[2],MModDir,False);
         if (AdrType!=ModNone)
          BEGIN
           BAsmCode[1]=AdrVals[0]; BAsmCode[0]=0xc5; CodeLen=3;
          END
        END
      END
     return;
    END

   if ((Memo("PUSH")) OR (Memo("POP")))
    BEGIN
     OpSize=1;
     if (ArgCnt!=1) WrError(1110);
     else
      BEGIN
       Mask=MModMem; if (Memo("PUSH")) Mask+=MModImm;
       DecodeAdr(ArgStr[1],Mask,False);
       if (AdrType!=ModNone)
	BEGIN
	 CodeLen=1+AdrCnt;
	 BAsmCode[0]=0xc8+AdrMode+(Ord(Memo("POP")) << 2);
	 memcpy(BAsmCode+1,AdrVals,AdrCnt);
	END
      END
     return;
    END

   if ((Memo("BMOV")) OR (Memo("BMOVI")) OR (Memo("EBMOVI")))
    BEGIN
     if (ArgCnt!=2) WrError(1110);
     else if (MomCPU<CPU80196) WrError(1500);
     else if ((MomCPU<CPU80196N) AND (Memo("EBMOVI"))) WrError(1500);
     else
      BEGIN
       OpSize=2; DecodeAdr(ArgStr[1],MModDir,False);
       if (AdrType!=ModNone)
        BEGIN
         BAsmCode[2]=AdrVals[0];
         OpSize=1; DecodeAdr(ArgStr[2],MModDir,False);
         if (AdrType!=ModNone)
          BEGIN
           BAsmCode[1]=AdrVals[0];
           if (Memo("BMOVI")) BAsmCode[0]=0xad;
           else if (Memo("BMOV")) BAsmCode[0]=0xc1;
           else BAsmCode[0]=0xe4;          
           CodeLen=3;
          END
        END
      END
     return;
    END

   for (z=0; z<ALU1OrderCnt; z++)
    if (BMemo(ALU1Orders[z].Name))
     BEGIN
      if (ArgCnt!=1) WrError(1110);
      else
       BEGIN
        DecodeAdr(ArgStr[1],MModDir,False);
        if (AdrType!=ModNone)
         BEGIN
          CodeLen=1+AdrCnt;
          BAsmCode[0]=ALU1Orders[z].Code+((1-OpSize) << 4);
          memcpy(BAsmCode+1,AdrVals,AdrCnt);
          if (BMemo("EXT")) ChkAlign(AdrVals[0]);
         END
       END
      return;
     END

   if (BMemo("XCH"))
    BEGIN
     if (ArgCnt!=2) WrError(1110);
     else if (MomCPU<CPU80196) WrError(1500);
     else
      BEGIN
       DecodeAdr(ArgStr[1],MModMem+MModDir,False);
       switch (AdrType)
        BEGIN
         case ModMem:
          if (AdrMode==1) WrError(1350);
          else
           BEGIN
            memcpy(BAsmCode+1,AdrVals,AdrCnt); HReg=AdrCnt;
            BAsmCode[0]=0x04+((1-OpSize) << 4)+AdrMode;
            DecodeAdr(ArgStr[2],MModDir,False);
            if (AdrType!=ModNone)
             BEGIN
              BAsmCode[1+HReg]=AdrVals[0]; CodeLen=2+HReg;
             END
           END
          break;
         case ModDir:
          HReg=AdrVals[0];
          DecodeAdr(ArgStr[2],MModMem,False);
          if (AdrType!=ModNone)
           if (AdrMode==1) WrError(1350);
           else
            BEGIN
             BAsmCode[0]=0x04+((1-OpSize) << 4)+AdrMode;
             memcpy(BAsmCode+1,AdrVals,AdrCnt);
             BAsmCode[1+AdrCnt]=HReg; CodeLen=2+AdrCnt;
            END
          break;
        END
      END
     return;
    END

   if ((Memo("LDBZE")) OR (Memo("LDBSE")))
    BEGIN
     if (ArgCnt!=2) WrError(1110);
     else
      BEGIN
       OpSize=0;
       DecodeAdr(ArgStr[2],MModMem+MModImm,False);
       if (AdrType!=ModNone)
	BEGIN
	 BAsmCode[0]=0xac+(Ord(Memo("LDBSE")) << 4)+AdrMode;
	 memcpy(BAsmCode+1,AdrVals,AdrCnt); Start=1+AdrCnt;
	 OpSize=1; DecodeAdr(ArgStr[1],MModDir,False);
	 if (AdrType!=ModNone)
	  BEGIN
	   BAsmCode[Start]=AdrVals[0]; CodeLen=1+Start;
	  END
	END
      END
     return;
    END

   if (Memo("NORML"))
    BEGIN
     if (ArgCnt!=2) WrError(1110);
     else
      BEGIN
       OpSize=0; DecodeAdr(ArgStr[2],MModDir,False);
       if (AdrType!=ModNone)
	BEGIN
	 BAsmCode[1]=AdrVals[0];
	 OpSize=1; DecodeAdr(ArgStr[1],MModDir,False);
	 if (AdrType!=ModNone)
	  BEGIN
	   CodeLen=3; BAsmCode[0]=0x0f; BAsmCode[2]=AdrVals[0];
	   ChkAlign(AdrVals[0]);
	  END
	END
      END
     return;
    END

   if (Memo("IDLPD"))
    BEGIN
     if (ArgCnt!=1) WrError(1110);
     else if (MomCPU<CPU80196) WrError(1500);
     else
      BEGIN
       OpSize=0; DecodeAdr(ArgStr[1],MModImm,False);
       if (AdrType!=ModNone)
        BEGIN
         CodeLen=2; BAsmCode[0]=0xf6; BAsmCode[1]=AdrVals[0];
        END
      END
     return;
    END

   for (z=0; z<ShiftOrderCnt; z++)
    if (LMemo(ShiftOrders[z]))
     BEGIN
      if (ArgCnt!=2) WrError(1110);
      else
       BEGIN
	DecodeAdr(ArgStr[1],MModDir,False);
	if (AdrType!=ModNone)
	 BEGIN
	  BAsmCode[0]=0x08+z+(Ord(OpSize==0) << 4)+(Ord(OpSize==2) << 2);
	  BAsmCode[2]=AdrVals[0];
	  OpSize=0; DecodeAdr(ArgStr[2],MModDir+MModImm,False);
	  if (AdrType!=ModNone)
	   if ((AdrType==ModImm) AND (AdrVals[0]>15)) WrError(1320);
	   else if ((AdrType==ModDir) AND (AdrVals[0]<16)) WrError(1315);
	   else
	    BEGIN
	     BAsmCode[1]=AdrVals[0]; CodeLen=3;
	    END
	 END
       END
      return;
     END

   if (Memo("SKIP"))
    BEGIN
     if (ArgCnt!=1) WrError(1110);
     else
      BEGIN
       OpSize=0; DecodeAdr(ArgStr[1],MModDir,False);
       if (AdrType!=ModNone)
	BEGIN
	 CodeLen=2; BAsmCode[0]=0; BAsmCode[1]=AdrVals[0];
	END
      END
     return;
    END

   if ((BMemo("ELD")) OR (BMemo("EST")))
    BEGIN 
     if (ArgCnt!=2) WrError(1110);
     else if (MomCPU<CPU80196N) WrError(1500);
     else
      BEGIN
       DecodeAdr(ArgStr[2],MModMem,True);
       if (AdrType==ModMem)
        if ((AdrMode==2) AND (Odd(AdrVals[0]))) WrError(1350); /* kein Autoincrement */
        else
         BEGIN
          BAsmCode[0]=(AdrMode & 1)+((1-OpSize) << 1);
          if (OpPart[1]=='L') BAsmCode[0]+=0xe8;
                         else BAsmCode[0]+=0x1c;
          memcpy(BAsmCode+1,AdrVals,AdrCnt); HReg=1+AdrCnt;
          DecodeAdr(ArgStr[1],MModDir,False);
          if (AdrType==ModDir)  
           BEGIN
            BAsmCode[HReg]=AdrVals[0]; CodeLen=HReg+1;
           END; 
         END;
      END;
     return;
    END

   for (z=0; z<MacOrderCnt; z++)
    if (Memo(MacOrders[z].Name))
     BEGIN
      if ((ArgCnt!=1) AND (ArgCnt!=2)) WrError(1110);
      else if (MomCPU<CPU80296) WrError(1500);
      else
       BEGIN
        OpSize=1; BAsmCode[0]=0x4c+(Ord(ArgCnt==1) << 5);
        if (MacOrders[z].Reloc) DecodeAdr(ArgStr[ArgCnt],MModMem,False);
        else DecodeAdr(ArgStr[ArgCnt],MModMem+MModImm,False);
        if (AdrType!=ModNone)
         BEGIN
          BAsmCode[0]+=AdrMode;
          memcpy(BAsmCode+1,AdrVals,AdrCnt); HReg=1+AdrCnt;
          if (ArgCnt==2)
           BEGIN
            DecodeAdr(ArgStr[1],MModDir,False);
            if (AdrType==ModDir)
             BEGIN
              BAsmCode[HReg]=AdrVals[0]; HReg++;
             END
           END
          if (AdrType!=ModNone)
           BEGIN
            BAsmCode[HReg]=MacOrders[z].Code; CodeLen=1+HReg;
           END
         END  
       END
      return;
     END

   if ((Memo("MVAC")) OR (Memo("MSAC")))
    BEGIN
     if (ArgCnt!=2) WrError(1110);
     else if (MomCPU<CPU80296) WrError(1500);
     else
      BEGIN
       OpSize=2; DecodeAdr(ArgStr[1],MModDir,False);
       if (AdrType==ModDir)
        BEGIN
         BAsmCode[0]=0x0d; BAsmCode[2]=AdrVals[0]+1+(Ord(Memo("MSAC")) << 1);
         OpSize=0; DecodeAdr(ArgStr[2],MModImm+MModDir,False);
         BAsmCode[1]=AdrVals[0];
         switch (AdrType)
          BEGIN
           case ModImm:
            if (AdrVals[0]>31) WrError(1320); else CodeLen=3;
            break;
           case ModDir:
            if (AdrVals[0]<32) WrError(1315); else CodeLen=3;
          END
        END 
      END      
     return;  
    END        

   for (z=0; z<RptOrderCnt; z++)
    if (Memo(RptOrders[z].Name))
     BEGIN
      if (ArgCnt!=1) WrError(1110);
      else if (MomCPU<CPU80296) WrError(1500);
      else
       BEGIN
        OpSize=1; DecodeAdr(ArgStr[1],MModImm+MModMem,False);
        if (AdrType!=ModNone)
         if (AdrMode==3) WrError(1350);
         else   
          BEGIN
           BAsmCode[0]=0x40+AdrMode;
           memcpy(BAsmCode+1,AdrVals,AdrCnt);
           BAsmCode[1+AdrCnt]=RptOrders[z].Code;
           BAsmCode[2+AdrCnt]=4;
           CodeLen=3+AdrCnt;
          END
       END
      return;
     END

   /* Spruenge */

   for (z=0; z<RelOrderCnt; z++)
    if (Memo(RelOrders[z].Name))
     BEGIN
      if (ArgCnt!=1) WrError(1110);
      else
       BEGIN
        AdrInt=EvalIntExpression(ArgStr[1],MemInt,&OK)-(EProgCounter()+2);
        if (OK)
         if ((NOT SymbolQuestionable) AND ((AdrInt<-128) OR (AdrInt>127))) WrError(1370);
         else
          BEGIN
           CodeLen=2; BAsmCode[0]=RelOrders[z].Code; BAsmCode[1]=AdrInt & 0xff;
          END
       END
      return;
     END

   if ((Memo("SCALL")) OR (Memo("LCALL")) OR (Memo("CALL")))
    BEGIN
     if (ArgCnt!=1) WrError(1110);
     else
      BEGIN
       AdrWord=EvalIntExpression(ArgStr[1],MemInt,&OK);
       if (OK)
	BEGIN
	 AdrInt=AdrWord-(EProgCounter()+2);
	 if (Memo("SCALL")) IsShort=True;
	 else if (Memo("LCALL")) IsShort=False;
	 else IsShort=((AdrInt>=-1024) AND (AdrInt<1023));
	 if (IsShort)
	  BEGIN
	   if ((NOT SymbolQuestionable) AND ((AdrInt<-1024) OR (AdrInt>1023))) WrError(1370);
	   else
	    BEGIN
	     CodeLen=2; BAsmCode[1]=AdrInt & 0xff;
	     BAsmCode[0]=0x28+((AdrInt & 0x700) >> 8);
	    END
	  END
	 else
	  BEGIN
           CodeLen=3; BAsmCode[0]=0xef; AdrInt--;
           BAsmCode[1]=Lo(AdrInt); BAsmCode[2]=Hi(AdrInt);
	   if ((NOT SymbolQuestionable) AND (AdrInt>=-1024) AND (AdrInt<=1023)) WrError(20);
	  END
	END
      END
     return;
    END

   if ((Memo("BR")) OR (Memo("LJMP")) OR (Memo("SJMP")))
    BEGIN
     OpSize=1;
     if (ArgCnt!=1) WrError(1110);
     else if ((Memo("BR")) AND (QuotPos(ArgStr[1],'[')!=Nil))
      BEGIN
       DecodeAdr(ArgStr[1],MModMem,False);
       if (AdrType!=ModNone)
	if ((AdrMode!=2) OR ((AdrVals[0]&1)==1)) WrError(1350);
	else
	 BEGIN
	  CodeLen=2; BAsmCode[0]=0xe3; BAsmCode[1]=AdrVals[0];
	 END
      END
     else
      BEGIN
       AdrWord=EvalIntExpression(ArgStr[1],MemInt,&OK);
       if (OK)
	BEGIN
	 AdrInt=AdrWord-(EProgCounter()+2);
	 if (Memo("SJMP")) IsShort=True;
	 else if (Memo("LJMP")) IsShort=False;
	 else IsShort=((AdrInt>=-1024) AND (AdrInt<1023));
	 if (IsShort)
	  BEGIN
	   if ((NOT SymbolQuestionable) AND ((AdrInt<-1024) OR (AdrInt>1023))) WrError(1370);
	   else
	    BEGIN
	     CodeLen=2; BAsmCode[1]=AdrInt & 0xff;
	     BAsmCode[0]=0x20+((AdrInt & 0x700) >> 8);
	    END
	  END
	 else
	  BEGIN
           CodeLen=3; BAsmCode[0]=0xe7; AdrInt--;
           BAsmCode[1]=Lo(AdrInt); BAsmCode[2]=Hi(AdrInt);
	   if ((NOT SymbolQuestionable) AND (AdrInt>=-1024) AND (AdrInt<=1023)) WrError(20);
	  END
	END
      END
     return;
    END

   if (Memo("TIJMP"))
    BEGIN
     if (ArgCnt!=3) WrError(1110);
     else if (MomCPU<CPU80196) WrError(1500);
     else
      BEGIN
       OpSize=1; DecodeAdr(ArgStr[1],MModDir,False);
       if (AdrType!=ModNone)
        BEGIN
         BAsmCode[3]=AdrVals[0];
         DecodeAdr(ArgStr[2],MModDir,False);
         if (AdrType!=ModNone)
          BEGIN
           BAsmCode[1]=AdrVals[0];
           OpSize=0; DecodeAdr(ArgStr[3],MModImm,False);
           if (AdrType!=ModNone)
            BEGIN
             BAsmCode[2]=AdrVals[0]; BAsmCode[0]=0xe2; CodeLen=4;
            END
          END
        END
      END
     return;
    END

   if ((Memo("DJNZ")) OR (Memo("DJNZW")))
    BEGIN
     if (ArgCnt!=2) WrError(1110);
     else if ((Memo("DJNZW")) AND (MomCPU<CPU80196)) WrError(1500);
     else
      BEGIN
       OpSize=Ord(Memo("DJNZW"));
       DecodeAdr(ArgStr[1],MModDir,False);
       if (AdrType!=ModNone)
	BEGIN
	 BAsmCode[0]=0xe0+OpSize; BAsmCode[1]=AdrVals[0];
	 AdrInt=EvalIntExpression(ArgStr[2],MemInt,&OK)-(EProgCounter()+3);
	 if (OK)
	  if ((NOT SymbolQuestionable) AND ((AdrInt<-128) OR (AdrInt>127))) WrError(1370);
	  else
	   BEGIN
	    CodeLen=3; BAsmCode[2]=AdrInt & 0xff;
	   END
	END
      END
     return;
    END

   if ((Memo("JBC")) OR (Memo("JBS")))
    BEGIN
     if (ArgCnt!=3) WrError(1110);
     else
      BEGIN
       BAsmCode[0]=EvalIntExpression(ArgStr[2],UInt3,&OK);
       if (OK)
	BEGIN
	 BAsmCode[0]+=0x30+(Ord(Memo("JBS")) << 3);
	 OpSize=0; DecodeAdr(ArgStr[1],MModDir,False);
	 if (AdrType!=ModNone)
	  BEGIN
	   BAsmCode[1]=AdrVals[0];
	   AdrInt=EvalIntExpression(ArgStr[3],MemInt,&OK)-(EProgCounter()+3);
	   if (OK)
	    if ((NOT SymbolQuestionable) AND ((AdrInt<-128) OR (AdrInt>127))) WrError(1370);
	    else
	     BEGIN
	      CodeLen=3; BAsmCode[2]=AdrInt & 0xff;
	     END
	  END
	END
      END
     return;
    END

   if (Memo("ECALL"))
    BEGIN
     if (ArgCnt!=1) WrError(1110);
     else if (MomCPU<CPU80196N) WrError(1500);
     else  
      BEGIN
       AdrInt=EvalIntExpression(ArgStr[1],MemInt,&OK)-(EProgCounter()+4);
       if (OK)
        BEGIN
         BAsmCode[0]=0xf1;
         BAsmCode[1]=AdrInt & 0xff;
         BAsmCode[2]=(AdrInt >> 8) & 0xff; 
         BAsmCode[3]=(AdrInt >> 16) & 0xff;
         CodeLen=4;
        END
      END
     return;
    END

   if ((Memo("EJMP")) OR (Memo("EBR")))
    BEGIN
     OpSize=1;
     if (ArgCnt!=1) WrError(1110);
     else if (MomCPU<CPU80196N) WrError(1500);
     else if (*ArgStr[1]=='[')
      BEGIN
       DecodeAdr(ArgStr[1],MModMem,False);
       if (AdrType==ModMem)
        if (AdrMode!=2) WrError(1350);
        else if (Odd(AdrVals[0])) WrError(1350);
        else
         BEGIN
          BAsmCode[0]=0xe3; BAsmCode[1]=AdrVals[0]+1;
          CodeLen=2;
         END
      END
     else
      BEGIN
       AdrInt=EvalIntExpression(ArgStr[1],MemInt,&OK)-(EProgCounter()+4);
       if (OK)
        BEGIN
         BAsmCode[0]=0xe6;
         BAsmCode[1]=AdrInt & 0xff;
         BAsmCode[2]=(AdrInt >> 8) & 0xff;
         BAsmCode[3]=(AdrInt >> 16) & 0xff;
         CodeLen=4;
        END
      END  
     return;
    END    

   WrXError(1200,OpPart);
END

	static void InitCode_96(void)
BEGIN
   SaveInitProc();
   WSRVal=0; CalcWSRWindow();
   WSR1Val=0; CalcWSR1Window();
END

	static Boolean IsDef_96(void)
BEGIN
   return False;
END

        static void SwitchFrom_96(void)
BEGIN
   DeinitFields();
END

	static void SwitchTo_96(void)
BEGIN
   TurnWords=False; ConstMode=ConstModeIntel; SetIsOccupied=False;

   PCSymbol="$"; HeaderID=0x39; NOPCode=0xfd;
   DivideChars=","; HasAttrs=False;

   ValidSegs=1<<SegCode;
   Grans[SegCode ]=1; ListGrans[SegCode ]=1; SegInits[SegCode ]=0;
   SegLimits[SegCode] = (MomCPU >= CPU80196N) ? 0xffffffl : 0xffff;

   MakeCode=MakeCode_96; IsDef=IsDef_96;
   SwitchFrom=SwitchFrom_96;

   if (MomCPU>=CPU80196N) MemInt=UInt24;
   else MemInt=UInt16;

   InitFields();
END

	void code96_init(void)
BEGIN
   CPU8096  =AddCPU("8096"  ,SwitchTo_96);
   CPU80196 =AddCPU("80196" ,SwitchTo_96);
   CPU80196N=AddCPU("80196N",SwitchTo_96);
   CPU80296 =AddCPU("80296" ,SwitchTo_96);

   SaveInitProc=InitPassProc; InitPassProc=InitCode_96;
END