void Mask_1(unsigned char * const ptrDestBuffer, const unsigned char * const ptrSrcBuffer, int Width, int Height, int idLineAdd, int isLineAdd, int idPixelAdd, int isPixelAdd, int MaskColor)
{
const int ld = idPixelAdd + 3;
const int ls = isPixelAdd + 3;
const unsigned char bmaskr = (unsigned char)MaskColor;
const unsigned char bmaskb = (unsigned char)(MaskColor>>16);
idPixelAdd += 2;
isPixelAdd += 2;
Width--;
int i;
register unsigned char *ptrDest = ptrDestBuffer;
register const unsigned char *ptrSrc = ptrSrcBuffer;
for (i = Height - 1; i >= 0; i--)
{
register int j = Width;
do
{
j--;
if (*ptrDest != bmaskr) //bmaskrgb[0]:Dest background color[blue part]
{
if (*ptrSrc != bmaskb) //bmaskb:Src background color[blue part]
{
*ptrDest = *ptrSrc;
ptrDest++;
ptrSrc++;
*((unsigned short int *)(ptrDest)) = *((unsigned short int *)(ptrSrc));
ptrDest += idPixelAdd;
ptrSrc += isPixelAdd;
}
else
{
ptrDest += ld;
ptrSrc += ls;
}
}
else
{
*ptrDest = *ptrSrc;
ptrDest++;
ptrSrc++;
*((unsigned short int *)(ptrDest)) = *((unsigned short int *)(ptrSrc));
ptrDest += idPixelAdd;
ptrSrc += isPixelAdd;
}
}while(j >= 0);
ptrDest += idLineAdd;
ptrSrc += isLineAdd;
}
} pushl %ebp
movl %esp, %ebp
subl $28, %esp
movl 32(%ebp), %eax
addl $3, %eax
movl %eax, -4(%ebp)
movl 36(%ebp), %eax
addl $3, %eax
movl %eax, -8(%ebp)
movl 40(%ebp), %eax
movb %al, -9(%ebp)
movl 40(%ebp), %eax
sarl $16, %eax
movb %al, -10(%ebp)
leal 32(%ebp), %eax
addl $2, (%eax)
leal 36(%ebp), %eax
addl $2, (%eax)
leal 16(%ebp), %eax
decl (%eax)
movl 8(%ebp), %eax
movl %eax, -20(%ebp)
movl 12(%ebp), %edx
movl %edx, -24(%ebp)
movl 20(%ebp), %eax
decl %eax
movl %eax, -16(%ebp)
L3:
cmpl $0, -16(%ebp)
js L2
movl 16(%ebp), %eax
movl %eax, -28(%ebp)
L6:
decl -28(%ebp)
movl -20(%ebp), %edx
movzbl (%edx), %eax
cmpb -9(%ebp), %al
je L9
movl -24(%ebp), %edx
movzbl (%edx), %eax
cmpb -10(%ebp), %al
je L10
movl -24(%ebp), %edx
movzbl (%edx), %eax
movl -20(%ebp), %edx
movb %al, (%edx)
incl -20(%ebp)
incl -24(%ebp)
movl -24(%ebp), %edx
movzwl (%edx), %eax
movl -20(%ebp), %edx
movw %ax, (%edx)
movl 32(%ebp), %eax
addl %eax, -20(%ebp)
movl 36(%ebp), %edx
addl %edx, -24(%ebp)
jmp L8
L10:
movl -4(%ebp), %eax
addl %eax, -20(%ebp)
movl -8(%ebp), %edx
addl %edx, -24(%ebp)
jmp L8
L9:
movl -24(%ebp), %edx
movzbl (%edx), %eax
movl -20(%ebp), %edx
movb %al, (%edx)
incl -20(%ebp)
incl -24(%ebp)
movl -24(%ebp), %edx
movzwl (%edx), %eax
movl -20(%ebp), %edx
movw %ax, (%edx)
movl 32(%ebp), %eax
addl %eax, -20(%ebp)
movl 36(%ebp), %edx
addl %edx, -24(%ebp)
L8:
cmpl $0, -28(%ebp)
js L7
jmp L6
L7:
movl 24(%ebp), %eax
addl %eax, -20(%ebp)
movl 28(%ebp), %edx
addl %edx, -24(%ebp)
leal -16(%ebp), %eax
decl (%eax)
jmp L3
L2:
leave
ret

本文深入探讨了使用 GCC 编译器进行汇编编程的细节,重点解析了函数 `Mask_1` 的实现过程,涵盖了从 C 代码到汇编转换的关键步骤,帮助读者理解底层指令和优化技巧。
718

被折叠的 条评论
为什么被折叠?



