@@ -16,10 +16,16 @@ enum OutputFormat
16
16
HexDump ,
17
17
Mif ,
18
18
IntelHex ,
19
+ DecComma ,
20
+ HexComma ,
21
+ DecC ,
22
+ HexC ,
23
+ LogiSim8 ,
24
+ LogiSim16 ,
19
25
}
20
26
21
27
22
- pub fn drive ( args : & Vec < String > , fileserver : & mut FileServer ) -> Result < ( ) , ( ) >
28
+ pub fn drive ( args : & Vec < String > , fileserver : & mut dyn FileServer ) -> Result < ( ) , ( ) >
23
29
{
24
30
let opts = make_opts ( ) ;
25
31
@@ -43,7 +49,7 @@ pub fn drive(args: &Vec<String>, fileserver: &mut FileServer) -> Result<(), ()>
43
49
}
44
50
45
51
46
- fn drive_inner ( report : RcReport , opts : & getopts:: Options , args : & Vec < String > , fileserver : & mut FileServer ) -> Result < ( ) , bool >
52
+ fn drive_inner ( report : RcReport , opts : & getopts:: Options , args : & Vec < String > , fileserver : & mut dyn FileServer ) -> Result < ( ) , bool >
47
53
{
48
54
let matches = parse_opts ( report. clone ( ) , opts, args) . map_err ( |_| true ) ?;
49
55
@@ -64,13 +70,20 @@ fn drive_inner(report: RcReport, opts: &getopts::Options, args: &Vec<String>, fi
64
70
65
71
let out_format = match matches. opt_str ( "f" ) . as_ref ( ) . map ( |s| s. as_ref ( ) )
66
72
{
67
- Some ( "binstr" ) => OutputFormat :: BinStr ,
68
- Some ( "bindump" ) => OutputFormat :: BinDump ,
69
- Some ( "hexstr" ) => OutputFormat :: HexStr ,
70
- Some ( "hexdump" ) => OutputFormat :: HexDump ,
71
- Some ( "binary" ) => OutputFormat :: Binary ,
72
- Some ( "mif" ) => OutputFormat :: Mif ,
73
- Some ( "intelhex" ) => OutputFormat :: IntelHex ,
73
+ Some ( "binstr" ) => OutputFormat :: BinStr ,
74
+ Some ( "bindump" ) => OutputFormat :: BinDump ,
75
+ Some ( "hexstr" ) => OutputFormat :: HexStr ,
76
+ Some ( "hexdump" ) => OutputFormat :: HexDump ,
77
+ Some ( "binary" ) => OutputFormat :: Binary ,
78
+ Some ( "mif" ) => OutputFormat :: Mif ,
79
+ Some ( "intelhex" ) => OutputFormat :: IntelHex ,
80
+ Some ( "deccomma" ) => OutputFormat :: DecComma ,
81
+ Some ( "hexcomma" ) => OutputFormat :: HexComma ,
82
+ Some ( "decc" ) => OutputFormat :: DecC ,
83
+ Some ( "hexc" ) => OutputFormat :: HexC ,
84
+ Some ( "c" ) => OutputFormat :: HexC ,
85
+ Some ( "logisim8" ) => OutputFormat :: LogiSim8 ,
86
+ Some ( "logisim16" ) => OutputFormat :: LogiSim16 ,
74
87
75
88
None => if out_stdout
76
89
{ OutputFormat :: HexDump }
@@ -110,13 +123,19 @@ fn drive_inner(report: RcReport, opts: &getopts::Options, args: &Vec<String>, fi
110
123
111
124
let output_data = match out_format
112
125
{
113
- OutputFormat :: Binary => assembled. generate_binary ( 0 , assembled. len ( ) ) ,
114
- OutputFormat :: BinStr => assembled. generate_binstr ( 0 , assembled. len ( ) ) . bytes ( ) . collect :: < Vec < u8 > > ( ) ,
115
- OutputFormat :: BinDump => assembled. generate_bindump ( 0 , assembled. len ( ) ) . bytes ( ) . collect :: < Vec < u8 > > ( ) ,
116
- OutputFormat :: HexStr => assembled. generate_hexstr ( 0 , assembled. len ( ) ) . bytes ( ) . collect :: < Vec < u8 > > ( ) ,
117
- OutputFormat :: HexDump => assembled. generate_hexdump ( 0 , assembled. len ( ) ) . bytes ( ) . collect :: < Vec < u8 > > ( ) ,
118
- OutputFormat :: Mif => assembled. generate_mif ( 0 , assembled. len ( ) ) . bytes ( ) . collect :: < Vec < u8 > > ( ) ,
119
- OutputFormat :: IntelHex => assembled. generate_intelhex ( 0 , assembled. len ( ) ) . bytes ( ) . collect :: < Vec < u8 > > ( ) ,
126
+ OutputFormat :: Binary => assembled. generate_binary ( 0 , assembled. len ( ) ) ,
127
+ OutputFormat :: BinStr => assembled. generate_binstr ( 0 , assembled. len ( ) ) . bytes ( ) . collect :: < Vec < u8 > > ( ) ,
128
+ OutputFormat :: BinDump => assembled. generate_bindump ( 0 , assembled. len ( ) ) . bytes ( ) . collect :: < Vec < u8 > > ( ) ,
129
+ OutputFormat :: HexStr => assembled. generate_hexstr ( 0 , assembled. len ( ) ) . bytes ( ) . collect :: < Vec < u8 > > ( ) ,
130
+ OutputFormat :: HexDump => assembled. generate_hexdump ( 0 , assembled. len ( ) ) . bytes ( ) . collect :: < Vec < u8 > > ( ) ,
131
+ OutputFormat :: Mif => assembled. generate_mif ( 0 , assembled. len ( ) ) . bytes ( ) . collect :: < Vec < u8 > > ( ) ,
132
+ OutputFormat :: IntelHex => assembled. generate_intelhex ( 0 , assembled. len ( ) ) . bytes ( ) . collect :: < Vec < u8 > > ( ) ,
133
+ OutputFormat :: DecComma => assembled. generate_comma ( 0 , assembled. len ( ) , 10 ) . bytes ( ) . collect :: < Vec < u8 > > ( ) ,
134
+ OutputFormat :: HexComma => assembled. generate_comma ( 0 , assembled. len ( ) , 16 ) . bytes ( ) . collect :: < Vec < u8 > > ( ) ,
135
+ OutputFormat :: DecC => assembled. generate_c_array ( 0 , assembled. len ( ) , 10 ) . bytes ( ) . collect :: < Vec < u8 > > ( ) ,
136
+ OutputFormat :: HexC => assembled. generate_c_array ( 0 , assembled. len ( ) , 16 ) . bytes ( ) . collect :: < Vec < u8 > > ( ) ,
137
+ OutputFormat :: LogiSim8 => assembled. generate_logisim ( 0 , assembled. len ( ) , 8 ) . bytes ( ) . collect :: < Vec < u8 > > ( ) ,
138
+ OutputFormat :: LogiSim16 => assembled. generate_logisim ( 0 , assembled. len ( ) , 16 ) . bytes ( ) . collect :: < Vec < u8 > > ( ) ,
120
139
} ;
121
140
122
141
if out_stdout
@@ -145,7 +164,7 @@ fn drive_inner(report: RcReport, opts: &getopts::Options, args: &Vec<String>, fi
145
164
fn make_opts ( ) -> getopts:: Options
146
165
{
147
166
let mut opts = getopts:: Options :: new ( ) ;
148
- opts. optopt ( "f" , "format" , "The format of the output file. Possible formats: binary, binstr, hexstr, bindump, hexdump, mif, intelhex" , "FORMAT" ) ;
167
+ opts. optopt ( "f" , "format" , "The format of the output file. Possible formats: binary, binstr, hexstr, bindump, hexdump, mif, intelhex, deccomma, hexcomma, decc, hexc, logisim8, logisim16 " , "FORMAT" ) ;
149
168
opts. optmulti ( "i" , "include" , "Specifies an additional file for processing before the given <asm-files>. [deprecated]" , "FILE" ) ;
150
169
opts. optopt ( "o" , "output" , "The name of the output file." , "FILE" ) ;
151
170
opts. optflag ( "p" , "print" , "Print output to stdout instead of writing to a file." ) ;
@@ -201,7 +220,7 @@ fn get_default_output_filename(report: RcReport, input_filename: &str) -> Result
201
220
}
202
221
203
222
204
- pub fn assemble ( report : RcReport , fileserver : & FileServer , filenames : & [ String ] , quiet : bool ) -> Result < BinaryOutput , ( ) >
223
+ pub fn assemble ( report : RcReport , fileserver : & dyn FileServer , filenames : & [ String ] , quiet : bool ) -> Result < BinaryOutput , ( ) >
205
224
{
206
225
if !quiet
207
226
{ print_header ( ) ; }
0 commit comments