# Help to finish a code

someone can help me transforming this code on c++ to assembley:
[code]
void muda_pixeis_c_f3(int altura, int largura, Byte *porig[], Byte *pdest[])
{
// Bin
int x, y, ml, ma, tx, factor;
ml = largura / 2;
ma = altura / 2;
for(y = 0; y < altura; y++){
for(x = 0; x < largura * 3; x+=3){
tx = x / 3;
factor = 1000 - 1000 * ((tx-ml)*(tx-ml) + (y-ma)*(y-ma)) / (ml*ml + ma*ma);
pdest[y][x]= (porig[y][x] * factor) / 1000;
pdest[y][x+1]= (porig[y][x+1] * factor) / 1000;
pdest[y][x+2]= (porig[y][x+2] * factor) / 1000;
}
}
}[/code]

i have already start, i only need to someone finish the code
[code]
void muda_pixeis_asm_f3(int altura, int largura, Byte *porig[], Byte *pdest[])
{
/*************************************
ebp+20 pdest
ebp+16 porig
ebp+12 largura
ebp+8 altura
ebp-4 x
ebp-8 y

ebp-12 ml
ebp-16 ma
ebp-20 tx
ebp-24 factor
*************************************/

asm
{
sub esp, 24 //int x, y, ml, ma, tx, factor

//declara

• Noone will write code for you, but if you ask specific questions, you might get what you want.
• i have already all the code done, but it's not working and i don't known where is the problem

CODE:
[code]
void muda_pixeis_asm_f3(int altura, int largura, Byte *porig[], Byte *pdest[])
{
/*************************************
ebp+20 pdest
ebp+16 porig
ebp+12 largura
ebp+8 altura
ebp-4 x
ebp-8 y

ebp-12 ml
ebp-16 ma
ebp-20 tx
ebp-24 factor
*************************************/

asm
{
sub esp, 24 //int x, y, ml, ma, tx, factor

//declara
• Ugh. Please dont crosspost, it is against the forum rules.

As I said in the other post, why not just disassemble the C++ routine, and work with that? Have you tried using a debugger?

Also, please post code using [leftbr]code[rightbr]*code here*[leftbr]/code[rightbr] tags:
[code]
*code here*
[/code]
Thanks.

• : i have already all the code done, but it's not working and i don't
: known where is the problem
:

Hey,

First off I would like to apologise for not responding to your mail.
I think I might know something that's not right:
[code]
mov ebx, dword ptr [ebp+16] //porig
mov ecx, X //x
mov edx, Y //y
mov esi, dword ptr [ebx+4*edx] //point linha da img orig
mov al, byte ptr [esi+ecx] //porig [y][x] -> al

[color=Green]// EAX here is FACTOR except for AL which is as above
// You need to XOR EAX, EAX before moving to AL (in the part above)[/color]
mul FACTOR
mov ecx, 1000
[color=Green]//cdq Unnecesary, because MUL fills EDX:EAX[/color]
idiv ecx
[/code]
Best Regards,
Richard

The way I see it... Well, it's all pretty blurry