Other Programming Languages
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreOther Programming Languages

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old February 4th, 2008, 09:38 AM
matt999tye matt999tye is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2006
Posts: 4 matt999tye Negative: is most likely a SPAMMER and a traitor to the cause. 
Time spent in forums: 1 h 27 m 37 sec
Reputation Power: 0
Assembly - New To Assembly

I am brand new to assembly, and i have just learned how to add two numbers. However I need to add eight numbers, and I just dont know how. here is my trial code

short int num1 = 0x1;
short int num2 = 0x0;
short int num3 = 0x1;
short int num4 = 0x3;
short int num5 = 0x6;
short int num6 = 0x6;
short int num7 = 0x5;
short int num8 = 0x4;
short int ans1 = 0;

__asm {

// | | |

mov ax,num1 ;get first num to add
mov ax,num2 ;get second num to add
mov ax,num3 ;get third num to add
mov ax,num4 ;get fourth num to add
mov ax,num5 ;get fifth num to add
mov ax,num6 ;get sixth num to add
mov ax,num7 ;get seventh num to add
mov ax,num8 ;get eigth num to add
add ax,num2 ;form sum
add ax,num3 ;form sum
add ax,num4 ;form sum
add ax,num5 ;form sum
add ax,num6 ;form sum
add ax,num7 ;form sum
add ax,num8 ;form sum
mov ans1,ax ;store result

}

Reply With Quote
  #2  
Old February 4th, 2008, 09:54 AM
Lux Perpetua Lux Perpetua is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Feb 2004
Location: San Francisco Bay
Posts: 1,418 Lux Perpetua User rank is Major (30000 - 40000 Reputation Level)Lux Perpetua User rank is Major (30000 - 40000 Reputation Level)Lux Perpetua User rank is Major (30000 - 40000 Reputation Level)Lux Perpetua User rank is Major (30000 - 40000 Reputation Level)Lux Perpetua User rank is Major (30000 - 40000 Reputation Level)Lux Perpetua User rank is Major (30000 - 40000 Reputation Level)Lux Perpetua User rank is Major (30000 - 40000 Reputation Level)Lux Perpetua User rank is Major (30000 - 40000 Reputation Level)Lux Perpetua User rank is Major (30000 - 40000 Reputation Level)Lux Perpetua User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 3 Weeks 4 Days 23 h 47 m 27 sec
Reputation Power: 334
When you move something into a register, it overwrites the old value of the register, so your data moves are pointless. You should do it by either moving one of the numbers to the register and adding the rest to it, or simply zeroing out the register and adding all the numbers to it.

Reply With Quote
  #3  
Old February 4th, 2008, 09:57 AM
matt999tye matt999tye is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2006
Posts: 4 matt999tye Negative: is most likely a SPAMMER and a traitor to the cause. 
Time spent in forums: 1 h 27 m 37 sec
Reputation Power: 0
Quote:
Originally Posted by Lux Perpetua
When you move something into a register, it overwrites the old value of the register, so your data moves are pointless. You should do it by either moving one of the numbers to the register and adding the rest to it, or simply zeroing out the register and adding all the numbers to it.


thanks for the timely response. so something like this should work?
mov ax,num1 ;get first num to add
add ax,num2 ;form sum
add ax,num3 ;form sum
add ax,num4 ;form sum
add ax,num5 ;form sum
add ax,num6 ;form sum
add ax,num7 ;form sum
add ax,num8 ;form sum
mov ans1,ax ;store result
Comments on this post
Lux Perpetua agrees: yes, now you have it.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreOther Programming Languages > Assembly - New To Assembly


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway