当前位置: 代码迷 >> 汇编语言 >> 求教高手,数组转换汇编解决思路
  详细解决方案

求教高手,数组转换汇编解决思路

热度:9994   发布时间:2013-02-26 00:00:00.0
求教高手,数组转换汇编
C代码如下:
static __inline void Convert_8u16s(const BYTE* pSrc, int width, int height, short *pDst)
{

int i,j;

for(i = 0; i< height; i++)
for(j = 0; j<width; j++)
{
*(pDst + i*width +j) = (short)(*(pSrc + i*width +j) );
}

}

求教,怎么用汇编高效率实现?(平台是DSP)
还有下面这个语句:
cr = (r >> 1) - ((g >> 2) + (g >> 3) + (g >> 5) + (g >> 7)) - ((b >> 4) + (b >> 6)) + 128;




------解决方案--------------------------------------------------------
前面的三个参数,在调用 Conert_8u16s之前,要先将这几个参数压入.const BYTE* pSrc, int width, int height, short *pDst ... 顺序是相反的. 
Convert_8u16s:
pop ebp
mov ebp, esp
#因为你的函数定义了两个变量.
add esp, 8
mov [ebp+4], # i变量
mov [ebp+8], # j变量

栈的情况如下:
pSrc
width
height
pEst
返回的地址
旧的ebp
下面就是你需要定义的局部变量了.




------解决方案--------------------------------------------------------
探讨
前面的三个参数,在调用 Conert_8u16s之前,要先将这几个参数压入.const BYTE* pSrc, int width, int height, short *pDst ... 顺序是相反的.
Convert_8u16s:
pop ebp
mov ebp, esp
#因为你的函数定义了两个变量.
add esp, 8
mov [ebp+4], # ……
  相关解决方案