DATA SEGMENT
BUF DB 255,0,255 DUP(0)
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
MAIN:
MOV AX,DATA
MOV DS,AX
LEA DX,BUF
MOV SI,DX;
MOV DI,DX
MOV AH,10
INT 21H
MOV AL,13
MOV AH,2
INT 21H
MOV DL,10
INT 21H
MOV CL,0
MOV CL,[SI+1]
AND CX,00FFH
ADD SI,2
MOV DI,CX
ADD DI,SI
MOV BYTE PTR[DI+1],'$'
SHR CX,1
LAB:
MOV AL,[SI]
XCHG AL,[DI]
MOV [SI],AL
INC SI
DEC DI
LOOP LAB
MOV DL,0DH
MOV AH,2
INT 21H
MOV DL,0AH
INT 21H
LEA DX,BUF
ADD DX,2
MOV AH,9
INT 21H
MOV AH,4CH
INT 21H
ENDS CODE
END MAIN
BUF DB 255,0,255 DUP(0)
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
MAIN:
MOV AX,DATA
MOV DS,AX
LEA DX,BUF
MOV SI,DX;
MOV DI,DX
MOV AH,10
INT 21H
MOV AL,13
MOV AH,2
INT 21H
MOV DL,10
INT 21H
MOV CL,0
MOV CL,[SI+1]
AND CX,00FFH
ADD SI,2
MOV DI,CX
ADD DI,SI
MOV BYTE PTR[DI+1],'$'
SHR CX,1
LAB:
MOV AL,[SI]
XCHG AL,[DI]
MOV [SI],AL
INC SI
DEC DI
LOOP LAB
MOV DL,0DH
MOV AH,2
INT 21H
MOV DL,0AH
INT 21H
LEA DX,BUF
ADD DX,2
MOV AH,9
INT 21H
MOV AH,4CH
INT 21H
ENDS CODE
END MAIN