LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
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 03-28-2011, 09:00 AM   #1
ridoy
LQ Newbie
 
Registered: Feb 2011
Posts: 19

Rep: Reputation: 1
assembly code


can someone give me a code to add 5 numbers in assembly?i want to use array for input of those 5 numbers.No problem if the output is 1 digit(0....9).i need it immediately..

Last edited by ridoy; 03-28-2011 at 01:33 PM.
 
Old 03-28-2011, 09:16 AM   #2
johnsfine
LQ Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,286

Rep: Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197
1) Looks like a homework question, so I would advise other experts against posting a complete homework answer.

2) You didn't say which architecture. I expect you mean X86 architecture. You might mean X86-64 architecture. But there are lots of other possibilities as well.

3) You were a bit vague about the required functionality. Make sure you at least understand yourself what functionality you want.

Do you want to display a prompt for all five numbers or for each number or not at all?

Is inputing the numbers from stdin to that array even part of the asm project?

4) If you are teaching yourself asm, rather than taking a class with specific assignments, I strongly suggest you leave asm I/O for much later or possibly never. Asm may be useful for computations, but is really lame for program I/O (asm I/O inside a driver is totally unlike asm I/O in an ordinary program).

ASM mixes very well with C and with the C runtime library. So either learn to call the C runtime library from asm code to do the I/O or (better) learn to write asm functions to be called from C and leave the I/O in the C calling function.

Last edited by johnsfine; 03-28-2011 at 09:20 AM.
 
1 members found this post helpful.
Old 03-28-2011, 09:27 AM   #3
ridoy
LQ Newbie
 
Registered: Feb 2011
Posts: 19

Original Poster
Rep: Reputation: 1
yes i mean X86 architecture.and i want to have the result of sum of all those 5 numbers as output
 
0 members found this post helpful.
Old 03-29-2011, 02:12 PM   #4
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
What do you mean by 'output'?
You want a function whose return value is the sum?
You want the value written to stdout (this complicates the requirement by an order of magnitude)?
What kind of numbers?
In this context, 'architecture' should include much more than the CPU type. OS, if any, high-level language parameter passing, if any, numeric format, toolchain compatbility, etc.

You'll find that most of us here aren't particularly motivated by your priorities. If you need something done on a timely basis, there are paid consultants to serve you, commensurate with your budget. In that case, you could economize by articulating the requirements with considerably greater detail.

--- rod.

Last edited by theNbomr; 03-29-2011 at 02:15 PM.
 
1 members found this post helpful.
  


Reply



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 converting the c++ code to assembly Nejad Programming 17 12-29-2008 12:50 PM
Trying to see assembly code on Runtime Azrai Programming 1 07-18-2006 11:44 PM
assembly code on linux omerlh Programming 1 06-01-2006 03:25 AM
Command for getting assembly code aizkorri Programming 1 06-18-2002 05:04 AM

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

All times are GMT -5. The time now is 07:15 PM.

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