예제 #1
0
void generate_OR (quad* quad) {

	quad->taddress = nextinstructionlabel();
	struct instruction t;

	t.opcode = jeq_v;
	make_operand(quad->arg1, &t.arg1);
	make_booloperand(&t.arg2, '1');
	t.result.type = label_a;
	t.result.val  = nextinstructionlabel()+4;
	emit_instruction(&t);

	make_operand(quad->arg2, &t.arg1);
	t.result.val  = nextinstructionlabel()+3;
	emit_instruction(&t);

	t.opcode = assign_v;
	make_booloperand(&t.arg1, '0');
	reset_operand(&t.arg2);
	make_operand(quad->result, &t.result);
	emit_instruction(&t);

	t.opcode = jump_v;
	reset_operand (&t.arg1);
	reset_operand(&t.arg2);
	t.result.type = label_a;
	t.result.val  = nextinstructionlabel()+2;
	emit_instruction(&t);

	t.opcode = assign_v;
	make_booloperand(&t.arg1, '1');
	reset_operand(&t.arg2);
	make_operand(quad->result, &t.result);
	emit_instruction(&t);
}
예제 #2
0
파일: target.c 프로젝트: vagianan/CSD-HY340
void generate_NOT( quad *quad ){
	quad->taddress = nextInstructionLabel();
	instruction *t = InitInstruction();
	instruction *t1 = InitInstruction();
	instruction *t2 = InitInstruction();
	instruction *t3 = InitInstruction();

	t->opcode = jeq_v;
	make_operand( quad->arg1, t->arg1 );
	make_booloperand( t->arg2, 1 );
	t->result->type = label_a;
	t->result->val = nextInstructionLabel()+3;
	emitVmarg( t );

	t1->opcode = assign_v;
	make_booloperand( t1->arg1, 1 );
	//reset_operand( t->arg2 );
	make_operand( quad->result, t1->result );
	emitVmarg( t1 );

	t2->opcode = jump_v;
	//reset_operand( t1->arg1 );
	//reset_operand( t1->arg2 );
	t2->result->type = label_a;
	t2->result->val = nextInstructionLabel()+2;
	emitVmarg( t2 );

	t2->opcode = assign_v;
	make_booloperand( t2->arg1, 0 );
	reset_operand( t2->arg2 );
	make_operand( quad->result, t2->result );
	emitVmarg( t2 );
}
예제 #3
0
void generate_AND(quad *q)
{
	q->taddress = nextinstructionlabel();
	instruction t1, t2, t3, t4, t5;
	
	init_instruction(&t1);
	init_instruction(&t2);
	init_instruction(&t3);
	init_instruction(&t4);
	init_instruction(&t5);
	
	t1.srcLine = q->line;
	t1.opcode = ieq_v;
	make_operand(q->arg1, t1.arg1);
	make_booloperand(t1.arg2, 0);
	t1.result->type = label_a;
	t1.result->val = nextinstructionlabel()+4;
	emit_icode(t1);
	
	t2.opcode = ieq_v;
	t2.srcLine = q->line;
	make_booloperand(t2.arg2, 0);
	make_operand(q->arg2, t2.arg1);
	t2.result->type = label_a;
	t2.result->val = nextinstructionlabel()+3;
	emit_icode(t2);
	
	t3.opcode = assign_v;
	t3.srcLine = q->line;
	
	make_booloperand(t3.arg1, 1);

	make_operand(q->result, t3.result);
	emit_icode(t3);
	
	t4.opcode = jump_v;
	t4.srcLine = q->line;
	

	t4.result->type = label_a;
	t4.result->val = nextinstructionlabel()+2;
	emit_icode(t4);
	
	t5.opcode = assign_v;
	t5.srcLine = q->line;
	make_booloperand(t5.arg1, 0);
	
	make_operand(q->result, t5.result);
	emit_icode(t5);
	
}
예제 #4
0
파일: target.c 프로젝트: vagianan/CSD-HY340
void generate_AND( quad *quad ){

	
	instruction *t = InitInstruction();
	instruction *t1 = InitInstruction();
	instruction *t2 = InitInstruction();
	instruction *t3 = InitInstruction();
	instruction *t4 = InitInstruction();

	quad->taddress = nextInstructionLabel();
	t->opcode = jeq_v;
	make_operand( quad->arg1, t->arg1 );
	make_booloperand( t->arg2, 0);
	t->result->type = label_a;
	t->result->val = nextInstructionLabel()+4;
	emitVmarg( t );

	t1->opcode = jeq_v;
   	make_operand(quad->arg2,t1->arg1);
   	make_booloperand(t1->arg2,0);
   	t1->result = make_vmarg();
   	(t1->result)->val = nextInstructionLabel()+3;
   	(t1->result)->type = label_a;
   	emitVmarg( t1 );	
	
	
	t2->opcode = assign_v;
   	make_booloperand(t2->arg1,1);
   	t2->arg2 = reset_operand();
   	make_operand(quad->result,t2->result);
   	t2->srcLine = quad->line;
   	emitVmarg(t2);	
	
	t3->opcode = jump_v;
  	t3->arg1 = reset_operand();
   	t3->arg2 = reset_operand();
   	t3->result = make_vmarg();
   	(t3->result)->type = label_a;
   	(t3->result)->val = nextInstructionLabel()+2;
   	t3->srcLine = quad->line;
   	emitVmarg(t3);

	t4->opcode = assign_v;
	   make_booloperand(t4->arg1,0);
	   t4->arg2 = reset_operand();
	   make_operand(quad->result,t4->result);
	   t4->srcLine = quad->line;
	   emitVmarg(t4);
	   return;
	
}