LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 02-21-2013, 01:51 AM   #1
falcan
LQ Newbie
 
Registered: Feb 2013
Posts: 2

Rep: Reputation: Disabled
How to convert this c++ code into assembly?


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++;
 
Old 02-21-2013, 02:00 AM   #2
millgates
Member
 
Registered: Feb 2009
Location: 192.168.x.x
Distribution: Slackware
Posts: 651

Rep: Reputation: 269Reputation: 269Reputation: 269
Have you tried using a compiler?

Code:
g++ -S file.cpp
 
2 members found this post helpful.
Old 02-21-2013, 08:27 AM   #3
falcan
LQ Newbie
 
Registered: Feb 2013
Posts: 2

Original Poster
Rep: Reputation: Disabled
thanks

i dont know how to use it...can pls post the assembly code..it is urgent i need it
 
Old 02-21-2013, 08:29 AM   #4
grail
Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 7,432

Rep: Reputation: 1878Reputation: 1878Reputation: 1878Reputation: 1878Reputation: 1878Reputation: 1878Reputation: 1878Reputation: 1878Reputation: 1878Reputation: 1878Reputation: 1878
hmmm ... urgent to you perhaps which now makes it sound and look like a homework question.

If not homework, please explain what you are trying to do and where you are stuck?

Note: Answers not excepted will be, turn code into assembler and don't know how.
 
Old 02-21-2013, 03:34 PM   #5
TKH
Member
 
Registered: Jul 2011
Location: Milky Way
Distribution: Ubuntu, LFS, Slackware, Fedora
Posts: 205

Rep: Reputation: 20
gcc -S <input file> -o <output file>
 
Old 02-21-2013, 05:43 PM   #6
colucix
Moderator
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,458

Rep: Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941
Moved: This thread is more suitable in Programming and has been moved accordingly to help your thread/question get the exposure it deserves.
 
Old 02-22-2013, 04:53 AM   #7
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 453Reputation: 453Reputation: 453Reputation: 453Reputation: 453
Quote:
Originally Posted by falcan View Post
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++;
Are you sure this is a valid C++ code ? Have you tried to compile it as C++ code first ?
 
Old 02-22-2013, 08:41 PM   #8
psionl0
Member
 
Registered: Jan 2011
Distribution: slackware_64 14.0
Posts: 510
Blog Entries: 2

Rep: Reputation: 68
Quote:
Originally Posted by falcan View Post
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++;
Is this a subroutine or a snippet of main code?
Is y a global variable? Or is y a parameter that was pushed on the stack? Or is y a parameter stored in the EAX register when the code snippet was executed?

Is count a global variable or is it something to be returned on the stack or EAX register? Does count need to be initialized?

Maybe y and count are addresses that were pushed on the stack before this code snippet was run?
Maybe y and count are addresses that were stored in the EAX and EBX registers before this code snippet was run?

BTW If you use CODE tags the program fragment will display the way you intended.

Last edited by psionl0; 02-22-2013 at 08:43 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to convert Assembly langugae to Executable in c language ssg14j Programming 15 11-04-2008 07:49 AM
How to convert Assembly code to "C" source code ssg14j Programming 2 08-01-2005 12:48 PM
how to convert C executable into Assembly Code indian Programming 4 10-04-2004 04:56 PM


All times are GMT -5. The time now is 02:13 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration