We're a community of 1.1M IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,080,620 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

Asm code

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:
    }
1
Contributor
0
Replies
9
Views
alanso
Newbie Poster
22 posts since Mar 2012
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page generated in 0.2784 seconds using 2.64MB