Howdy, Stranger!

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

Sign In with Facebook Sign In with Google Sign In with OpenID

Categories

We have migrated to a new platform! Please note that you will need to reset your password to log in (your credentials are still in-tact though). Please contact lee@programmersheaven.com if you have questions.
Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

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

Comments

  • IDKIDK Posts: 1,784Member
    Noone will write code for you, but if you ask specific questions, you might get what you want.
  • fabricemoreirafabricemoreira Posts: 11Member
    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
  • MT2002MT2002 Posts: 1,444Member
    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.

    [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]
  • BitByBit_ThorBitByBit_Thor Posts: 2,444Member
    : 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
Sign In or Register to comment.