Please use Assembly Language
Write a program to reverse the contents of an array of 5 unsigned 8-bit numbers starting at location $4000. For example, if your initial array values read 2, 4, 3, 6, 1 they must read 1, 6, 3, 4, 2 after you execute your program.
Expert Answer
Here is the coding segment as per the given condition, please have a look:-
DATA SEGMENT
DATA1 DB 01H,02H,05H,03H,04H
DATA2 DB 5 DUP(?)
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE, DS:DATA
START:
MOV EAX, 4000H ; initial condition
MOV AX, DATA ; loading data
MOV DS, AX
LEA SI, DATA1 ; accessing each data
LEA DI, DATA2+2 ; accessing next INT data.. 2 bytes aheaed
MOV CX, 05H
REVERSE: CLD ; start iterates from reverse order..
; if zero returns.. then exits loop
MOV AL, [SI] ; storing reverse element data
MOV [DI], AL
INC SI ; incrementing next location in temp array
DEC DI ; decrementing original array.. as we are looping from backside
DEC CX
JNZ REVERSE ; calling routine recursively
INT 3
CODE ENDS
END START