Help to finish a code

i have a problem.
i need help to converte a c++ to assembley, anybody can help me, i have do only until 18 pm to finish.


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;
}
}



i have done that code but it's not well done

/*************************************
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

Comments

  • [link=http://www.programmersheaven.com/mb/SourceShare/365264/365264/ReadMessage.aspx?S=B20000]Please dont cross post[/link]

    : i have a problem.
    : i need help to converte a c++ to assembley, anybody can help me, i
    : have do only until 18 pm to finish.

    Hope you get it finished in time, then :-)

    : i have done that code but it's not well done

    Im not sure what you mean here... Please describe in more detail at what you need...

    [hr][size=1][leftbr].:EvolutionEngine[rightbr][leftbr].:MicroOS Operating System[rightbr][leftbr][link=http://www.mt2002.sitesled.com]Website :: OS Development Series[rightbr][/link][/size]
  • I have to transforme the c ++ code to assembley.

    the c++ code is on the top

    i try to transforme de code, but but it's not well done, the code don't compile
  • : I have to transforme the c ++ code to assembley.
    :
    : the c++ code is on the top
    :
    : i try to transforme de code, but but it's not well done, the code
    : don't compile
    :

    I guess it's too late now, but:
    First of all, the error messages when trying to compile are very helpful.

    Second of all, I think I can guess what they are:
    When you use MUL by a variable you forget to specify the variable's size (word/dword).

    Best Regards,
    Richard

    The way I see it... Well, it's all pretty blurry
  • Now i have other problem i have to pass the code in assembley to assembly optimized and i don't know how to do this. anybody can do this for me?


    And post
  • : Now i have other problem i have to pass the code in assembley to
    : assembly optimized and i don't know how to do this. anybody can do
    : this for me?
    :
    :

    Do you mean optimizing the assembly code for speed?

    I'd say it's more of an art than anything else ;)
    The trick is to try and calculate things only once and building on previous calculation. For instance, if you have:
    [code]
    int a = someVariable / 100
    int b = someVariable % 100
    [/code]
    This could be done in assembly by only one division (where a becomes eax and b becomes edx).
    This is one example.
    Another would be:
    [code]
    int a = someVariable / 100
    int b = someVariable / 1000
    [/code]
    Rather than getting the value of someVariable twice (once for each calculation), you could use the result of a and divide it by 10 to get b.

    One thing I saw in your code was at the first two calculations:
    First calculation you set ecx to 2 and the second calculation you do this again. This improves readability so I would not call it bad practice at all... however, if you want to optimize for speed (and also space in this matter), the second instruction can be omitted.

    Best Regards,
    Richard

    The way I see it... Well, it's all pretty blurry
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories