Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


adding double word

esadleresadler Member Posts: 1
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.

The problem is this:
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.

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?

mov ax,6000h ;load ax with 6000h
mov ds,ax ;set ds to 60000h

mov w.[1020h],0000 ;clear memory location 60020h low byte
mov w.[1022h],0000 ;clear memory location 60022h high byte
mov si,0000h ;clear si
mov cx,0000h ;clear cx
mov bx,0020h ;get sum
mov ax,[bx] ;move the content of bx into ax
add ax,[si] ;add the content of si to ax store in ax
mov [bx],ax ;move content of ax into bx 60020h
inc si ;inc si to look at next word
inc si ;inc si
inc bx ;inc bx to store in 60022h
inc bx ;inc bx
mov ax,[bx] ;move the content of bx high byte into ax
adc ax,[si] ;move the content of si into ax 60002h
mov [bx],ax ;move the content of ax into bx 60022h
inc cx ;inc count
inc si ;move to next word to add 60004
inc si ;move to next word to add
cmp cx,0006h ;compare to see if loop is done
jne lp ;jump


Sign In or Register to comment.