-1

*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?

nrz
  • 10,435
  • 4
  • 39
  • 71
Codex
  • 11
  • 5
  • no this is as far as i have gotten. i have tackled only trying add to 3 8 bit values. the rest of the question is untouched. – Codex Dec 16 '13 at 14:31

2 Answers2

1

al is 8 bits.

sum is 16 bits.

so they have conflict.

Majid
  • 13,853
  • 15
  • 77
  • 113
Ahmad
  • 906
  • 11
  • 27
0
SUMS DW 0,0
mov sums,al

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

mov sums, ax
Devolus
  • 21,661
  • 13
  • 66
  • 113
  • in addition, the task to store sum of three word variable, and place it in memory at location SUMS + 2 will be achieved through the means of pointers? correct? – Codex Dec 16 '13 at 14:41
  • That could be done, and makes sense. Not strictly neccessary for this though. And as the code is missing, I was not commenting on that part. – Devolus Dec 16 '13 at 14:47