<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
  <channel>
    <title>'adding double word' Thread RSS Feed</title>
    <link>http://www.programmersheaven.com/</link>
    <description>Contains the latest posts from the thread 'adding double word' posted on the 'x86 Assembly' forum at Programmer's Heaven.</description>
    <language>en</language>
    <copyright>Copyright 2008 Programmers Heaven</copyright>
    <pubDate>Wed, 15 Oct 2008 19:32:32 -0700</pubDate>
    <lastBuildDate>Wed, 15 Oct 2008 19:32:32 -0700</lastBuildDate>
    <generator>Argotic Syndication Framework 2007.3.0.1, http://www.codeplex.com/Argotic</generator>
    <docs>http://www.rssboard.org/rss-specification</docs>
    <ttl>360</ttl>
    <image>
      <url>http://www.programmersheaven.com/images/ph.gif</url>
      <title>Programmers Heaven</title>
      <link>http://www.programmersheaven.com/</link>
      <width>88</width>
      <height>31</height>
    </image>
    <item>
      <title>adding double word</title>
      <link>http://www.programmersheaven.com/mb/x86_asm/370649/370649/adding-double-word/</link>
      <description>First of all let me thank you for taking the time to read and possibly respond to this question.  Second this is a homework assignment so I am not looking for someone to do this for me just answer a few questions and place me on the correct path.&lt;br /&gt;
&lt;br /&gt;
The problem is this:   &lt;br /&gt;
Add together all of the 2-word numbers that are stored from address 6000h to 60fffh in memory.  Store the sum starting at location 61020h.  Each 2-word number may range in size from 00000000h to ffffffffh.  State your assumptions as to how the words for each number are stored in memory and how large the final sum can be.&lt;br /&gt;
&lt;br /&gt;
The words are stored in my case low then high in two consecutive bytes.  What I am not sure about is what happens when I have a carry in the lower word and where does the carry of the upper word go?  As for the second do I need to look at the next higher byte?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
mov ax,6000h        ;load ax with 6000h&lt;br /&gt;
mov ds,ax           ;set ds to 60000h&lt;br /&gt;
&lt;br /&gt;
mov w.[1020h],0000    ;clear memory location 60020h low byte&lt;br /&gt;
mov w.[1022h],0000    ;clear memory location 60022h high byte&lt;br /&gt;
mov si,0000h        ;clear si&lt;br /&gt;
mov cx,0000h        ;clear cx&lt;br /&gt;
lp:&lt;br /&gt;
    mov bx,0020h    ;get sum&lt;br /&gt;
    mov ax,[bx]     ;move the content of bx into ax&lt;br /&gt;
    add ax,[si]     ;add the content of si to ax store in ax&lt;br /&gt;
    mov [bx],ax     ;move content of ax into bx 60020h&lt;br /&gt;
    inc si          ;inc si to look at next word&lt;br /&gt;
    inc si          ;inc si&lt;br /&gt;
    inc bx          ;inc bx to store in 60022h&lt;br /&gt;
    inc bx          ;inc bx&lt;br /&gt;
    mov ax,[bx]     ;move the content of bx high byte into ax&lt;br /&gt;
    adc ax,[si]     ;move the content of si into ax 60002h&lt;br /&gt;
    mov [bx],ax     ;move the content of ax into bx 60022h&lt;br /&gt;
    inc cx          ;inc count&lt;br /&gt;
    inc si          ;move to next word to add 60004&lt;br /&gt;
    inc si          ;move to next word to add&lt;br /&gt;
    cmp cx,0006h    ;compare to see if loop is done&lt;br /&gt;
    jne lp          ;jump&lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
Thanks &lt;br /&gt;
&lt;br /&gt;
Ed&lt;br /&gt;</description>
      <pubDate>Thu, 27 Mar 2008 07:26:45 -0700</pubDate>
      <category>x86 Assembly</category>
    </item>
  </channel>
</rss>