OpenCores
URL https://opencores.org/ocsvn/c16/c16/trunk

Subversion Repositories c16

[/] [c16/] [trunk/] [asm/] [assembler.cc] - Blame information for rev 30

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 jsauermann
 
2
#include <stdio.h>
3
#include <string.h>
4
#include <assert.h>
5
 
6
extern FILE * yyin;
7
extern FILE * out;
8
extern FILE * sym;
9
extern FILE * ihx;
10
extern int yyparse();
11
 
12
static void usage(const char * prog);
13
 
14
FILE * out  = 0;
15
FILE * sym  = 0;
16
FILE * list = 0;
17
FILE * ihx  = 0;
18
char listname[256];
19
char outname [256];
20
char ihxname [256];
21
char symname [256];
22
 
23
//-----------------------------------------------------------------------------
24
int main(int argc, char * argv[])
25
{
26
   if (argc < 2)   { usage(argv[0]);   return 1; }
27
 
28 30 jsauermann
char * asmname = argv[1];
29 2 jsauermann
   yyin = fopen(asmname,  "r");
30
   if (yyin == 0)
31
      {
32
        fprintf(stderr, "Can't open %s\n", asmname);
33
        return 1;
34
      }
35
 
36
char * asmend = strrchr(asmname, '.');
37
   if (asmend)   *asmend = 0;
38
 
39
   if (argc == 3)   sprintf(outname, "%s", argv[2]);
40
   else             sprintf(outname,  "%s.bin", asmname);
41
 
42
   if (argc == 4)   sprintf(listname, "%s", argv[3]);
43
   else             sprintf(listname, "%s.lst", asmname);
44
 
45
   if (argc == 5)   sprintf(symname, "%s", argv[4]);
46
   else             sprintf(symname, "%s.sym", asmname);
47
 
48
   if (argc == 6)   sprintf(ihxname, "%s", argv[5]);
49
   else             sprintf(ihxname, "%s.ihx", asmname);
50
 
51
   fprintf(stderr, "Asmname  = %s\n", asmname);
52
   fprintf(stderr, "Listname = %s\n", listname);
53
   fprintf(stderr, "Outname  = %s\n", outname);
54
   fprintf(stderr, "Symname  = %s\n", symname);
55
   fprintf(stderr, "Ihxname  = %s\n", ihxname);
56
 
57
   list = fopen(listname, "w");   assert(list);
58
   out  = fopen(outname, "wb");   assert(out);
59
   sym  = fopen(symname, "w");    assert(sym);
60
   ihx  = fopen(ihxname, "w");    assert(ihx);
61
 
62
   if (yyparse())
63
      {
64
        fprintf(stderr, "PARSE ERROR\n");
65
      }
66
   else
67
      {
68
        fprintf(stderr, "PARSED OK\n");
69
      }
70
 
71
   fclose(yyin);
72
   fclose(list);
73
   fclose(out);
74
   fclose(sym);
75
   yyin = 0;
76
   return 0;
77
}
78
//-----------------------------------------------------------------------------
79
void usage(const char * prog)
80
{
81
   fprintf(stderr, "Usage: %s [-l] file.asm [file.asm]\r\n", prog);
82
}
83
//-----------------------------------------------------------------------------

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.