src/processing.c
/*
**	This function will translate one line of instruction to the bytecode, and
**	write it to the temp file. It does so by splitting the line into separate
**	words, looking up and writing the instruction opcode, if necessary, it
**	generates and writes the param byte, and then one by one writes the
**	parameters using write_nbr() based on it's type and whether or not the
**	instruction uses indices.
*/
This function will translate one line of instruction to the bytecode, and
write it to the temp file. It does so by splitting the line into separate
words, looking up and writing the instruction opcode, if necessary, it
generates and writes the param byte, and then one by one writes the
parameters using write_nbr() based on it's type and whether or not the
instruction uses indices.
This function will translate one line of instruction to the bytecode and write it to the temp file . It does so by splitting the line into separate words looking up and writing the instruction opcode if necessary it generates and writes the param byte and then one by one writes the parameters using write_nbr () based on it ' s type and whether or not the instruction uses indices .
static void	process_line(char *line)
{
	char	**words;
	char	instruction;
	char	param_byte;
	int		i;
	int		nbr;
	words = ft_strsplit(line, ' ');
	instruction = instruction_opcode(words[0]);
	param_byte = generate_param_byte(line);
	write_out(&instruction, sizeof(char));
	if (instruction_param_byte(words[0]) == 1)
		write_out(&param_byte, sizeof(char));
	i = 0;
	while (words[++i] && i <= 3)
	{
		nbr = read_nbr(words[i]);
		if (words[i][0] == 'r')
			write_nbr(nbr, 1);
		else if (words[i][0] == DIRECT_CHAR && !instruction_index(words[0]))
			write_nbr(nbr, 4);
		else
			write_nbr(nbr, 2);
	}
	ft_strarrdel(&words);
}
static void process_line ( char * line ) { char * * words ; char instruction ; char param_byte ; int i ; int nbr ; words = ft_strsplit ( line , ' ' ) ; instruction = instruction_opcode ( words [ 0 ] ) ; param_byte = generate_param_byte ( line ) ; write_out ( & instruction , sizeof ( char ) ) ; if ( instruction_param_byte ( words [ 0 ] ) == 1 ) write_out ( & param_byte , sizeof ( char ) ) ; i = 0 ; while ( words [ ++ i ] && i <= 3 ) { nbr = read_nbr ( words [ i ] ) ; if ( words [ i ] [ 0 ] == ' ' ) write_nbr ( nbr , 1 ) ; else if ( words [ i ] [ 0 ] == DIRECT_CHAR && ! instruction_index ( words [ 0 ] ) ) write_nbr ( nbr , 4 ) ; else write_nbr ( nbr , 2 ) ; } ft_strarrdel ( & words ) ; }
This function will translate one line of instruction to the bytecode, and
write it to the temp file.
This function will translate one line of instruction to the bytecode and write it to the temp file .