1.11M Members

Asm code

 
0
 

hey guys this c++ code which needed to convert to asm and when user enter 2000 the clock shoud show lest then 5 sec....

for (a=0; a<=y; a++)
        for (b=0; b<=y/2; b++)
            for (c=0; c<=y/3; c++)
                if ((a + 2*b + 3*c) == y)
                    count++;

this is the question
-finds the
solution for the equation a + 2b + 3c = y, where a, b, c, y are natural numbers
(0,1,2,....). Given the value of y, the program find out all the possible cobinations of a, b and
c. and after i convert to asm there is eror in divide..

 _asm{ 
  LOOP1:
        CMP B1(a),C2(y)
        JG END ;

                LOOP2:
                MOV C2(y),AX
                DIV AX,2 ; 
                CMP B2(b),
                JG LOOP1A ;

                        LOOP3:

                        MOVE C2(y),AX
                        DIV AX,3 ; 
                        CMP C1(c),
                        JG LOOP2A ; 

                        INC C1(c) ;
                        JMP LOOP3
                LOOP2A:
                INC B2(b) ; b++
                JMP LOOP2;
        LOOP1A:
        INC B1(a) ;a++
        JMP LOOP1;


stop:
    }
You
Post:
Start New Discussion
View similar articles that have also been tagged: