请问一下,写线性汇编需要注意什么吗, 我的线性汇编代码 处理一张图像没问题,但是处理视频就不对了,问题可能在哪?
算法是八连通查找算法,C语言是对的。 算法如下
C语言的:
//除第一行之外的标记,此时会出现等价的关系
for ( j=1; j < nHeight; j++ )
{
m_lpImgBitsMove=pImgData+j*nWidth; //pImgData图像指针
m_lpnMarkMove=g_nMarkTable+j*nWidth;
//对每行的第一个点做处理,总体就是对图象的最左列做处理
//只需要检视上,右上两个点
if ( *m_lpImgBitsMove==bObjectGray )
{
//<上>位置被标记过
if ( *(m_lpnMarkMove - nWidth)!=0 )
{
JudgeEqual(2,1,m_lpnMarkMove,listEqualMark);
}
//<上>没有标记,此时一定不会存在等价关系
else if ( *(m_lpnMarkMove-nWidth+1)!=0 )
{//<右上>被标记
JudgeEqual(3,1,m_lpnMarkMove,listEqualMark);
}
else
{//<上>、<右上>都没有标记,则开始新的标记
*m_lpnMarkMove = nMarkValue++;
}
}
m_lpnMarkMove++;
m_lpImgBitsMove++;
//对每行的中间点做标记处理,此时存在<左>、<左上>、<上>、<右上> 4种情况
for ( i=1; i< nWidth-1; i++ )
{
//需要标记
if ( (*m_lpImgBitsMove)==bObjectGray )
{
if ( *(m_lpnMarkMove-1) != 0 )
{//<左>被标记过
JudgeEqual(0,1,m_lpnMarkMove,listEqualMark);
}
else if ( *(m_lpnMarkMove-nWidth-1)!=0 )
{//<左上>被标记过
JudgeEqual(1,1,m_lpnMarkMove,listEqualMark);
}
else if ( *(m_lpnMarkMove-nWidth)!=0 )
{//<上>被标记过
JudgeEqual(2,1,m_lpnMarkMove,listEqualMark);
}
else if (*(m_lpnMarkMove-nWidth+1)!=0)
{//<右上>被标记过
JudgeEqual(3,1,m_lpnMarkMove,listEqualMark);
}
else
{//<左>、<左上>、<上>未标记过,此时不存在等价关系
*m_lpnMarkMove=nMarkValue++;
}
}
m_lpnMarkMove++;
m_lpImgBitsMove++;
} //中间点处理的结束
//对每行的最后一个点做处理,总体就是对图象的最右列做处理
//此时存在<左>、<左上>、<上> 3种情况需要标记
if ( (*m_lpImgBitsMove)==bObjectGray )
{
if ( *(m_lpnMarkMove-1)!=0 )
{//<左>被标记过
JudgeEqual(0,0,m_lpnMarkMove,listEqualMark);
}
else if ( *(m_lpnMarkMove-nWidth-1)!=0 )
{//<左上>被标记过
JudgeEqual(1,0,m_lpnMarkMove,listEqualMark);
}
else if ( *(m_lpnMarkMove-nWidth)!=0 )
{//<上>标记
JudgeEqual(2,0,m_lpnMarkMove,listEqualMark);
}
else
{//<左>、<左上>、<上>未标记过,则开始新的标记值
*m_lpnMarkMove=nMarkValue++;
}
} //对每行的最后一个点做处理,总体就是对图象的最左列做处理
}//"除第一行之外的标记"的结束
线性汇编代码:
.global _FillArea8
.global _JudgeEqual ;函数
.global _g_nMarkTable
.global _g_listEqualMark
.text
_FillArea8: .cproc pImgData,nMarkValue, nWidth, nHeigh, bObjectGray
.reg i, j, temp1,temp2, param1,param2,param3,param0, width, height ,lpImgBitsMove,lpnMarkMove
.reg srcdata, listEqualMark, g_lpMarkTable, conf1,conf2
.reg upMoveData, lupMoveData,leftMoveData,rupMoveData
.reg confup,conflup,confleft,confrup
mvk 1, j
; mvk 1, nMarkValue
mvkl 0, param0
mvkh 0, param0
mvkl 1, param1
mvkh 1, param1
mvkl 2, param2
mvkh 2, param2
mvkl 3, param3
mvkh 3, param3
mvkl _g_listEqualMark,listEqualMark ; 等价关系数组
mvkh _g_listEqualMark,listEqualMark ;
mvkl _g_nMarkTable,g_lpMarkTable ;图像标记表
mvkh _g_nMarkTable,g_lpMarkTable ;
sub nWidth, 2, width
mv nHeigh, height
b loopHeight
branch1: .call _JudgeEqual(param2,param1,lpnMarkMove,listEqualMark)
b branchFback
branch2: .call _JudgeEqual(param3,param1,lpnMarkMove,listEqualMark)
b branchFback
branch3: .call _JudgeEqual(param0,param1,lpnMarkMove,listEqualMark)
b branchMback
branch4: .call _JudgeEqual(param1,param1,lpnMarkMove,listEqualMark)
b branchMback
branch5: .call _JudgeEqual(param2,param1,lpnMarkMove,listEqualMark)
b branchMback
branch6: .call _JudgeEqual(param3,param1,lpnMarkMove,listEqualMark)
b branchMback
branch7: .call _JudgeEqual(param0,param0,lpnMarkMove,listEqualMark)
b branchLback
branch8: .call _JudgeEqual(param1,param0,lpnMarkMove,listEqualMark)
b branchLback
branch9: .call _JudgeEqual(param2,param0,lpnMarkMove,listEqualMark)
b branchLback
theFirstCol:
mpy nWidth, 4, temp1
sub lpnMarkMove, temp1, temp2 ;nWidth
ldw *temp2, upMoveData
cmpeq upMoveData, 0, confup ;上
cmpeq confup, 0, confup
sub nWidth, 1, temp1
mpy temp1, 4, temp1
sub lpnMarkMove, temp1, temp2
ldw *temp2, rupMoveData
cmpeq rupMoveData, 0, confrup ;右上
cmpeq confrup, 0, confrup
[confup] b branch1
[confrup]b branch2
stw nMarkValue, *lpnMarkMove
add nMarkValue, 1, nMarkValue
branchFback:
b backFirstCol
theMedianCol:
sub lpnMarkMove, 4, temp2
ldw *temp2, leftMoveData
cmpeq leftMoveData, 0, confleft ;左
cmpeq confleft, 0, confleft
add nWidth, 1, temp1
mpy temp1, 4, temp1
sub lpnMarkMove, temp1, temp2
ldw *temp2, lupMoveData
cmpeq lupMoveData, 0, conflup ;左上
cmpeq conflup, 0, conflup
mpy nWidth, 4, temp1
sub lpnMarkMove, temp1, temp2
ldw *temp2, upMoveData
cmpeq upMoveData, 0, confup ;上
cmpeq confup, 0, confup
sub nWidth, 1, temp1
mpy temp1, 4, temp1
sub lpnMarkMove, temp1, temp2
ldw *temp2, rupMoveData
cmpeq rupMoveData, 0, confrup ;右上
cmpeq confrup, 0, confrup
[confleft] b branch3
[conflup] b branch4
[confup] b branch5
[confrup] b branch6
stw nMarkValue, *lpnMarkMove
add nMarkValue, 1, nMarkValue
branchMback:
b backMedianCol
theLastCol:
sub lpnMarkMove, 4, temp2
ldw *temp2, leftMoveData
cmpeq leftMoveData, 0, confleft ;左
cmpeq confleft, 0, confleft
add nWidth, 1, temp1
mpy temp1, 4, temp1
sub lpnMarkMove, temp1, temp2
ldw *temp2, lupMoveData
cmpeq lupMoveData, 0, conflup ;左上
cmpeq conflup, 0, conflup
mpy nWidth, 4, temp1
sub lpnMarkMove, temp1, temp2
ldw *temp2, upMoveData
cmpeq upMoveData, 0, confup ;上
cmpeq confup, 0, confup
[confleft] b branch7
[conflup] b branch8
[confup] b branch9
stw nMarkValue, *lpnMarkMove
add nMarkValue, 1, nMarkValue
branchLback:
b backLastCol
loopHeight:
mpy j, nWidth, temp1 ;j*nWidth
add temp1, pImgData, lpImgBitsMove ;pImgData+j*nWidth
mpy temp1 , 4, temp1
add g_lpMarkTable, temp1, lpnMarkMove;lpnMarkMove+j*nWidth
ldbu *lpImgBitsMove, srcdata
sub nWidth, 2, width ;初始化内层循环的次数
;对每行的第一个点做处理,总体就是对图象的最左列做处理
;只需要检视上,右上两个点
cmpeq bObjectGray, srcdata, conf1 ;*m_lpImgBitsMove==bObjectGray
[conf1] b theFirstCol
backFirstCol:add lpnMarkMove, 4, lpnMarkMove
add lpImgBitsMove, 1, lpImgBitsMove
;Median
loopWidth:
ldbu *lpImgBitsMove, srcdata
cmpeq bObjectGray, srcdata, conf2
[conf2] b theMedianCol
backMedianCol:add lpnMarkMove, 4, lpnMarkMove
add lpImgBitsMove, 1, lpImgBitsMove
[width] sub width,1, width
[width] b loopWidth
;Last
ldbu *lpImgBitsMove, srcdata
cmpeq bObjectGray, srcdata, conf1
[conf1] b theLastCol
backLastCol:
add j, 1, j
cmplt j , height, conf1
[conf1] b loopHeight
.return nMarkValue
.endproc
.end
代码比较多, 哪位朋友帮我分析一下, 问题就出在这段汇编上, 不知道线性汇编有什么指令细节问题什么的,或者溢出什么的。 |