4 * Extensions to CUG 292 assembler ASxxxx to produce NoICE debug files
6 * 3-Nov-1997 by John Hartman
15 /* Return basic file name without path or extension.
16 If spacesToUnderscores != 0 then spaces are converted to underscores */
18 char* BaseFileName( int fileNumber, int spacesToUnderscores )
20 static int prevFile = -1;
21 static char baseName[ PATH_MAX ];
25 if (fileNumber != prevFile)
27 prevFile = fileNumber;
31 /* issue a FILE command with full path and extension */
32 fprintf( ofp, ";!FILE %s\n", p1 );
34 /* Name starts after any colon or backslash (DOS) */
35 p2 = strrchr( p1, '\\' );
36 if (p2 == NULL) p2 = strrchr( p1, '/' );
37 if (p2 == NULL) p2 = strrchr( p1, ':' );
38 if (p2 == NULL) p2 = p1-1;
39 strcpy( baseName, p2+1 );
41 /* Name ends at any separator */
42 p2 = strrchr( baseName, FSEPX );
43 if (p2 != NULL) *p2 = 0;
44 /* SD comment this out since not a ANSI Function */
45 /* strupr( baseName ); */
47 if (spacesToUnderscores)
49 /* Convert spaces to underscores */
50 for (p1 = baseName; *p1; ++p1)
59 /* Define a symbol for current location: FILE.line# */
60 void DefineNoICE_Line()
65 /* symbol is FILE.nnn */
66 sprintf( name, "%s.%u", BaseFileName( cfile, 0 ), srcline[ cfile ] );
68 pSym = lookup( name );
69 pSym->s_type = S_USER;
70 pSym->s_area = dot.s_area;
72 pSym->s_flag |= S_GBL;
75 /* Define a symbol for current location: A$FILE$line# */
81 /* symbol is FILE.nnn */
82 sprintf( name, "A$%s$%u", BaseFileName( cfile, 1 ), srcline[ cfile ] );
84 pSym = lookup( name );
85 pSym->s_type = S_USER;
86 pSym->s_area = dot.s_area;
88 pSym->s_flag |= S_GBL;
93 /* Define a symbol for current location: FILE.line# */
94 void DefineNoICE_Line()
96 static int prevFile = -1;
97 static struct area *pPrevArea = NULL;
98 static char baseName[ PATH_MAX ];
103 /* Get outfilename without extension for use as base symbol name */
104 if (baseName[0] == 0)
108 while ((*p1 != 0) && (*p1 != FSEPX))
113 /* SD Commented this out since it is not a
115 /* strupr( baseName ); */
118 if ((cfile != prevFile) || (dot.s_area != pPrevArea))
121 pPrevArea = dot.s_area;
123 /* file or area change: issue FILE command with base @ */
124 fprintf( ofp, ";!FILE %s %s_%s\n", srcfn[ cfile ],
129 fprintf( ofp, ";!LINE %u. 0x%X\n", srcline[ cfile ], laddr );