


Thread Tools  Display Modes 
Dec 28th, 2012, 12:53 PM  #1 
Newbie
Join Date: Dec 2012
Posts: 12
Rep Power: 0

guide for writing the sum of two hundred digits by Using string.
Hi
I have two numbers (up to hundreds of varieties) to get from the users. And sum it up, I would put in an array. I had some trouble First, when two numbers are added together to get an array of cell, and the result is Two digit, I do not know what to do. (because i want to use ADC and I need to singledigit numbers) Second, the first string put in si, second string put in di. The sum of the string, where I am? regards in Persian language: Ø¯Ùˆ Ù…Ø´Ú©Ù„ Ø¨Ø±Ø§ÛŒ Ù†ÙˆØ´ØªÙ† Ø¬Ù…Ø¹ Ø¯Ùˆ Ø¹Ø¯Ø¯ ØµØ¯ Ø±Ù‚Ù…ÛŒ Ø³Ù„Ø§Ù… Ù…ÛŒ Ø®ÙˆØ§Ù… Ø¯Ùˆ ØªØ§ Ø¹Ø¯Ø¯ (ØªØ§ ØµØ¯ Ø±Ù‚Ù…) Ø§Ø² Ú©Ø§Ø±Ø¨Ø± Ø¨Ú¯ÛŒØ±Ù…. Ùˆ Ø*Ø§ØµÙ„ Ø¬Ù…Ø¹ Ø¢Ù† Ù‡Ø§ Ø±Ø§ØŒ Ø¯Ø± ÛŒÚ© Ø¢Ø±Ø§ÛŒÙ‡ Ù‚Ø±Ø§Ø± Ø¨Ø¯Ù…. Ú†Ù†Ø¯ ØªØ§ Ù…Ø´Ú©Ù„ Ø¯Ø§Ø´ØªÙ… Ø§ÙˆÙ„ Ø§ÛŒÙ†Ú©Ù‡ ÙˆÙ‚ØªÛŒ Ø¯Ùˆ ØªØ§ Ø¹Ø¯Ø¯ Ø§Ø² Ø¯Ùˆ Ø®Ø§Ù†Ù‡ ÛŒ Ø¢Ø±Ø§ÛŒÙ‡ Ø±Ø§ Ø¨Ø§ Ù‡Ù… Ø¬Ù…Ø¹ Ù…ÛŒ Ú©Ù†Ù… Ùˆ Ø*Ø§ØµÙ„ Ø¯Ùˆ Ø±Ù‚Ù…ÛŒ Ù…ÛŒØ´Ù‡ØŒ Ù†Ù…ÛŒ Ø¯ÙˆÙ†Ù… Ø¨Ø§ÛŒØ¯ Ú†ÛŒÚ©Ø§Ø±Ø´ Ú©Ù†Ù…!! Ø¯ÙˆÙ… Ø§ÛŒÙ†Ú©Ù‡ØŒ Ø±Ø´ØªÙ‡ Ø§ÙˆÙ„ Ø±Ùˆ ØªÙˆÛŒ si Ù…ÛŒØ°Ø§Ø±Ù…ØŒ Ø±Ø´ØªÙ‡ Ø¯ÙˆÙ… Ø±Ùˆ ØªÙˆÛŒ di Ø¨Ø¹Ø¯ Ø±Ø´ØªÙ‡ Ø¬ÙˆØ§Ø¨ Ø±Ùˆ Ø¨Ø§ÛŒØ¯ Ú†Ù‡ Ú©Ø§Ø± Ú©Ù†Ù…ØŸØŸ!! ØªÙˆÛŒ ÛŒÚ©ÛŒ Ø§Ø² Ø«Ø¨Ø§Øª Ù‡Ø§ Ù…Ø«Ù„ ax Ù…ÛŒØ°Ø§Ø±Ù… Ø®Ø·Ø§ Ù…ÛŒØ¯Ù‡. 
Dec 29th, 2012, 2:28 AM  #2 
Programming Guru
Join Date: Jun 2005
Posts: 1,631
Rep Power: 15

Re: guide for writing the sum of two hundred digits by Using string.
1. Add from the least significant digit to the most significant digit. When you have a sum of the two digits that is over 9, set a carry flag and subtract 10 from the value. Then, when you add the next 2 digits and there is a carry flag, add 1 to the sum.
e.g. 416 + 739 6+9 = 15. Subtract 10: gives 5 and the carry flag set 1 + 3 = 4. Add one for the carry flag gives 5 and the carry flag clear 4 + 7 = 11. Subtract 10: gives 1 and the carry flag set As you finished with the carry flag you need to start with a 1. So the answer would be: 1155 2. You would need to use another register, or a memory location and use a register for an offset. Make sure that your output location is at least one bigger than your inputs. 
Jan 2nd, 2013, 9:39 AM  #3 
Newbie
Join Date: Dec 2012
Posts: 12
Rep Power: 0

debug code
Many thanks for the answer The Dark
Please help me debug this code http://www.mediafire.com/download.php?o79xx1mkh86e2o7 INCLUDE io.h ; header file for input/output 
Jan 2nd, 2013, 5:26 PM  #4 
Programming Guru
Join Date: Jun 2005
Posts: 1,631
Rep Power: 15

Re: guide for writing the sum of two hundred digits by Using string.
You should say what it is doing wrong to help me debug it.
Here are a few issues:

Jan 2nd, 2013, 10:27 PM  #5 
Programming Guru
Join Date: Jun 2005
Posts: 1,333
Rep Power: 14

Re: guide for writing the sum of two hundred digits by Using string.
I don't see where CX is ever initialized. Is the input function doing this? Im used to seeing eax used for return values.

Jan 2nd, 2013, 10:37 PM  #6 
Programming Guru
Join Date: Jun 2005
Posts: 1,631
Rep Power: 15

Re: guide for writing the sum of two hundred digits by Using string.
I thought that too, but assumed it was the returned length from the inputs call.

Jan 3rd, 2013, 11:40 AM  #7 
Programming Guru
Join Date: Jun 2005
Posts: 1,333
Rep Power: 14

Re: guide for writing the sum of two hundred digits by Using string.
What does your input look like once it gets read in by inputs? are you handling the existence of a newline at the end of your input?

Jan 4th, 2013, 6:21 AM  #8  
Newbie
Join Date: Dec 2012
Posts: 12
Rep Power: 0

Re: guide for writing the sum of two hundred digits by Using string.
Quote:
But still no output! Please help INCLUDE io.h ; header file for input/output 

Jan 23rd, 2013, 7:33 AM  #9 
Newbie
Join Date: Dec 2012
Posts: 12
Rep Power: 0

Re: guide for writing the sum of two hundred digits by Using string.
Please help me to debug this code
I got an error in line 51.: illegal indexing mode INCLUDE io.h ; header file for input/output 
Bookmarks 
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)  
Thread Tools  
Display Modes  


Similar Threads  
Thread  Thread Starter  Forum  Replies  Last Post 
Double data when saving  Serigraphie  Visual Basic .NET  2  Aug 1st, 2012 4:37 AM 
sum of 2 digits mistake in code?  3drenderer  Assembly  6  Feb 16th, 2011 6:31 AM 
Converting Capitals to lowercase in a string  MIPS  Nukkenfutz  Assembly  1  Dec 2nd, 2010 8:46 AM 
Sum of digits in a float?  maligree  C  3  Jul 12th, 2008 3:37 PM 
An Attempt at a DBMS  grimpirate  PHP  8  Apr 17th, 2007 1:01 PM 