1 /* asnoice.c - Extensions to CUG 292 assembler ASxxxx to produce NoICE debug files
3 Copyright (C) 1989-1995 Alan R. Baldwin
4 721 Berkeley St., Kent, Ohio 44240
6 This program is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by the
8 Free Software Foundation; either version 3, or (at your option) any
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>. */
20 * Extensions to CUG 292 assembler ASxxxx to produce NoICE debug files
22 * 3-Nov-1997 by John Hartman
31 /* Return basic file name without path or extension.
32 If spacesToUnderscores != 0 then spaces are converted to underscores */
34 char* BaseFileName( int fileNumber, int spacesToUnderscores )
36 static int prevFile = -1;
37 static char baseName[ PATH_MAX ];
41 if (fileNumber != prevFile)
43 prevFile = fileNumber;
47 /* issue a FILE command with full path and extension */
48 fprintf( ofp, ";!FILE %s\n", p1 );
50 /* Name starts after any colon or backslash (DOS) */
51 p2 = strrchr( p1, '\\' );
52 if (p2 == NULL) p2 = strrchr( p1, '/' );
53 if (p2 == NULL) p2 = strrchr( p1, ':' );
54 if (p2 == NULL) p2 = p1-1;
55 strcpy( baseName, p2+1 );
57 /* Name ends at any separator */
58 p2 = strrchr( baseName, FSEPX );
59 if (p2 != NULL) *p2 = 0;
60 /* SD comment this out since not a ANSI Function */
61 /* strupr( baseName ); */
63 if (spacesToUnderscores)
65 /* Convert spaces to underscores */
66 for (p1 = baseName; *p1; ++p1)
74 /* Define a symbol for current location: FILE.line# */
75 void DefineNoICE_Line()
80 /* symbol is FILE.nnn */
81 sprintf( name, "%s.%u", BaseFileName( cfile, 0 ), 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;
90 /* Define a symbol for current location: A$FILE$line# */
96 /* symbol is FILE.nnn */
97 sprintf( name, "A$%s$%u", BaseFileName( cfile, 1 ), srcline[ cfile ] );
99 pSym = lookup( name );
100 pSym->s_type = S_USER;
101 pSym->s_area = dot.s_area;
102 pSym->s_addr = laddr;
103 pSym->s_flag |= S_GBL;
108 /* Define a symbol for current location: FILE.line# */
109 void DefineNoICE_Line()
111 static int prevFile = -1;
112 static struct area *pPrevArea = NULL;
113 static char baseName[ PATH_MAX ];
118 /* Get outfilename without extension for use as base symbol name */
119 if (baseName[0] == 0)
123 while ((*p1 != 0) && (*p1 != FSEPX))
128 /* SD Commented this out since it is not a
130 /* strupr( baseName ); */
133 if ((cfile != prevFile) || (dot.s_area != pPrevArea))
136 pPrevArea = dot.s_area;
138 /* file or area change: issue FILE command with base @ */
139 fprintf( ofp, ";!FILE %s %s_%s\n", srcfn[ cfile ],
144 fprintf( ofp, ";!LINE %u. 0x%X\n", srcline[ cfile ], laddr );