コード例 #1
0
ファイル: arrow.c プロジェクト: bsisic42/42
void		move_cur(char *cr)
{
	t_elem	*e;

	e = g_all.c.cur;
	if (cr[0] == 27 && cr[1] == 91 && cr[2] == 66)
	{
		if (g_all.c.cur == g_all.c.end)
			g_all.c.cur = g_all.c.start;
		else
			g_all.c.cur = e->next;
	}
	if (cr[0] == 27 && cr[1] == 91 && cr[2] == 65)
	{
		if (g_all.c.cur == g_all.c.start)
			g_all.c.cur = g_all.c.end;
		else
			g_all.c.cur = e->prev;
	}
	if (cr[0] == 32 && cr[1] == 0 && cr[2] == 0)
	{
		if (e->sel)
			e->sel = 0;
		else
			e->sel = 1;
	}
	move_l(cr);
}
コード例 #2
0
ファイル: codewar.c プロジェクト: KalSkirata/CodeWar
void move_general(struct cpu *c,uint16_t mot1,uint16_t mot2){
	/*c->registres[0]=0;
	c->N=0;		
	c->C=0;
	c->Z=1;*/
	int typeMove=0;
	int typeSource=0;
	int typeDes=0;
	uint16_t ins=mot1 & 0x600;	
	int T1 = (mot1 >> 6) & 7;
	int T2 = (mot1 >> 3) & 7;	
	uint16_t valeurR=mot1 & 0x7;

	ins=ins>>9;
	
	if(ins==1){
		printf(" C'est un move.l \n" );
		typeMove=1;
	}else if(ins==2){
		printf(" C'est un move.h \n");
		typeMove=2;
	}else {
		printf(" C'est un move tout simple \n" );
		typeMove=3;
	}
	
	switch(T1){
		case 0: printf("Registre \n"); typeSource=0; break;
		case 1: printf("Registre pré-decrementé \n"); typeSource=1;break;
		case 2: printf("Adressage indirect \n");typeSource=2; break;
		case 3: printf("Registre post-incremente \n"); typeSource=3;break;
		case 4: printf("valeur immediate \n"); typeSource=4;break;
		case 5: printf("Adresse \n"); typeSource=5; break;
	}
	switch(T2){
		case 0: printf("Registre \n"); typeDes=0; break;
		case 1: printf("Registre pré-decrementé \n"); typeDes=1; break;
		case 2: printf("Adressage indirect \n"); typeDes=2;break;
		case 3: printf("Registre post-incremente \n");typeDes=3; break;
		case 4: printf("valeur immediate \n"); typeDes=4;break;
		case 5: printf("Adresse \n"); typeDes=5;break;
	}

	if((typeSource==4 || typeSource==5) && (typeDes==0 || typeDes==1 || typeDes==2 ||typeDes==3  )){
		printf(" Registre de destination %d \n", valeurR);

		/* Move.l */
		if(typeMove==1){
		move_l(c,typeSource,typeDes,valeurR,mot1,mot2);

		c->C=0;
		c->N=((mot1&0xFF)&0x40)>>6;
		if(mot1==0){
			c->Z=1;
		}else{
			c->Z=0;
		}

		/* Move.h */
		}else if(typeMove==2){