summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKenneth R Westerback <krw@cvs.openbsd.org>2004-06-12 03:37:21 +0000
committerKenneth R Westerback <krw@cvs.openbsd.org>2004-06-12 03:37:21 +0000
commitecadf17a38af7fd195dd98bd641156d92da10ee3 (patch)
tree29586e2e1eeee72057d7d480bf13cfafceca4e30
parent7789950cc775d5782a4aedf8b87ea85479af868e (diff)
Sync with FreeBSD aicasm. No changes to the generated reg.h or seq.h
files used by ahc or ahd result from these changes, so they are not being sync'ed at this time. ok deraadt@
-rw-r--r--sys/dev/microcode/aic7xxx/aicasm.c39
-rw-r--r--sys/dev/microcode/aic7xxx/aicasm_macro_scan.l16
-rw-r--r--sys/dev/microcode/aic7xxx/aicasm_scan.l21
3 files changed, 49 insertions, 27 deletions
diff --git a/sys/dev/microcode/aic7xxx/aicasm.c b/sys/dev/microcode/aic7xxx/aicasm.c
index 91f4314c61f..c6c01857a4c 100644
--- a/sys/dev/microcode/aic7xxx/aicasm.c
+++ b/sys/dev/microcode/aic7xxx/aicasm.c
@@ -1,6 +1,4 @@
-/* $OpenBSD: aicasm.c,v 1.11 2003/12/24 23:27:55 krw Exp $ */
-/* $NetBSD: aicasm.c,v 1.5 2003/07/14 15:42:39 lukem Exp $ */
-
+/* $OpenBSD: aicasm.c,v 1.12 2004/06/12 03:37:19 krw Exp $ */
/*
* Aic7xxx SCSI host adapter firmware asssembler
*
@@ -40,12 +38,11 @@
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGES.
*
- * $FreeBSD: src/sys/dev/aic7xxx/aicasm/aicasm.c,v 1.35 2002/08/31 06:39:40 gibbs Exp $
+ * $Id: aicasm.c,v 1.12 2004/06/12 03:37:19 krw Exp $
+ *
+ * $FreeBSD: src/sys/dev/aic7xxx/aicasm/aicasm.c,v 1.37 2004/03/12 21:45:25 trhodes Exp $
*/
-
#include <sys/cdefs.h>
-/* __RCSID("$NetBSD: aicasm.c,v 1.5 2003/07/14 15:42:39 lukem Exp $"); */
-
#include <sys/types.h>
#include <sys/mman.h>
@@ -148,7 +145,7 @@ main(int argc, char *argv[])
yydebug = 0;
mmdebug = 0;
#endif
- while ((ch = getopt(argc, argv, "d:i:l:n:o:p:r:I:")) != -1) {
+ while ((ch = getopt(argc, argv, "d:i:l:n:o:p:r:I:X")) != -1) {
switch(ch) {
case 'd':
#if DEBUG
@@ -249,6 +246,9 @@ main(int argc, char *argv[])
}
break;
}
+ case 'X':
+ /* icc version of -nostdinc */
+ break;
case '?':
default:
usage();
@@ -314,7 +314,7 @@ usage()
{
(void)fprintf(stderr,
-"usage: %-16s [-nostdinc] [-I-] [-I directory] [-o output_file]\n"
+"usage: %-16s [-nostdinc|-X] [-I-] [-I directory] [-o output_file]\n"
" [-r register_output_file [-p register_diag_file -i includefile]]\n"
" [-l program_list_file]\n"
" input_file\n", appname);
@@ -614,10 +614,10 @@ output_listing(char *ifilename)
while (line < cur_instr->srcline) {
fgets(buf, sizeof(buf), ifile);
- fprintf(listfile, "\t\t%s", buf);
+ fprintf(listfile, " \t%s", buf);
line++;
}
- fprintf(listfile, "%03x %02x%02x%02x%02x", instrptr,
+ fprintf(listfile, "%04x %02x%02x%02x%02x", instrptr,
#if BYTE_ORDER == LITTLE_ENDIAN
cur_instr->format.bytes[0],
cur_instr->format.bytes[1],
@@ -629,14 +629,23 @@ output_listing(char *ifilename)
cur_instr->format.bytes[1],
cur_instr->format.bytes[0]);
#endif
- fgets(buf, sizeof(buf), ifile);
- fprintf(listfile, "\t%s", buf);
- line++;
+ /*
+ * Macro expansions can cause several instructions
+ * to be output for a single source line. Only
+ * advance the line once in these cases.
+ */
+ if (line == cur_instr->srcline) {
+ fgets(buf, sizeof(buf), ifile);
+ fprintf(listfile, "\t%s", buf);
+ line++;
+ } else {
+ fprintf(listfile, "\n");
+ }
instrptr++;
}
/* Dump the remainder of the file */
while(fgets(buf, sizeof(buf), ifile) != NULL)
- fprintf(listfile, "\t\t%s", buf);
+ fprintf(listfile, " %s", buf);
fclose(ifile);
}
diff --git a/sys/dev/microcode/aic7xxx/aicasm_macro_scan.l b/sys/dev/microcode/aic7xxx/aicasm_macro_scan.l
index a38ba14c0f4..7932e696051 100644
--- a/sys/dev/microcode/aic7xxx/aicasm_macro_scan.l
+++ b/sys/dev/microcode/aic7xxx/aicasm_macro_scan.l
@@ -1,7 +1,6 @@
%{
-/* $OpenBSD: aicasm_macro_scan.l,v 1.2 2003/12/24 23:27:55 krw Exp $ */
-/* $NetBSD: aicasm_macro_scan.l,v 1.1 2003/04/19 19:26:11 fvdl Exp $ */
-
+/*
+/* $OpenBSD: aicasm_macro_scan.l,v 1.3 2004/06/12 03:37:20 krw Exp $ */
/*
* Sub-Lexical Analyzer for macro invokation in
* the Aic7xxx SCSI Host adapter sequencer assembler.
@@ -41,7 +40,9 @@
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGES.
*
- * $FreeBSD: src/sys/dev/aic7xxx/aicasm/aicasm_macro_scan.l,v 1.4 2002/09/27 03:23:02 gibbs Exp $
+ * $Id: aicasm_macro_scan.l,v 1.3 2004/06/12 03:37:20 krw Exp $
+ *
+ * $FreeBSD: src/sys/dev/aic7xxx/aicasm/aicasm_macro_scan.l,v 1.5 2003/12/16 23:54:07 gibbs Exp $
*/
#include <sys/types.h>
@@ -79,6 +80,7 @@ MCARG [^(), \t]+
\n {
++yylineno;
}
+\r ;
<ARGLIST>{SPACE} ;
<ARGLIST>\( {
parren_count++;
@@ -111,7 +113,7 @@ MCARG [^(), \t]+
<ARGLIST>{MCARG} {
char *yptr;
- yptr = yytext;
+ yptr = mmtext;
while (*yptr)
*string_buf_ptr++ = *yptr++;
}
@@ -132,7 +134,7 @@ MCARG [^(), \t]+
}
{WORD}[(] {
/* May be a symbol or a macro invocation. */
- mmlval.sym = symtable_get(yytext);
+ mmlval.sym = symtable_get(mmtext);
if (mmlval.sym->type != MACRO) {
stop("Expecting Macro Name",
EX_DATAERR);
@@ -144,7 +146,7 @@ MCARG [^(), \t]+
}
. {
snprintf(buf, sizeof(buf), "Invalid character "
- "'%c'", yytext[0]);
+ "'%c'", mmtext[0]);
stop(buf, EX_DATAERR);
}
%%
diff --git a/sys/dev/microcode/aic7xxx/aicasm_scan.l b/sys/dev/microcode/aic7xxx/aicasm_scan.l
index 0b84aceda95..b682cfda1a3 100644
--- a/sys/dev/microcode/aic7xxx/aicasm_scan.l
+++ b/sys/dev/microcode/aic7xxx/aicasm_scan.l
@@ -1,6 +1,5 @@
%{
-/* $OpenBSD: aicasm_scan.l,v 1.7 2003/12/24 23:27:55 krw Exp $ */
-/* $NetBSD: aicasm_scan.l,v 1.3 2003/04/19 19:26:11 fvdl Exp $ */
+/* $OpenBSD: aicasm_scan.l,v 1.8 2004/06/12 03:37:20 krw Exp $ */
/*
* Lexical Analyzer for the Aic7xxx SCSI Host adapter sequencer assembler.
*
@@ -40,7 +39,9 @@
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGES.
*
- * $FreeBSD: src/sys/dev/aic7xxx/aicasm/aicasm_scan.l,v 1.21 2002/09/27 03:23:02 gibbs Exp $
+ * $Id: aicasm_scan.l,v 1.8 2004/06/12 03:37:20 krw Exp $
+ *
+ * $FreeBSD: src/sys/dev/aic7xxx/aicasm/aicasm_scan.l,v 1.22 2003/12/16 23:54:07 gibbs Exp $
*/
#include <sys/types.h>
@@ -87,6 +88,7 @@ MBODY ((\\[^\n])*[^\n\\]*)+
%%
\n { ++yylineno; }
+\r ;
"/*" { BEGIN COMMENT; /* Enter comment eating state */ }
<COMMENT>"/*" { fprintf(stderr, "Warning! Comment within comment."); }
<COMMENT>\n { ++yylineno; }
@@ -114,6 +116,7 @@ if[ \t]*\( {
}
}
<CEXPR>\n { ++yylineno; }
+<CEXPR>\r ;
<CEXPR>[^()\n]+ {
char *yptr;
@@ -359,6 +362,7 @@ else { return T_ELSE; }
/* Eat escaped newlines. */
++yylineno;
}
+<MACROBODY>\r ;
<MACROBODY>\n {
/* Macros end on the first unescaped newline. */
BEGIN INITIAL;
@@ -369,10 +373,17 @@ else { return T_ELSE; }
}
<MACROBODY>{MBODY} {
char *yptr;
+ char c;
yptr = yytext;
- while (*yptr)
- *string_buf_ptr++ = *yptr++;
+ while (c = *yptr++) {
+ /*
+ * Strip carriage returns.
+ */
+ if (c == '\r')
+ continue;
+ *string_buf_ptr++ = c;
+ }
}
{WORD}\( {
char *yptr;