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)
58 /* Define a symbol for current location: FILE.line# */
59 void DefineNoICE_Line()
64 /* symbol is FILE.nnn */
65 sprintf( name, "%s.%u", BaseFileName( cfile, 0 ), srcline[ cfile ] );
67 pSym = lookup( name );
68 pSym->s_type = S_USER;
69 pSym->s_area = dot.s_area;
71 pSym->s_flag |= S_GBL;
74 /* Define a symbol for current location: A$FILE$line# */
80 /* symbol is FILE.nnn */
81 sprintf( name, "A$%s$%u", BaseFileName( cfile, 1 ), srcline[ cfile ] );
83 pSym = lookup( name );
84 pSym->s_type = S_USER;
85 pSym->s_area = dot.s_area;
87 pSym->s_flag |= S_GBL;
92 /* Define a symbol for current location: FILE.line# */
93 void DefineNoICE_Line()
95 static int prevFile = -1;
96 static struct area *pPrevArea = NULL;
97 static char baseName[ PATH_MAX ];
102 /* Get outfilename without extension for use as base symbol name */
103 if (baseName[0] == 0)
107 while ((*p1 != 0) && (*p1 != FSEPX))
112 /* SD Commented this out since it is not a
114 /* strupr( baseName ); */
117 if ((cfile != prevFile) || (dot.s_area != pPrevArea))
120 pPrevArea = dot.s_area;
122 /* file or area change: issue FILE command with base @ */
123 fprintf( ofp, ";!FILE %s %s_%s\n", srcfn[ cfile ],
128 fprintf( ofp, ";!LINE %u. 0x%X\n", srcline[ cfile ], laddr );