17Fermer19
GodzilLe 14/05/2009 à 17:43
Bon et sérieusement gcc -O3 genere ça :

#include <tigcclib.h>

// Main Function

long hash(char *buffer asm("%a2"), long p asm("%a6"))
{
	volatile unsigned short hash;
	hash = (((buffer[0]<<4) + (buffer[1]<<2) + buffer[2]) & 0xFFF) << 2;
	return p + hash; 
}

void _main(void)
{
	
}


>>>

hash:
	subq.w #4,%sp
	move.l %a2,-(%sp)
	move.b 1(%a2),%d0
	ext.w %d0
	add.w %d0,%d0
	add.w %d0,%d0
	move.b (%a2),%d1
	ext.w %d1
	lsl.w #4,%d1
	move.b 2(%a2),%d2
	ext.w %d2
	add.w %d2,%d1
	add.w %d1,%d0
	and.w #4095,%d0
	add.w %d0,%d0
	add.w %d0,%d0
	move.w %d0,6(%sp)
	move.w 6(%sp),%d0
	and.l #65535,%d0
	moveq #8,%d1
	add.l %sp,%d1
	add.l %d1,%d0
	move.l (%sp)+,%a2
	addq.w #4,%sp
	rts