/[projet1]/public/pc/tools/osdk/main/xa/sources/xa.cpp
Defence Force logotype

Contents of /public/pc/tools/osdk/main/xa/sources/xa.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1391 - (show annotations)
Sat Mar 18 19:15:40 2017 UTC (2 years, 8 months ago) by dbug
File size: 19985 byte(s)
XA 2.2.4
- Extended the values for a number of hardcoded defines (labels, blocks, number of open files, etc...)
1
2 #pragma warning( disable : 4786) // Debug symbols thing
3
4 #include <vector>
5 #include <string>
6
7
8 #include <ctype.h>
9 #include <string.h>
10 #include <stdio.h>
11 #include <stdlib.h>
12 #include <time.h>
13 /* structs and defs */
14
15 #include "common.h"
16
17 #include "xah.h"
18 #include "xah2.h"
19
20 /* exported functions are defined here */
21
22 #include "xar.h"
23 #include "xa.h"
24 #include "xam.h"
25 #include "xal.h"
26 #include "xap.h"
27 #include "xat.h"
28 #include "xao.h"
29
30 /* exported globals */
31
32
33 FileData *afile = NULL;
34
35 int gFlag_ncmos;
36 int gFlag_cmosfl;
37 int gFlag_w65816;
38 int gFlag_n65816;
39
40 int gFlagMasmCompatibilityMode = 0;
41 int nolink = 0;
42 int romable = 0;
43 int romadr = 0;
44 int noglob = 0;
45 int gFlag_ShowBlocks = 0;
46
47 /* local variables */
48
49
50
51 static char out[MAXLINE];
52 static time_t tim1;
53 static time_t tim2;
54 static FILE *gOutputFileHandle;
55 FILE *gErrorFileHandle;
56 static FILE *gSymbolsFileHandle;
57 static int ner = 0;
58
59 static int align = 1;
60
61 static void printstat(void);
62 static void usage(void);
63 static int setfext(char*,char*);
64 static int pass1(void);
65 static ErrorCode getline(char*);
66 static void lineout(void);
67 static long ga_p1(void);
68 static long gm_p1(void);
69 int unlink(const char *);
70 /* text */
71
72 int memode;
73 int xmode;
74
75 SEGMENT_e gCurrentSegment;
76 int SectionTextLenght=0;
77 int SectionTextBase=0x1000;
78 int SectionDataLenght=0;
79 int SectionDataBase=0x0400;
80 int SectionBssLenght=0;
81 int SectionBssBase=0x4000;
82 int SectionZeroLenght=0;
83 int SectionZeroBase=4;
84
85
86 int fmode=0;
87 int relmode=0;
88
89 int TablePcSegment[_eSEGMENT_MAX_]; /* segments */
90
91
92
93 static const char *copyright=
94 {
95 #ifdef _WIN32
96 "Cross-Assembler 65xx V2.2.4 ("__TIME__" / "__DATE__") \r\n"
97 #else
98 "Cross-Assembler 65xx V2.2.4 (No date available) \r\n"
99 #endif
100 "(c) 1989-98 by A.Fachat\r\n"
101 "65816 opcodes and modes coded by Jolse Maginnis\r\n"
102 "Oric C adaptation and debugging by Mickael Pointier\r\n"
103 "Clean Linux port by Jean-Yves Lamoureux\r\n"
104 };
105
106 static void usage(void)
107 {
108 fprintf(stderr, "%s",copyright);
109 fprintf(stderr, "usage : xa { option | sourcefile }\n"
110 "options:\n"
111 " -v = verbose output\n"
112 " -C = no CMOS-opcodes\n"
113 " -W = no 65816-opcodes\n"
114 " -B = show lines with block open/close\n"
115 " -c = produce o65 object instead of executable files (i.e. do not link)\n"
116 " -o filename = sets output filename, default is 'a.o65'\n"
117 " A filename of '-' sets stdout as output file\n"
118 " -e filename = sets errorlog filename, default is none\n"
119 " -l filename = sets labellist filename, default is none\n"
120 " -M = allow \":\" to appear in comments, for MASM compatibility\n"
121 " -R = start assembler in relocating mode\n"
122 " -Llabel = defines 'label' as absolute, undefined label even when linking\n"
123 " -b? adr = set segment base address to integer value adr. \n"
124 " '?' stands for t(ext), d(ata), b(ss) and z(ero) segment\n"
125 " (address can be given more than once, latest is taken)\n"
126 " -A adr = make text segment start at an address that when the _file_\n"
127 " starts at adr, relocation is not necessary. Overrides -bt\n"
128 " Other segments have to be take care of with -b?\n"
129 " -G = suppress list of exported globals\n"
130 " -DDEF=TEXT = defines a preprocessor replacement\n"
131 " -Idir = add directory 'dir' to include path (before XAINPUT)\n"
132 "Environment:\n"
133 " XAINPUT = include file path; components divided by ','\n"
134 " XAOUTPUT= output file path\n"
135 );
136 }
137
138
139
140
141 int main(int argc,char *argv[])
142 {
143 int er=1,i;
144 signed char *s=NULL;
145
146 bool bFlagVerbose = false;
147
148 std::vector<std::string> cInputFileList;
149
150 tim1=time(NULL);
151
152 gFlag_ncmos=0;
153 gFlag_n65816=0;
154 gFlag_cmosfl=1;
155 gFlag_w65816=1;
156
157 afile = new FileData;
158 if (!afile)
159 {
160 return 1;
161 }
162
163 if (argc<=1)
164 {
165 usage();
166 return 1;
167 }
168
169 char* ptr_output_filename ="a.o65";
170 char* ptr_error_filename =NULL;
171 char* ptr_symbols_filename =NULL;
172
173 if (gPreprocessor.Init())
174 {
175 logout("fatal: pp: no memory!");
176 return 1;
177 }
178 if (b_init())
179 {
180 logout("fatal: b: no memory!");
181 return 1;
182 }
183
184
185 i=1;
186 while (i<argc)
187 {
188 if (argv[i][0]=='-')
189 {
190 switch (argv[i][1])
191 {
192 case 'M':
193 // MASM compatibility mode
194 gFlagMasmCompatibilityMode = 1;
195 break;
196
197 case 'A':
198 // make text segment start so that text relocation
199 // is not necessary when _file_ starts at adr
200 romable = 2;
201 if (argv[i][2]==0)
202 {
203 romadr = ConvertAdress(argv[++i]);
204 }
205 else
206 {
207 romadr = ConvertAdress(argv[i]+2);
208 }
209 break;
210
211 case 'G':
212 noglob = 1;
213 break;
214
215 case 'L':
216 // define global label
217 if (argv[i][2])
218 {
219 afile->m_cSymbolData.DefineGlobalLabel(argv[i]+2);
220 }
221 break;
222
223 case 'R':
224 relmode = 1;
225 break;
226
227 case 'D':
228 s = (signed char*)strstr(argv[i]+2,"=");
229 if (s) *s = ' ';
230 gPreprocessor.command_define(argv[i]+2);
231 break;
232
233 case 'c':
234 fmode |= FM_OBJ;
235 break;
236
237 case 'v':
238 bFlagVerbose = true;
239 break;
240
241 case 'C':
242 gFlag_cmosfl = 0;
243 break;
244
245 case 'W':
246 gFlag_w65816 = 0;
247 break;
248
249 case 'B':
250 gFlag_ShowBlocks = 1;
251 break;
252
253 case 'I':
254 if (argv[i][2]==0)
255 {
256 reg_include(argv[++i]);
257 }
258 else
259 {
260 reg_include(argv[i]+2);
261 }
262 break;
263
264 case 'o':
265 if (argv[i][2]==0)
266 {
267 ptr_output_filename=argv[++i];
268 }
269 else
270 {
271 ptr_output_filename=argv[i]+2;
272 }
273 break;
274
275 case 'l':
276 if (argv[i][2]==0)
277 {
278 ptr_symbols_filename=argv[++i];
279 }
280 else
281 {
282 ptr_symbols_filename=argv[i]+2;
283 }
284 break;
285
286 case 'e':
287 if (argv[i][2]==0)
288 {
289 ptr_error_filename=argv[++i];
290 }
291 else
292 {
293 ptr_error_filename=argv[i]+2;
294 }
295 break;
296
297 case 'b':
298 // set segment base addresses
299 switch (argv[i][2])
300 {
301 case 't':
302 if (argv[i][3]==0) SectionTextBase = ConvertAdress(argv[++i]);
303 else SectionTextBase = ConvertAdress(argv[i]+3);
304 break;
305
306 case 'd':
307 if (argv[i][3]==0) SectionDataBase = ConvertAdress(argv[++i]);
308 else SectionDataBase = ConvertAdress(argv[i]+3);
309 break;
310
311 case 'b':
312 if (argv[i][3]==0) SectionBssBase = ConvertAdress(argv[++i]);
313 else SectionBssBase = ConvertAdress(argv[i]+3);
314 break;
315
316 case 'z':
317 if (argv[i][3]==0) SectionZeroBase = ConvertAdress(argv[++i]);
318 else SectionZeroBase = ConvertAdress(argv[i]+3);
319 break;
320
321 default:
322 fprintf(stderr,"unknow segment type '%c' - ignoring!\n",argv[i][2]);
323 break;
324 }
325 break;
326
327 case 0:
328 fprintf(stderr, "Single dash '-' on command line - ignoring!\n");
329 break;
330
331 default:
332 fprintf(stderr, "Unknown option '%c' - ignoring!\n",argv[i][1]);
333 break;
334 }
335 }
336 else
337 {
338 // no option -> filename
339 cInputFileList.push_back(argv[i]);
340 }
341 i++;
342 }
343
344 if (cInputFileList.empty())
345 {
346 fprintf(stderr, "No input files given!\n");
347 exit(0);
348 }
349
350 gSymbolsFileHandle =xfopen(ptr_symbols_filename,"w");
351 gErrorFileHandle =xfopen(ptr_error_filename,"w");
352 if (!strcmp(ptr_output_filename,"-"))
353 {
354 ptr_output_filename=NULL;
355 gOutputFileHandle = stdout;
356 }
357 else
358 {
359 gOutputFileHandle= xfopen(ptr_output_filename,"wb");
360 }
361 if (!gOutputFileHandle)
362 {
363 fprintf(stderr, "Couldn't open output file!\n");
364 exit(1);
365 }
366
367 if (bFlagVerbose) fprintf(stderr, "%s",copyright);
368
369 if (gErrorFileHandle) fprintf(gErrorFileHandle,"%s",copyright);
370 if (bFlagVerbose) logout(ctime(&tim1));
371
372 //
373 // Pass 1
374 //
375 TablePcSegment[eSEGMENT_ABS]= 0; /* abs addressing */
376 afile->StartSegment(fmode,SectionTextBase,SectionDataBase,SectionBssBase,SectionZeroBase,0,relmode);
377
378 if (relmode)
379 {
380 r_mode(RMODE_RELOC);
381 gCurrentSegment = eSEGMENT_TEXT;
382 }
383 else
384 {
385 r_mode(RMODE_ABS);
386 }
387
388 for (unsigned int i=0;i<cInputFileList.size();i++)
389 {
390 const std::string& cSourceFilename=cInputFileList[i];
391
392 sprintf(out,"xAss65: Pass 1: %s\n",cSourceFilename.c_str());
393 if (bFlagVerbose) logout(out);
394
395 er=PreprocessorFile_c::Open(cSourceFilename.c_str(),b_depth());
396 if (!er)
397 {
398 er=pass1();
399 gPreprocessor.Close();
400 }
401 else
402 {
403 sprintf(out, "Couldn't open source file '%s'!\n", cSourceFilename.c_str());
404 logout(out);
405 }
406 }
407
408 if ((er=b_depth()))
409 {
410 sprintf(out,"Still %d blocks open at end of file!\n",er);
411 logout(out);
412 }
413
414 if (SectionTextBase & (align-1))
415 {
416 sprintf(out,"Warning: text segment ($%04x) start address doesn't align to %d!\n",SectionTextBase,align);
417 logout(out);
418 }
419 if (SectionDataBase & (align-1))
420 {
421 sprintf(out,"Warning: data segment ($%04x) start address doesn't align to %d!\n",SectionDataBase,align);
422 logout(out);
423 }
424 if (SectionBssBase & (align-1))
425 {
426 sprintf(out,"Warning: bss segment ($%04x) start address doesn't align to %d!\n",SectionBssBase,align);
427 logout(out);
428 }
429 if (SectionZeroBase & (align-1))
430 {
431 sprintf(out,"Warning: zero segment ($%04x) start address doesn't align to %d!\n",SectionZeroBase,align);
432 logout(out);
433 }
434 if (gFlag_n65816>0)
435 fmode |= 0x8000;
436
437 switch (align)
438 {
439 case 1:
440 break;
441 case 2:
442 fmode |= 1;
443 break;
444 case 4:
445 fmode |= 2;
446 break;
447 case 256:
448 fmode |=3;
449 break;
450 }
451
452 if ((!er) && relmode)
453 {
454 afile->WriteRelocatableHeader(gOutputFileHandle, fmode,SectionTextLenght,SectionDataLenght,SectionBssLenght,SectionZeroLenght, 0);
455 }
456
457
458 //
459 // Pass 2
460 //
461 if (!er)
462 {
463 if (bFlagVerbose) logout("xAss65: Pass 2:\n");
464
465 afile->SegmentPass2();
466
467 if (!relmode)
468 {
469 r_mode(RMODE_ABS);
470 }
471 else
472 {
473 r_mode(RMODE_RELOC);
474 gCurrentSegment = eSEGMENT_TEXT;
475 }
476 er=afile->pass2();
477 }
478
479 if (gSymbolsFileHandle)
480 {
481 afile->m_cSymbolData.PrintSymbols(gSymbolsFileHandle);
482 }
483
484 tim2=time(NULL);
485 if (bFlagVerbose)
486 {
487 printstat();
488 }
489
490 if ((!er) && relmode) afile->SegmentEnd(gOutputFileHandle); // write reloc/label info
491
492 if (gErrorFileHandle) fclose(gErrorFileHandle);
493 if (gSymbolsFileHandle) fclose(gSymbolsFileHandle);
494 if (gOutputFileHandle) fclose(gOutputFileHandle);
495
496 gPreprocessor.Terminate();
497
498 if (ner || er)
499 {
500 fprintf(stderr, "Break after %d error%c\n",ner,ner?'s':0);
501 /*unlink();*/
502 if (ptr_output_filename)
503 {
504 DeleteFile(ptr_output_filename);
505 }
506 }
507
508 return ( (er || ner) ? 1 : 0 );
509 }
510
511 static void printstat(void)
512 {
513 logout("Statistics:\n");
514 sprintf(out," %8d of %8d label used\n",afile->m_cSymbolData.GetLabelCount(),gm_lab());
515 logout(out);
516 sprintf(out," %8ld of %8ld byte label-memory used\n",ga_labm(),gm_labm());
517 logout(out);
518 sprintf(out," %8d of %8d PP-defs used\n",gPreprocessor.ga_pp(),gPreprocessor.gm_pp());
519 logout(out);
520 sprintf(out," %8ld of %8ld byte PP-memory used\n",gPreprocessor.ga_ppm(),gPreprocessor.gm_ppm());
521 logout(out);
522 sprintf(out," %8ld of %8ld byte buffer memory used\n",afile->ga_p1(),afile->gm_p1());
523 logout(out);
524 sprintf(out," %8d blocks used\n",ga_blk());
525 logout(out);
526 sprintf(out," %8ld seconds used\n",(long)difftime(tim2,tim1));
527 logout(out);
528 }
529
530 #define fputw(a,fp) fputc((a)&255,fp);fputc((a>>8)&255,fp)
531
532
533 static int setfext(char *s, char *ext)
534 {
535 int j,i=(int)strlen(s);
536
537 if (i>MAXLINE-5)
538 {
539 return -1;
540 }
541
542 for (j=i-1;j>=0;j--)
543 {
544 if (s[j]==DIRCHAR)
545 {
546 strcpy(s+i,ext);
547 break;
548 }
549 if (s[j]=='.')
550 {
551 strcpy(s+j,ext);
552 break;
553 }
554 }
555 if (!j)
556 strcpy(s+i,ext);
557
558 return 0;
559 }
560
561
562 #ifndef abs
563 #define abs(a) ((a)>=0 ? a : -a)
564 #endif
565
566 int FileData::pass2()
567 {
568 int c,er,l,ll,i,al;
569 signed char *dataseg=NULL;
570 signed char *datap=NULL;
571
572 memode=0;
573 xmode=0;
574 if ((dataseg=(signed char*)malloc(SectionDataLenght)))
575 {
576 if (!dataseg)
577 {
578 fprintf(stderr, "Couldn't alloc dataseg memory...\n");
579 exit(1);
580 }
581 datap=dataseg;
582 }
583
584 PreprocessorFile_c datei;
585 gPreprocessor.m_CurrentFile=&datei;
586 m_cMnData.ResetReadPos();
587
588 while (ner<20 && m_cMnData.CanReadMore())
589 {
590 l=m_cMnData.ReadShort();
591 ll=l;
592
593 if (!l)
594 {
595 Tokens nType=(Tokens)m_cMnData.ReadByte();
596 if (nType==T_LINE)
597 {
598 datei.SetCurrentLine(m_cMnData.ReadUShort());
599 }
600 else
601 if (nType==T_FILE)
602 {
603 datei.SetCurrentLine(m_cMnData.ReadUShort());
604 datei.SetCurrentFileName(m_cMnData.ReadString());
605 }
606 else
607 {
608 printf("Invalid type: %u",nType);
609 }
610 }
611 else
612 {
613 signed char* ptr=m_cMnData.GetReadPointer();
614 er=t_p2(ptr,&ll,0,&al);
615
616 if (er==E_NOLINE)
617 {
618 }
619 else
620 if (er==E_OK)
621 {
622 if (gCurrentSegment<eSEGMENT_DATA)
623 {
624 const signed char* ptr=m_cMnData.GetReadPointer();
625 for(i=0;i<ll;i++)
626 {
627 putc(ptr[i],gOutputFileHandle);
628 }
629 }
630 else
631 if (gCurrentSegment==eSEGMENT_DATA && datap)
632 {
633 memcpy(datap,m_cMnData.GetReadPointer(),ll);
634 datap+=ll;
635 }
636 }
637 else
638 if (er==E_DSB)
639 {
640 const signed char* ptr=m_cMnData.GetReadPointer();
641 c=ptr[0];
642 if (gCurrentSegment<eSEGMENT_DATA)
643 {
644 for(i=0;i<ll;i++)
645 {
646 putc(c&255,gOutputFileHandle);
647 }
648 }
649 else
650 if (gCurrentSegment==eSEGMENT_DATA && datap)
651 {
652 memset(datap, c, ll);
653 datap+=ll;
654 }
655 }
656 else
657 {
658 errout(er);
659 }
660 m_cMnData.MoveReadPos(abs(l));
661 }
662 }
663 if (relmode)
664 {
665 if ((ll=fwrite(dataseg, 1,SectionDataLenght, gOutputFileHandle))<SectionDataLenght)
666 {
667 fprintf(stderr, "Problems writing %d bytes, return gives %d\n",SectionDataLenght,ll);
668 }
669 }
670
671 return ner;
672 }
673
674
675 static int pass1(void)
676 {
677 signed char out[MAXLINE];
678 int l,outlen;
679 ErrorCode er;
680
681 memode=0;
682 xmode=0;
683 SectionTextLenght=0;
684 ner=0;
685 while (!(er=getline(BufferLine)))
686 {
687 /*
688 if (!strcmp(BufferLine,"Lctk-conio70"))
689 {
690 printf("\r\nBreak here !!!\r\n");
691 }
692 */
693 er=t_p1((signed char*)BufferLine,out,&l,&outlen);
694
695 switch (gCurrentSegment)
696 {
697 case eSEGMENT_ABS:
698 case eSEGMENT_TEXT:
699 SectionTextLenght+= outlen;
700 break;
701 case eSEGMENT_DATA:
702 SectionDataLenght+= outlen;
703 break;
704 case eSEGMENT_BSS :
705 SectionBssLenght += outlen;
706 break;
707 case eSEGMENT_ZERO:
708 SectionZeroLenght+= outlen;
709 break;
710 }
711
712 if (l)
713 {
714 if (er)
715 {
716 if (er==E_OKDEF)
717 {
718 if (!(er=afile->WriteShort(l)))
719 {
720 er=afile->WriteSequence(out,l);
721 }
722 }
723 else
724 if (er==E_NOLINE)
725 {
726 er=E_OK;
727 }
728 }
729 else
730 {
731 if (!(er=afile->WriteShort(-l)))
732 {
733 er=afile->WriteSequence(out,l);
734 }
735 }
736 }
737 if (er)
738 {
739 lineout();
740 errout(er);
741 }
742 }
743
744 if (er!=E_EOF)
745 {
746 errout(er);
747 }
748
749 return ner;
750 }
751
752
753
754 #define ANZERR 31
755 #define ANZWARN 6
756
757 /*
758 static char *ertxt[] = { "Syntax","Label definiert",
759 "Label nicht definiert","Labeltabelle voll",
760 "Label erwartet","Speicher voll","Illegaler Opcode",
761 "Falsche Adressierungsart","Branch ausserhalb des Bereichs",
762 "Ueberlauf","Division durch Null","Pseudo-Opcode erwartet",
763 "Block-Stack-Ueberlauf","Datei nicht gefunden",
764 "End of File","Block-Struktur nicht abgeschlossen",
765 "NoBlk","NoKey","NoLine","OKDef","DSB","NewLine",
766 "NewFile","CMOS-Befehl","pp:Falsche Anzahl Parameter" };
767 */
768 static char *ertxt[] =
769 {
770 "Syntax",
771 "Label defined",
772 "Label not defined",
773 "Labeltab full",
774 "Label expected",
775 "no more memory",
776 "Illegal opcode",
777 "Wrong addressing mode",
778 "Branch out of range",
779 "Overflow",
780 "Division by zero",
781 "Pseudo-opcode expected",
782 "Block stack overflow",
783 "file not found",
784 "End of file",
785 "Too many block close",
786 "NoBlk",
787 "NoKey",
788 "NoLine",
789 "OKDef",
790 "DSB",
791 "NewLine",
792 "NewFile",
793 "CMOS instructions are not allowed (-C flag)",
794 "pp:Wrong parameter count",
795 "Illegal pointer arithmetic",
796 "Illegal segment",
797 "File header option too long",
798 "File Option not at file start (when ROM-able)",
799 "Illegal align value",
800 "65816 instructions are not allowed (-W flag)",
801 /* warnings start here */
802 "Cutting word relocation in byte value",
803 "Byte relocation in word value",
804 "Illegal pointer arithmetic",
805 "Address access to low or high byte pointer",
806 "High byte access to low byte pointer",
807 "Low byte access to high byte pointer"
808 };
809
810 static int gFlagMasmCompatibilityWeirdSwitch;
811 static int gFlagLineOutTest;
812
813
814
815
816 static char GetLineBuffer[MAXLINE];
817
818 static ErrorCode getline(char *s)
819 {
820 static int i,c;
821
822 int j=0;
823 int bFlagInQuotedString=0;
824 ErrorCode ec=E_OK;
825
826 if (!gFlagMasmCompatibilityWeirdSwitch)
827 {
828 do
829 {
830 ec=gPreprocessor.GetLine(GetLineBuffer);
831 i=0;
832 while (GetLineBuffer[i]==' ')
833 {
834 i++;
835 }
836
837 while (GetLineBuffer[i]!=0 && isdigit(GetLineBuffer[i]))
838 {
839 i++;
840 }
841
842
843 gFlagLineOutTest=1;
844
845 if (ec==E_NEWLINE)
846 {
847 unsigned int line=gPreprocessor.m_CurrentFile->GetCurrentLine();
848 //if (gErrorFileHandle) fprintf(gErrorFileHandle,"getline Line:%u\r\n",line);
849 afile->WriteShort(0);
850 afile->WriteByte(T_LINE);
851 afile->WriteUShort(line);
852 ec=E_OK;
853 }
854 else
855 if (ec==E_NEWFILE)
856 {
857 unsigned int line=gPreprocessor.m_CurrentFile->GetCurrentLine();
858 //if (gErrorFileHandle) fprintf(gErrorFileHandle,"getline File:%s (%u)\r\n",gPreprocessor.m_CurrentFile->GetCurrentFileName().c_str(),line);
859 afile->WriteShort(0);
860 afile->WriteByte(T_FILE);
861 afile->WriteUShort(line);
862 afile->WriteSequence((signed char*)gPreprocessor.m_CurrentFile->GetCurrentFileName().c_str(),gPreprocessor.m_CurrentFile->GetCurrentFileName().size()+1);
863 ec=E_OK;
864 }
865 }
866 while (!ec && GetLineBuffer[i]==0);
867 }
868
869 gFlagMasmCompatibilityWeirdSwitch=0;
870 if (!ec)
871 {
872 do
873 {
874 c=s[j]=GetLineBuffer[i++];
875
876 if (c=='\"')
877 bFlagInQuotedString^=1;
878
879 if (c==0)
880 break;
881
882 if ((!gFlagMasmCompatibilityMode) && (c==':') && !bFlagInQuotedString)
883 {
884 gFlagMasmCompatibilityWeirdSwitch=1;
885 break;
886 }
887 j++;
888 }
889 while (c!=0 && j<MAXLINE-1 && i<MAXLINE-1);
890
891 s[j]=0;
892 }
893 else
894 {
895 s[0]=0;
896 }
897
898 return ec;
899 }
900
901 void set_align(int a)
902 {
903 align = (a>align)?a:align;
904 }
905
906 static void lineout(void)
907 {
908 if (gFlagLineOutTest)
909 {
910 logout(gPreprocessor.m_CurrentFile->m_p_line_buffer);
911 logout("\n");
912 gFlagLineOutTest=0;
913 }
914 }
915
916 void errout(int er)
917 {
918 if (er<-ANZERR || er>-1)
919 {
920 if (er>=-(ANZERR+ANZWARN) && er < -ANZERR)
921 {
922 sprintf(out,"%s(%u): %04x: Warning - %s\n",gPreprocessor.m_CurrentFile->GetCurrentFileName().c_str(), gPreprocessor.m_CurrentFile->GetCurrentLine(), TablePcSegment[gCurrentSegment], ertxt[-er-1]);
923 }
924 else
925 {
926 /* sprintf(out,"%s:Zeile %d: %04x:Unbekannter Fehler Nr.: %d\n",*/
927 sprintf(out,"%s(%u): %04x: Unknown error # %d\n",gPreprocessor.m_CurrentFile->GetCurrentFileName().c_str(),gPreprocessor.m_CurrentFile->GetCurrentLine(),TablePcSegment[gCurrentSegment],er);
928 ner++;
929 }
930 }
931 else
932 {
933 if (er==ERR_UNDEFINED_LABEL)
934 sprintf(out,"%s(%u): %04x:Label '%s' not defined\n",gPreprocessor.m_CurrentFile->GetCurrentFileName().c_str(),gPreprocessor.m_CurrentFile->GetCurrentLine(),TablePcSegment[gCurrentSegment],gError_LabelNamePointer);
935 else
936 sprintf(out,"%s(%u): %04x:%s error\n",gPreprocessor.m_CurrentFile->GetCurrentFileName().c_str(),gPreprocessor.m_CurrentFile->GetCurrentLine(),TablePcSegment[gCurrentSegment],ertxt[-er-1]);
937
938 ner++;
939 }
940 logout(out);
941 }
942
943
944 void logout(char *s)
945 {
946 fprintf(stderr, "%s",s);
947 if (gErrorFileHandle) fprintf(gErrorFileHandle,"%s",s);
948 }
949

  ViewVC Help
Powered by ViewVC 1.1.26