File tree 4 files changed +30
-15
lines changed
4 files changed +30
-15
lines changed Original file line number Diff line number Diff line change
1
+ # **************************************************************************** #
2
+ # #
3
+ # ::: :::::::: #
4
+ # check_cor.sh :+: :+: :+: #
5
+ # +:+ +:+ +:+ #
6
+ # By: ciglesia <ciglesia@student.42.fr> +#+ +:+ +#+ #
7
+ # +#+#+#+#+#+ +#+ #
8
+ # Created: 2020/09/16 12:01:33 by ciglesia #+# #+# #
9
+ # Updated: 2020/09/16 12:01:42 by ciglesia ### ########.fr #
10
+ # #
11
+ # **************************************************************************** #
12
+
13
+ hexdump -vC $1
Original file line number Diff line number Diff line change 6
6
/* By: ciglesia <ciglesia@student.42.fr> +#+ +:+ +#+ */
7
7
/* +#+#+#+#+#+ +#+ */
8
8
/* Created: 2020/09/05 22:18:22 by ciglesia #+# #+# */
9
- /* Updated: 2020/09/15 21:14:35 by ciglesia ### ########.fr */
9
+ /* Updated: 2020/09/16 12:27:10 by ciglesia ### ########.fr */
10
10
/* */
11
11
/* ************************************************************************** */
12
12
19
19
typedef struct s_instr
20
20
{
21
21
t_uchar opcode ;
22
- int nargs ;//
23
- t_arg_type args [3 ];//
24
- int acb ;
22
+ t_uchar nargs ;
23
+ t_uchar acb ;
25
24
int reg ;
26
25
char * dir ;
27
26
char * ind ;
@@ -47,7 +46,7 @@ typedef struct s_file
47
46
t_code * code_tab ;
48
47
} t_file ;
49
48
50
- int translate (t_file * file );
49
+ int translate (t_file * file , int verbosity );
51
50
52
51
void file_init (t_file * file );
53
52
t_code * new_label (void );
Original file line number Diff line number Diff line change 6
6
/* By: ciglesia <ciglesia@student.42.fr> +#+ +:+ +#+ */
7
7
/* +#+#+#+#+#+ +#+ */
8
8
/* Created: 2020/09/05 22:21:40 by ciglesia #+# #+# */
9
- /* Updated: 2020/09/15 19:45:14 by ciglesia ### ########.fr */
9
+ /* Updated: 2020/09/16 12:29:15 by ciglesia ### ########.fr */
10
10
/* */
11
11
/* ************************************************************************** */
12
12
@@ -16,17 +16,17 @@ int main(int ac, char **av)
16
16
{
17
17
t_file file ;
18
18
19
- if (ac != 2 )
19
+ if (ac != 2 && ac != 3 )
20
20
return (ft_puterr (ERROR "" RED ": assembler needs exactly one file!" E0M ,
21
21
EXIT_FAILURE ));
22
- else
22
+ else if ( ac == 2 || ( ac == 3 && ft_strcmp ( av [ 1 ], "-v" ) == 0 ))
23
23
{
24
24
file_init (& file );
25
- if (valid_input (av [1 ], & file ) == EXIT_FAILURE )
25
+ if (valid_input (( ac == 2 ) ? av [1 ] : av [ 2 ], & file ) == EXIT_FAILURE )
26
26
return (EXIT_FAILURE );
27
27
if (verify_code (& file , NULL , 0 , 0 ) == EXIT_FAILURE )
28
28
return (EXIT_FAILURE );
29
- translate (& file );
29
+ translate (& file , ( ac == 3 ) ? ft_strcmp ( av [ 1 ], "-v" ) == 0 : 0 );
30
30
//free table, lists, char*
31
31
}
32
32
return (EXIT_SUCCESS );
Original file line number Diff line number Diff line change 6
6
/* By: ciglesia <ciglesia@student.42.fr> +#+ +:+ +#+ */
7
7
/* +#+#+#+#+#+ +#+ */
8
8
/* Created: 2020/09/15 19:12:29 by ciglesia #+# #+# */
9
- /* Updated: 2020/09/15 21:24:56 by ciglesia ### ########.fr */
9
+ /* Updated: 2020/09/16 12:29:44 by ciglesia ### ########.fr */
10
10
/* */
11
11
/* ************************************************************************** */
12
12
@@ -22,16 +22,19 @@ void print_instr(t_instruction *instr)
22
22
}
23
23
}
24
24
25
- int translate (t_file * file )
25
+ int translate (t_file * file , int verbosity )
26
26
{
27
27
t_code * table ;
28
28
29
29
table = file -> code_tab ;
30
30
while (table )
31
31
{
32
- ft_printf (BLUE "%s:\n" E0M , table -> label );
33
- print_instr (table -> instr );
34
- //print intrinsic instructions (table->instr)
32
+ if (verbosity )
33
+ {
34
+ ft_printf (BLUE "%s:\n" E0M , table -> label );
35
+ print_instr (table -> instr );
36
+ //print intrinsic instructions (table->instr)
37
+ }
35
38
table = table -> next ;
36
39
}
37
40
return (0 );
You can’t perform that action at this time.
0 commit comments