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

Subversion Repositories i650

[/] [i650/] [trunk/] [utils/] [ibm650_soap2/] [ibm650_soap2/] [main.cpp] - Blame information for rev 29

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 29 eightycc
//////////////////////////////////////////////////////////////////////////////////
2
// IBM 650 Reconstruction in Verilog (i650)
3
// 
4
// This file is part of the IBM 650 Reconstruction in Verilog (i650) project
5
// http:////www.opencores.org/project,i650
6
//
7
// Description: An implementation of SOAP 2 for the IBM 650.
8
// 
9
// Additional Comments: .
10
//
11
// Copyright (c) 2015 Robert Abeles
12
//
13
// This source file is free software; you can redistribute it
14
// and/or modify it under the terms of the GNU Lesser General
15
// Public License as published by the Free Software Foundation;
16
// either version 2.1 of the License, or (at your option) any
17
// later version.
18
//
19
// This source is distributed in the hope that it will be
20
// useful, but WITHOUT ANY WARRANTY; without even the implied
21
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
22
// PURPOSE.  See the GNU Lesser General Public License for more
23
// details.
24
//
25
// You should have received a copy of the GNU Lesser General
26
// Public License along with this source; if not, download it
27
// from http://www.opencores.org/lgpl.shtml
28
//////////////////////////////////////////////////////////////////////////////////
29
 
30
#include <getopt.h>
31
#include "soap2.h"
32
 
33
static void usage() {
34
    cout << "Usage: ibm650_soap2 [options] source_file" << endl;
35
    cout << "Options" << endl;
36
    cout << "  -h, --help           Print this message and exit." << endl;
37
    cout << "  -c, --punch_comments Punches comment cards." << endl;
38
    cout << "  -e, --punch_800x     Punches 800x cards." << endl;
39
    cout << "  -p, --punch_pseudo   Punches pseudo op cards." << endl;
40
    cout << "  -k, --check_object   Compare generated object to 7-word deck." << endl;
41
}
42
 
43
int main(int argc, char *argv[]) {
44
    ifstream file_source, file_check;
45
    ofstream file_list, file_obj;
46
    string name_prefix, name_source, name_list, name_obj, name_check;
47
    int ch;
48
    int help_flag = 0;
49
    int err_flag  = 0;
50
    int flags     = 0;
51
 
52
    static struct option longopts[] = {
53
        { "help",           no_argument,    NULL,   'h' },
54
        { "punch_comments", no_argument,    NULL,   'c' },
55
        { "punch_800x",     no_argument,    NULL,   'e' },
56
        { "punch_pseudo",   no_argument,    NULL,   'p' },
57
        { "check_object",   no_argument,    NULL,   'k' },
58
        { NULL,             0,              NULL,     0 }
59
    };
60
 
61
    while ((ch = ::getopt_long(argc, argv, "hcepk", longopts, NULL)) != -1)
62
        switch (ch) {
63
            case 'h':
64
                help_flag = 1;
65
                break;
66
            case 'c':
67
                flags |= asmflag_c;
68
                break;
69
            case 'e':
70
                flags |= asmflag_e;
71
                break;
72
            case 'p':
73
                flags |= asmflag_p;
74
                break;
75
            case 'k':
76
                flags |= asmflag_k;
77
                break;
78
            default:
79
                err_flag = 1;
80
                break;
81
    }
82
    argc -= optind;
83
    argv += optind;
84
    if (argc == 0) {
85
        cout << "Error: Missing source_file." << endl;
86
        err_flag = 1;
87
    }
88
    if (argc > 1) {
89
        cout << "Error: Extraneous argument(s)." << endl;
90
        err_flag = 1;
91
    }
92
    if (err_flag) {
93
        usage();
94
        return -1;
95
    }
96
    if (help_flag) {
97
        usage();
98
        return 0;
99
    }
100
    name_source = argv[0];
101
    if (string::npos != name_source.rfind('.')) {
102
        name_prefix = name_source.substr(0, name_source.rfind('.'));
103
        if (name_prefix.empty()) {
104
            cout << "Error: Malformed source_file." << endl;
105
            err_flag = 1;
106
        }
107
    } else {
108
        name_prefix = name_source;
109
    }
110
    name_list = name_prefix + ".listing";
111
    name_obj  = name_prefix + ".obj";
112
    name_check= name_prefix + ".7wd";
113
    file_source.open(name_source);
114
    if (!file_source) {
115
        cout << "Error: Unable to open source_file." << endl;
116
        err_flag = 1;
117
    }
118
    file_list.open(name_list);
119
    if (!file_list) {
120
        cout << "Error: Unable to open list_file." << endl;
121
        err_flag = 1;
122
    }
123
    file_obj.open(name_obj);
124
    if (!file_obj) {
125
        cout << "Error: Unable to open obj_file." << endl;
126
        err_flag = 1;
127
    }
128
    if (flags & asmflag_k) {
129
        file_check.open(name_check);
130
        if (!file_check) {
131
            cout << "Error: Unable to open check_file." << endl;
132
            err_flag = 1;
133
        }
134
    }
135
    if (err_flag) {
136
        usage();
137
        return -1;
138
    }
139
    soap2 myasm(cs_bcd48+cs_bcd48_f, flags, file_source, file_obj, file_list, file_check);
140
    return 0;
141
}

powered by: WebSVN 2.1.0

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