Sum of a word array not storing in another word array

658 views Asked by At

*The task assigned to me twas to write an assembly program that finds the sum of three 8-bits values and places it in memory at location SUMS. Then compute sum of three word variable, and place it in memory at location SUMS + 2. Use the following data:

BYTE_ARRAY DB 10H,20H,30H
WORD_ARRAY DW 1000H,2000H,3000H
SUMS DW 0,0*

My problem is that the following code gives me an error

mov sums,al

I understand that one is a 16 bit address and the other is 8 bit address but is there any other way to get around it?

EDIT:

Complete code:

    org 100h

.data 
byte_array db 10h,20h,30h
word_array dw 1000h,2000h,3000h


sums dw 0,0

.code

mov ax,@data
mov ds,ax
mov bx,offset byte_array
mov al,[bx]
inc bx
add al,[bx]
inc bx
add al,[bx]
mov si,offset sums
mov [si],al

mov bx,offset word_array
mov ax,[bx]
add ax,[bx+2]
add ax,[bx+4]
mov [bx+6], ax





ret

My only problem that remains is that i do not understand the meaning of SUMS + 2. What is the questions asking me to do?

2

There are 2 answers

2
Devolus On
SUMS DW 0,0
mov sums,al

As you declared your array being of word size, your operand should match that.

mov sums, ax
0
Ahmad On

al is 8 bits.

sum is 16 bits.

so they have conflict.