Jump to content

ASM w/ C++ problems

- - - - -

  • Please log in to reply
No replies to this topic

#1
RobotGymnast

RobotGymnast

    Programmer

  • Members
  • PipPipPipPip
  • 143 posts
Alright so I decided to start dabbling in x86 ASM a bit because I'm new to the field (being 15).

My code was simply as follows:


void outputstuff()

{

     WORD i = 0;


     __asm{pop i}

     printf("%u",i);

}

int main(int nArgs,char*sArgs[])

{

     WORD i = 0;

     

     __asm

     {

          jmp looping

          looping:

               cmp i,256

               je breaker

               push i

               call outputstuff

               add i,1

               jmp looping

          breaker:

     }

}


but it doesn't run properly (but compiles fine)
I also tried putting WORD i as an argument:


void outputstuff(WORD i)

...


push i

call outputstuff

....


but that didn't work either. Any idea?

Also, the conditional jump gave me some trouble. It works fine now, but I want to say if i is greater than or equal to 256, quit, but jge just quit right away and jle quit at 129. what's with that?

Thanks




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users