21Fermer23
GodzilLe 14/05/2009 à 17:48
Lionel Debroux (./19) :
Tu es sûr de vouloir utiliser (signed) char ?

Non c'est une erreur

Edit: c'est pas mieux
Result
Signed                        		|		Unsigned
					|
hash:                        		|		hash:
	subq.w #4,%sp            	|			move.l %a2,-(%sp)
	move.l %a2,-(%sp)        	|			move.b 1(%a2),%d0
	move.b 1(%a2),%d0        	|			lsl.w #2,%d0
	ext.w %d0                	|			and.w #1020,%d0
	add.w %d0,%d0            	|			clr.w %d1
	add.w %d0,%d0            	|			move.b (%a2),%d1
	move.b (%a2),%d1         	|			lsl.w #4,%d1
	ext.w %d1                	|			clr.w %d2
	lsl.w #4,%d1             	|			move.b 2(%a2),%d2
	move.b 2(%a2),%d2        	|			add.w %d2,%d1
	ext.w %d2                	|			add.w %d1,%d0
	add.w %d2,%d1            	|			and.l #4095,%d0
	add.w %d1,%d0            	|			moveq #4,%d1
	and.w #4095,%d0          	|			add.l %sp,%d1
	add.w %d0,%d0            	|			add.l %d1,%d0
	add.w %d0,%d0            	|			lsl.l #2,%d0
	move.w %d0,6(%sp)        	|			move.l (%sp)+,%a2
	move.w 6(%sp),%d0        	|			rts
	and.l #65535,%d0         	|		
	moveq #8,%d1             	|		
	add.l %sp,%d1            	|		
	add.l %d1,%d0            	|		
	move.l (%sp)+,%a2        	|		
	addq.w #4,%sp            	|		
	rts 


le code en C :
code
unsigned long hash(unsigned char *buffer asm("%a2"), unsigned long p asm("%a6"))
{
	return p + (((buffer[0]<<4) + (buffer[1]<<2) + buffer[2]) & 0xFFF) << 2; 
}