Example #1
0
void process_line(char *line) {
	int len = strlen(line);
	if(line[0] == '#') {
		process_macro(line);
	} else {
		process_instruction(line);
	}
}
void radeonNqssaDce(GLcontext *ctx, struct gl_program *p, struct radeon_nqssadce_descr* descr)
{
	struct nqssadce_state s;

	_mesa_bzero(&s, sizeof(s));
	s.Ctx = ctx;
	s.Program = p;
	s.Descr = descr;
	s.Descr->Init(&s);
	s.IP = p->NumInstructions;

	while(s.IP > 0) {
		s.IP--;
		process_instruction(&s);
	}
}
void multiprogram(FILE *ptr_file, queue *q_ready, queue *q_process)
{
	process *curr_proc = NULL;		/* the current process removed from the front of the ready queue */
	char **token_arr = NULL;		/* array of tokens used to store the current instruction */
	char buffer[256];			/* buffer used to store the string read from the input file */
	queue *q_wait = init_queue();

	while (!(empty_queue(q_ready))) {	/* continue executing processes until no processes remain in the ready state */
		curr_proc = (process *) dequeue(q_ready);

		fsetpos(ptr_file, &(curr_proc->process_fpos));	/* update the file read position curr_proc's next instruction */
		fgets(buffer, 256, ptr_file);

		token_arr = tokenize_str(buffer);
		int continue_processing = TRUE;
		int ret_val = -999;
		while (continue_processing) {
			ret_val = process_instruction(curr_proc, q_ready, q_process, q_wait, token_arr);
			free_token(token_arr);

			if (ret_val == 0) {		/* alloc/dealloc was successful continue processing at next instruction */
				fgetpos(ptr_file, &(curr_proc->process_fpos));
				fgets(buffer, 256, ptr_file);

				token_arr = tokenize_str(buffer);
				continue_processing = TRUE;
			} else if (ret_val == 1) { 	/* a "SL #" instruction was encountered continue processing later */
				fgetpos(ptr_file, &(curr_proc->process_fpos)); /* update the processes fpos */
				continue_processing = FALSE;
			} else if (ret_val == -1) {	/* alloc/dealloc failed continue processing later at same instruction */
				continue_processing = FALSE;
			}
		}
	}
	free_queue(q_wait);

	return;
}
Example #4
0
/*                                                           
 * Procedure : cycle                                          
 * Purpose   : Execute a cycle                              
 */
void cycle() {                                                

  process_instruction();
  CURRENT_STATE = NEXT_STATE;
  INSTRUCTION_COUNT++;
}
Example #5
0
/**
* Given the first token to an input line, will attempt to parse it and
* process the related instruction.
*
* @param tok 		The first token on the input line, this is expected to be
* 					a clean (non-whitespace) token.
* @param program 	Contains all current program information gathered so far,
* 					primarily used for error reporting.
*/
void process_token(char *tok, struct program *program){

	// check for comments
	if(check_comment(tok, program)){
		process_comment(program);
		return;
	}

	// process constant definitions
	else if(check_const_def(tok, program)){
		process_const_def(tok, program);
		return;
	}

	// Function definitions
	else if(check_func_def(tok, program)){
		process_func_def(tok, program);
		return;
	}
	
	// check if we have a label
	else if(check_label_def(tok, program)){
		process_label_def(tok, program);
		return;
	}

	// the first token should contain our instruction
	else if(!strcmp(tok, "HALT")){
		process_instruction(program, HALT, HALT_F , 0);
	}
	else if(!strcmp(tok, "NOT")){
		process_instruction(program, NOT, NOT_F, 0);
	}
	else if(!strcmp(tok, "SHL")){
		process_instruction(program, SHL, SHL_F, 0);
	}
	else if(!strcmp(tok, "SHR")){
		process_instruction(program, SHR, SHR_F, 0);
	}
	else if(!strcmp(tok, "OR")){
		process_instruction(program, OR, OR_F, 0);
	}
	else if(!strcmp(tok, "AND")){
		process_instruction(program, AND, AND_F, 0);
	}
	else if(!strcmp(tok, "ADD")){
		process_instruction(program, ADD, ADD_F, 0);
	}
	else if(!strcmp(tok, "SW")){
		process_instruction(program, SW, SW_F, 0);
	}
	else if(!strcmp(tok, "SI")){
		process_instruction(program, SI, SI_F, 0);
	}
	else if(!strcmp(tok, "LW")){
		process_instruction(program, LW, LW_F, 0);
	}
	else if(!strcmp(tok, "LI")){
		process_instruction(program, LI, LI_F, 0);
	}
	else if(!strcmp(tok, "BEZ")){
		process_instruction(program, BEZ, BEZ_F, 0);
	}
	else if(!strcmp(tok, "ROT")){
		process_instruction(program, ROT, ROT_F, 0);
	}
	else if(!strcmp(tok, "ROT1")){
		process_instruction(program, ROT1, ROT1_F, 0);
	}
	else if(!strcmp(tok, "JMP")){
		process_instruction(program, JMP, JMP_F, 0);
	}
	else if(!strcmp(tok, "NOP")){
		process_instruction(program, NOP, NOP_F, 0);
	}
	else if(!strcmp(tok, "LFSJ")){
		process_instruction(program, LFSJ, LFSJ_F, 0);
	}
	else if(!strcmp(tok, "STJ")){
		process_instruction(program, STJ, STJ_F, 0);
	}

	// looks like a bad opcode
	else{
		#ifdef DEBUG
			fprintf(stderr, "BAD CODE '%s'\n", tok);
		#endif
		print_unexpected_ident(tok, program);
	}
}