Thanks Robert for your optimisations and bugspotting. I've incorporated them into our emulation code. Also I have completed the emulation of the multimedia instructions (not just what we needed to run Civilisation CTP) by adding emulation for: - "pixel error"(perr) - word/long pack to byte (pkwb,pklb) and unpack (unpkbw,unpkbl) I've attached the new patch to this email so that some of you guys can check it out. Is this sort of code useful to other people? Do you think it's worth adding this to the mainstream Linux distribution? Again, this is a patch for kernel v2.2.11 because Loki say that v2.2.12 has problems which break Civilisation CTP. Our purpose in writing this patch was to get CivCTP to run. It doesn't change many files though, so it will probably work with other kernel versions. - Luke & Daniel. On Mon, 18 Oct 1999, Robert Harley wrote: > BTW, here is a fast and short way of doing minuw(): > > ------------------------------------------------------------------------------ > #define CMPBGE(a, b, c) \ > asm("cmpbge %1, %2, %0" : "=r" (c) : "r" (a), "r" (b)) > #define ZAP(a, b, c) \ > asm("zap %1, %2, %0" : "=r" (c) : "r" (a), "r" (b)) > #define ZAPNOT(a, b, c) \ > asm("zapnot %1, %2, %0" : "=r" (c) : "r" (a), "r" (b)) > > static u64 minuw(u64 x, u64 y) { > u64 eq, ge1, ge2; > > CMPBGE(x, y, ge1); > CMPBGE(0, x ^ y, eq); > > ge2 = (ge1 & ~eq | eq & ge1<<1) & 0xAA; > ge2 |= ge2>>1; > > ZAP(x, ge2, x); > ZAPNOT(y, ge2, y); > > return x | y; > } /* end function minuw */ > ------------------------------------------------------------------------------ > > > The output from gcc 2.95 looks like: > > ------------------------------------------------------------------------------ > minuw: > cmpbge $16, $17, $1 > xor $16,$17,$3 > mov $31,$2 > cmpbge $2, $3, $2 > addq $1,$1,$4 > bic $1,$2,$1 > and $2,$4,$2 > bis $1,$2,$1 > and $1,170,$1 > srl $1,1,$2 > bis $1,$2,$1 > zapnot $17, $1, $17 > zap $16, $1, $16 > bis $16,$17,$0 > ret $31,($26),1 > .end minuw > ------------------------------------------------------------------------------ > > > This bit: > > mov $31,$2 > cmpbge $2, $3, $2 > > would be better as: > > cmpbge $31, $3, $2 > > > Bye, > Rob. -------------------------------------------------------------------------- Luke Deller luked@cse.unsw.edu.au _--_|\ Computer Engineering student / \ School of Computer Science and Engineering ? ? ? ? \_.--._* The University of New South Wales ~~^^~ v Sydney, NSW 2052 AUSTRALIA o o -------------------------------------------------------ooO--(_)--Ooo------