Subject: Re: string copy
To: Ian Dall <Ian.Dall@dsto.defence.gov.au>
From: Dave Rand <dlr@above.net>
List: port-pc532
Date: 06/06/1999 10:02:29
While it can be written that way, it's slower.

The code as written is pipelined.


[In the message entitled "string copy" on Jun  6, 23:47, Ian Dall writes:]
> While on this can anyone see why the following:
> 
> 5:	movd	0x01010101,r3		/* Magic number to use */
> 	movd	0x80808080,r4		/* Another magic number. */
> 	
> 	movd	0(r1),r5		/* Get 1st double word. */
> 	movd	r5,r0			/* Save for storage later. */
> 	subd	r3,r0			/* Gets borrow if byte = 0. */
> 	bicd	r5,r0			/* Clear original bits. */
> 	andd	r4,r0			/* See if borrow occurred. */
> 	cmpqd	0,r0
> 	bne	1f			/* See if this DWORD contained a 0. */
> 
> 	.align	2,0xa2
> 0:	movd	4(r1),r0		/* Get next 4 bytes to process */
> 	movd	r5,0(r2)		/* Save away prev four bytes. */
> 	addd	4,r1			/* addd is faster then addqd here */
> 	addd	4,r2
> 	movd	r0,r5			/* Save for storage if no zeros. */
> 	subd	r3,r0
> 	bicd	r5,r0
> 	andd	r4,r0
> 	cmpqd	0,r0
> 	beq	0b
> 
> can not be re-written as:
> 
> 5:	movd	0x01010101,r3		/* Magic number to use */
> 	movd	0x80808080,r4		/* Another magic number. */
> 	
> 0:	movd	0(r1),r5		/* Get 1st double word. */
> 	movd	r5,r0			/* Save for storage later. */
> 	subd	r3,r0			/* Gets borrow if byte = 0. */
> 	bicd	r5,r0			/* Clear original bits. */
> 	andd	r4,r0			/* See if borrow occurred. */
> 	cmpqd	0,r0
> 	bne	1f			/* See if this DWORD contained a 0. */
> 	movd	r5,0(r2)		/* Save away prev four bytes. */
> 	addd	4,r1			/* addd is faster then addqd here */
> 	addd	4,r2
> 	beq	0b
> 
> Ian
> 


-- 
Dave Rand
CTO, Above.net
NASDAQ: ABOV