Consider the following array with the contents given (you have to declare it in your program):

5 9 11 16 20 25 19 7 30 13

Write an assembly program to convert each of the even numbers in the array to its next higher odd numbers and each of the odd numbers in the array to its immediate lower even numbers. then add all modified numbers in the array and sotre result in a memory location 'RESULT'. consider each of the element is of WORD size

Assuming that the array is stored starting at memory address 1000, and the 'RESULT' memory location will be at address 2000, you can write the following assembly program to achieve the desired result:

```
DATA SEGMENT
ARR DW 5, 9, 11, 16, 20, 25, 19, 7, 30, 13
SIZE DW 10 ; Number of elements in the array
RESULT DW ?
DATA ENDS

CODE SEGMENT
ASSUME DS:DATA, CS:CODE

START:
MOV AX, DATA
MOV DS, AX ; Initialize DS segment register

MOV SI, 0 ; Initialize source index
MOV DI, 0 ; Initialize destination index
MOV BX, 0 ; Initialize sum register

LOOP_START:
MOV AX, ARR[SI] ; Load next element from the array
CMP AX, 0 ; Check if the element is zero (end of array)
JE END_LOOP ; If yes, jump to the end

TEST AX, 1 ; Check if the number is odd or even
JNZ ODD ; If odd, jump to ODD label

EVEN:
INC AX ; Increment even number to the next odd number
MOV ARR[DI], AX ; Store the modified number back to the array
ADD BX, AX ; Add the modified number to the sum
ADD DI, 2 ; Increment destination index
ADD SI, 2 ; Increment source index
JMP LOOP_START ; Jump to the start of the loop

ODD:
DEC AX ; Decrement odd number to the previous even number
MOV ARR[DI], AX ; Store the modified number back to the array
ADD BX, AX ; Add the modified number to the sum
ADD DI, 2 ; Increment destination index
ADD SI, 2 ; Increment source index
JMP LOOP_START ; Jump to the start of the loop

END_LOOP:
MOV RESULT, BX ; Store the sum in the RESULT memory location

MOV AX, 4C00H ; Terminate the program
INT 21H

CODE ENDS
END START
```

This program uses a loop that iterates over each element in the array. It checks if the current element is odd or even using the `TEST` instruction. If it's even, it increments it to the next odd number, stores it back into the array, adds it to the sum in the `BX` register, and increments the source and destination indices. If it's odd, it decrements it to the previous even number, performs the same operations, and increments the indices.

After the loop, the program stores the final sum in the `RESULT` memory location and terminates.

display the RESULT

To display the value stored in the 'RESULT' memory location, you can add the following code snippet to the end of the previous assembly program:

```
DISPLAY_RESULT:
MOV AH, 02H ; Set the function to display a character
MOV DL, 'R' ; Move the ASCII value of 'R' to the DL register
INT 21H ; Display the character

MOV AH, 09H ; Set the function to display a string
LEA DX, RESULT ; Load the address of the 'RESULT' memory location
INT 21H ; Display the value

MOV AH, 02H ; Set the function to display a character
MOV DL, ' ' ; Move a space character to the DL register
INT 21H ; Display the space character

MOV AH, 02H ; Set the function to display a character
MOV DL, 'H' ; Move the ASCII value of 'H' to the DL register
INT 21H ; Display the character

MOV AX, 4C00H ; Terminate the program
INT 21H

CODE ENDS
END START
```

This additional code snippet will display the value stored in the 'RESULT' memory location using the INT 21H interrupt. Firstly, it displays the character 'R', then it displays the value stored in 'RESULT', followed by a space character, and finally, it displays the character 'H'. After that, the program terminates.

By incorporating this code, you can display the value stored in the 'RESULT' memory location at the end of the program execution.

Certainly! Here's a step-by-step breakdown:

Step 1: Declare and initialize the array of numbers

```assembly
DATA SEGMENT
ARR DW 5, 9, 11, 16, 20, 25, 19, 7, 30, 13
DATA ENDS
```

Step 2: Set up the necessary registers and variables

```assembly
CODE SEGMENT
ASSUME CS:CODE, DS:DATA

START:
MOV AX, DATA
MOV DS, AX

MOV BX, 0 ; Accumulator for the result
MOV CX, 10 ; Number of elements in the array
LOOP_START:
```

Step 3: Check if the current element is even or odd, and perform the required modification

```assembly
MOV AX, ARR[BX] ; Load the current element into AX

TEST AX, 1 ; Check if it's odd or even
JNZ ODD ; If it's odd, jump to the ODD section

; Even number, so add 1 to make it odd
ADD AX, 1
JMP NEXT ; Jump to the next iteration

ODD:
; Odd number, so subtract 1 to make it even
SUB AX, 1
```

Step 4: Add the modified number to the accumulator and move to the next element

```assembly
NEXT:
ADD BX, 2 ; Move to the next element in the array
ADD BX, 2 ; Increment by 2 to account for the word size of each element

ADD BX, AX ; Add the modified number to the accumulator

LOOP LOOP_START ; Repeat for the next element

```

Step 5: Store the final result in the 'RESULT' memory location

```assembly
MOV [RESULT], BX

; Exit the program
MOV AH, 4CH
INT 21H
CODE ENDS
END START
```

Make sure to adjust the memory location for 'RESULT' according to your needs.