Write a program that uses the register a to rearrange the fo
Write a program that uses the register a, to rearrange the four word values in the following array as 4. 3. 1. .data array W WORD 1, 2, 3, 4 To display the reversed array, please move the array elements into ax, bx, cx, dx.
Solution
DATA SEGMENT
ARR DB 4,1,2,3
LEN DW $-ARR
DATA ENDS
CODE SEGMENT
ASSUME DS:DATA CS:CODE
START:
MOV AX,DATA
MOV DS,AX
MOV CX,LEN-1
OUTER:
LEA SI,ARR
MOV BX,0
INNER:
INC BX
MOV AL,ARR[SI]
INC SI
CMP ARR[SI],AL
JB SKIP
XCHG AL,ARR[SI]
MOV ARR[SI-1],AL
SKIP:
CMP BX,CX
JL INNER
LOOP OUTER
MOV AH,4CH
INT 21H
CODE ENDS
END START
