Skip to content

Commit dd81f98

Browse files
committed
verbosity:asm
1 parent b2a2bf5 commit dd81f98

File tree

4 files changed

+30
-15
lines changed

4 files changed

+30
-15
lines changed

assembler/check_cor.sh

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
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

assembler/include/asm.h

+4-5
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
/* By: ciglesia <ciglesia@student.42.fr> +#+ +:+ +#+ */
77
/* +#+#+#+#+#+ +#+ */
88
/* 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 */
1010
/* */
1111
/* ************************************************************************** */
1212

@@ -19,9 +19,8 @@
1919
typedef struct s_instr
2020
{
2121
t_uchar opcode;
22-
int nargs;//
23-
t_arg_type args[3];//
24-
int acb;
22+
t_uchar nargs;
23+
t_uchar acb;
2524
int reg;
2625
char *dir;
2726
char *ind;
@@ -47,7 +46,7 @@ typedef struct s_file
4746
t_code *code_tab;
4847
} t_file;
4948

50-
int translate(t_file *file);
49+
int translate(t_file *file, int verbosity);
5150

5251
void file_init(t_file *file);
5352
t_code *new_label(void);

assembler/src/asm_main.c

+5-5
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
/* By: ciglesia <ciglesia@student.42.fr> +#+ +:+ +#+ */
77
/* +#+#+#+#+#+ +#+ */
88
/* 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 */
1010
/* */
1111
/* ************************************************************************** */
1212

@@ -16,17 +16,17 @@ int main(int ac, char **av)
1616
{
1717
t_file file;
1818

19-
if (ac != 2)
19+
if (ac != 2 && ac != 3)
2020
return (ft_puterr(ERROR""RED": assembler needs exactly one file!"E0M,
2121
EXIT_FAILURE));
22-
else
22+
else if (ac == 2 || (ac == 3 && ft_strcmp(av[1], "-v") == 0))
2323
{
2424
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)
2626
return (EXIT_FAILURE);
2727
if (verify_code(&file, NULL, 0, 0) == EXIT_FAILURE)
2828
return (EXIT_FAILURE);
29-
translate(&file);
29+
translate(&file, (ac == 3) ? ft_strcmp(av[1], "-v") == 0 : 0);
3030
//free table, lists, char*
3131
}
3232
return (EXIT_SUCCESS);

assembler/src/synthesis/translation.c

+8-5
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
/* By: ciglesia <ciglesia@student.42.fr> +#+ +:+ +#+ */
77
/* +#+#+#+#+#+ +#+ */
88
/* 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 */
1010
/* */
1111
/* ************************************************************************** */
1212

@@ -22,16 +22,19 @@ void print_instr(t_instruction *instr)
2222
}
2323
}
2424

25-
int translate(t_file *file)
25+
int translate(t_file *file, int verbosity)
2626
{
2727
t_code *table;
2828

2929
table = file->code_tab;
3030
while (table)
3131
{
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+
}
3538
table = table->next;
3639
}
3740
return (0);

0 commit comments

Comments
 (0)