1. Consider the following array with the contents given:

5 5 5 5 5 5 5 5 5 5

Do the the following:
a) Write an assembly code using index addressing to add all the elements in the array and store the result in a memory location 'RESULT'. consider each of the element is of WORD size

b) Write the same program using Based Index addressing.

c) Write the same program using Based Index with displacement.

a) Assembly code using index addressing:

```assembly
MOV CX, 10 ; Initialize counter for number of elements
MOV BX, 0 ; Initialize index pointer
MOV SI, OFFSET ARRAY ; Start memory location of array elements
MOV AX, 0 ; Initialize accumulator

LOOP_START:
MOV AX, [SI+BX] ; Load array element at index BX into AX
ADD AX, [RESULT] ; Add current array element to accumulator in RESULT
MOV [RESULT], AX ; Store updated accumulator in RESULT

ADD BX, 2 ; Move to next index in array
DEC CX ; Decrease counter

CMP CX, 0 ; Check if all elements have been processed
JNZ LOOP_START ; If not, repeat loop

```

b) Assembly code using Based Index addressing:

```assembly
MOV CX, 10 ; Initialize counter for number of elements
MOV BX, 0 ; Initialize index pointer
MOV SI, OFFSET ARRAY ; Start memory location of array elements
MOV AX, 0 ; Initialize accumulator

LOOP_START:
ADD AX, [SI+BX] ; Add array element at index BX to accumulator
MOV [RESULT], AX ; Store updated accumulator in RESULT

ADD BX, 2 ; Move to next index in array
DEC CX ; Decrease counter

CMP CX, 0 ; Check if all elements have been processed
JNZ LOOP_START ; If not, repeat loop

```

c) Assembly code using Based Index with displacement addressing:

```assembly
MOV CX, 10 ; Initialize counter for number of elements
MOV BX, 0 ; Initialize index pointer
MOV SI, OFFSET ARRAY ; Start memory location of array elements
MOV AX, 0 ; Initialize accumulator

LOOP_START:
MOV AX, [BX+SI] ; Load array element at index BX into AX
ADD AX, [RESULT] ; Add current array element to accumulator in RESULT
MOV [RESULT], AX ; Store updated accumulator in RESULT

ADD BX, 2 ; Move to next index in array
DEC CX ; Decrease counter

CMP CX, 0 ; Check if all elements have been processed
JNZ LOOP_START ; If not, repeat loop

```

a) Assembly code using index addressing:

```
MOV AX, 0 ; Initialize sum with 0
MOV CX, 10 ; Set counter to 10 (number of elements in the array)
MOV DI, OFFSET ARR ; Load the starting address of the array into DI register

LOOP_START:
ADD AX, [DI] ; Add the value at the current index to AX
ADD DI, 2 ; Increment the index by 2 (since each element is of WORD size)
LOOP LOOP_START ; Repeat until counter becomes 0

MOV RESULT, AX ; Store the result in memory location 'RESULT'
```

b) Assembly code using Based Index addressing:
```
MOV BX, OFFSET ARR ; Load the base address of the array into BX register
MOV AX, 0 ; Initialize sum with 0
MOV CX, 10 ; Set counter to 10 (number of elements in the array)

LOOP_START:
ADD AX, [BX+SI] ; Add the value at the current index to AX
INC SI ; Increment the index by 1
LOOP LOOP_START ; Repeat until counter becomes 0

MOV RESULT, AX ; Store the result in memory location 'RESULT'
```

c) Assembly code using Based Index with displacement:
```
MOV BX, OFFSET ARR ; Load the base address of the array into BX register
MOV AX, 0 ; Initialize sum with 0
MOV CX, 10 ; Set counter to 10 (number of elements in the array)

LOOP_START:
ADD AX, [BX+SI+2] ; Add the value at the current index to AX, considering each element is of WORD size
INC SI ; Increment the index by 1
LOOP LOOP_START ; Repeat until counter becomes 0

MOV RESULT, AX ; Store the result in memory location 'RESULT'
```

Note: In all three programs, 'ARR' and 'RESULT' are assumed to be memory locations for the array and the result, respectively.