⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 longcopy2.cpp

📁 一个3D的保龄球的源代码
💻 CPP
字号:
#ifndef AEE_SIMULATOR

/* copy a piece of memory from s to d. 
 * Using ARM's multiply load instruct to accelerate copying speed.
 * To test this function, see optim/test.c
 */
void LongCopy2(unsigned char *d,unsigned char *s,int w,int h, int d2, int s2)
{
	__asm{
		//at the begin of this function, r0 = d, r1 = s, r2 =w, r3 = h
beg1:
		mov  r2, w					//r2 was changed during the loop
		movs r12, r2, lsr #5		// r12 = r2 div  32( number of 8 word)
		beq copywords				// less than 8 words to move
		
octcopy:
		ldmia r1!, {r4-r11}			//load 8 long from s (r1)
		stmia r0!, {r4-r11}			//store 8 long to d (r0)
		subs  r12, r12, #1			//r12 -- ( number of 8 long)
		bne octcopy

copywords:
		ands r2, r2, #31				//number of chars to copy
		beq nextline					//no more chars to copy

		movs r12, r2, lsr #2			//number of word to copy. r12 = r2 >>2
		beq nextline
wordcopy:
		ldr	r4,[r1], #4
		str	r4,[r0], #4
		subs r12, r12, #1
		bne wordcopy

		ands r2, r2, #3					//number of char to copy. 
		beq nextline
charcopy:		
#if defined BREW11
		ldrb	r4,[r1], #1				//load a byte from r1 to r4, r1++
		strb	r4,[r0], #1				//store r4 to *r0, r0++ (r0 is char* now)
		subs r2, r2, #1
#else
		ldrh	r4,[r1], #2				//load a byte from r1 to r4, r1++
		strh	r4,[r0], #2				//store r4 to *r0, r0++ (r0 is char* now)
		subs r2, r2, #2
#endif
		bne charcopy

nextline:
		adds r0, r0, d2;		// d += d2, s+=s2 for each line
		adds r1, r1, s2;

		subs r3, r3,1		
		bgt beg1				//while(--h>0)
	}
}
#else
void LongCopy1(unsigned short *d, unsigned short *s,int w,int h, int d2, int s2)
{
	register int i,j;
	
	register unsigned long * ld;
	register unsigned long * ls;
//	register unsigned short* sd;
//	register unsigned short* ss;
	int w2;
//	DBGPRINTF("%d, %d", (int)d%4, (int)s%4);
	for(j=h; j>0; j--){//each line
		w2 = w;
		if((int)s % 4)
		{
			*d ++ = *s ++;
			w2 = w - 1;
		}

		ld = (unsigned long*)d;
		ls = (unsigned long*)s;

		for(i=w2;i>=8;i-=8){
			*ld++= *ls++;  //[2003/09/22]for ensure use asm code in mobile, mark screen in simulator
			*ld++= *ls++;
			*ld++= *ls++;
			*ld++= *ls++;
			//*((long*)d++)= *((long*)s++);
			//*((long*)d++)= *((long*)s++);
			//*((long*)d++)= *((long*)s++);

		}
		for(; i>=2; i-=2){
			*ld++=*ls++;
		}	
		
		d = (unsigned short*)ld;
		s = (unsigned short*)ls;
		//for(; i>=4; i-=4){
		//	*sd++=*ss++;
		//	*sd++=*ss++;
		//	//*((short*)d++)= *((short*)s++);
		//	//*((short*)d++)= *((short*)s++);
		//}
		if( i>0){
			*d++=*s++;
			//*((short*)d++)= *((short*)s++);
		}
		//d = sd;
		//s = ss;
		d += d2;
		s += s2;
	}
}
#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -