LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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: 852

Rep: Reputation: 389Reputation: 389Reputation: 389Reputation: 389
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
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,999

Rep: Reputation: 3190Reputation: 3190Reputation: 3190Reputation: 3190Reputation: 3190Reputation: 3190Reputation: 3190Reputation: 3190Reputation: 3190Reputation: 3190Reputation: 3190
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: 223

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

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
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: 454Reputation: 454Reputation: 454Reputation: 454Reputation: 454
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.1
Posts: 722
Blog Entries: 2

Rep: Reputation: 124Reputation: 124
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

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:30 AM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration