Path: utzoo!utgpu!utstat!jarvis.csri.toronto.edu!mailrus!wasatch!cs.utexas.edu!tut.cis.ohio-state.edu!bloom-beacon!bu-cs!purdue!decwrl!sun!pitstop!sundc!seismo!uunet!mcvax!prlb2!kulcs!bimandre From: bimandre@kulcs.uucp (Andre Marien) Newsgroups: comp.arch Subject: Re: Endian reversing MOVEs Message-ID: <1586@kulcs.kulcs.uucp> Date: 8 Feb 89 11:14:21 GMT References: <759@atanasoff.cs.iastate.edu,MXvZBhy00W428s8WI0@andrew.cmu.edu> Reply-To: bimandre@kulcs.UUCP () Organization: B.I.M., Belgium Lines: 46 > John Hascall writes: > > ; > > ; Move and Reverse Endian-ness Longword > > ; > > .macro MREL src,dst > > PUSHL src ; stack source operand > > MOVB 0(SP),-(SP) ; re-stack HI byte > > MOVB 2(SP),-(SP) ; re-stack HI-MID byte > > MOVB 4(SP),-(SP) ; re-stack LO-MID byte > > MOVB 6(SP),-(SP) ; re-stack LO byte > > MOVL (SP)+,dst ; pop it into destination operand > > TSTL (SP)+ ; clear stack, set cond code > > .endm > That's 11 memory references for something which has nothing to do with memory. > It only takes 6 instructions (0 memory references) on the RT. This can be done on the VAX too : */ int g,cg; conv() { asm(" movl _g,r0"); asm(" rotl $8,r0,r1"); asm(" rotl $24,r0,r2"); asm(" bicl2 $0xff00ff00,r1"); asm(" bicl2 $0xff00ff,r2"); asm(" addl3 r1,r2,_cg"); } main() { while(1) { scanf("%d",&g); conv(); printf("src = %x dst = %x\n",g,cg); } } /* Andre' Marien B.I.M. Belgium bimandre@cs.kuleuven.ac.be sun!sunuk!sunbim!kulcs!bimandre */