4 Replies - 2046 Views - Last Post: 23 February 2013 - 08:11 AM Rate Topic: -----

#1 alanso  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 23-February 13

convert to c++ to assembly i am having problem it cant run

Posted 23 February 2013 - 05:57 AM

this is the c++ code which need to convert to assembly

//Convert this nested for loop to assembly instructions
	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 assembly which i converted n got error

MOV y,C2 
        
        LOOP1:
        CMP B1(a),C2(y)
        JG END ;if a>y , jump to 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 ; 
                       
                                ((a + 2*b + 3*c) == y)
                                
                        INC C1(c) ;c++
                        JMP LOOP3
                LOOP2A:
                INC B2(B)/>/> ; b++
                JMP LOOP2;
        LOOP1A:
        INC B1(a) ;a++
        JMP LOOP1;



Is This A Good Question/Topic? 0
  • +

Replies To: convert to c++ to assembly i am having problem it cant run

#2 no2pencil  Icon User is online

  • Toubabo Koomi
  • member icon

Reputation: 5230
  • View blog
  • Posts: 27,014
  • Joined: 10-May 07

Re: convert to c++ to assembly i am having problem it cant run

Posted 23 February 2013 - 06:12 AM

View Postalanso, on 23 February 2013 - 07:57 AM, said:

this is the assembly which i converted n got error

Can you elaborate?

Was the error in the conversion, in the C code, in the asm code, when running the C code, or when running the asm code?

Also some other notable information would be the compiler you are using for C, the assembler you are using, & how exactly you converted this code.
Was This Post Helpful? 0
  • +
  • -

#3 alanso  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 23-February 13

Re: convert to c++ to assembly i am having problem it cant run

Posted 23 February 2013 - 06:21 AM

mirosoft visual c++ 2010... are there any software converts c++ to assembly
Was This Post Helpful? 0
  • +
  • -

#4 no2pencil  Icon User is online

  • Toubabo Koomi
  • member icon

Reputation: 5230
  • View blog
  • Posts: 27,014
  • Joined: 10-May 07

Re: convert to c++ to assembly i am having problem it cant run

Posted 23 February 2013 - 08:06 AM

Normally what one does is issues a flag to the compiler to compile c++ code to assembly output.

After a few moments of Google searching I found this. I would suggest you refer to the documentation of the compiler, or perhaps someone may post that is more familiar with Microsoft Visual C++ 2010.
Was This Post Helpful? 0
  • +
  • -

#5 GunnerInc  Icon User is online

  • "Hurry up and wait"
  • member icon




Reputation: 858
  • View blog
  • Posts: 2,279
  • Joined: 28-March 11

Re: convert to c++ to assembly i am having problem it cant run

Posted 23 February 2013 - 08:11 AM

that code is not valid syntax for any Assembly language I have ever seen. VS uses MASM on the backend.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1