MY_DATA SEGMENT
X DW MY_NUMBER
MSG1 DB 'NUMBER IS A PALINDRONE'
MSG2 DB 'NUMBER IS NOT A PALINDRONE'
MY_DATA ENDS
CODE SEGMENT
ASSUME CS:CODE, DS:MY_DATA
START:
MOV AX, MY_DATA
MOV DS, AX
; THE AOVE 2 STTEMNETS INITILISE THE DATA SEGMENT
MOV CL, 10H ; AS DOUBLE WORD IS 16 BITS
UP:
ROR AX, 1
; ROTATE RIGHT ONE TIME
RCL DX, 1
; ROTATE LEFT WITH CARRY ONE TIME
LOOP UP
; TILL COUNTER GOES TO 0
CMP AX, DX
JNZ NOPALIN
; NO ZERO MEANS NOT A PALINDRONE SO DECLARE THAT
LEA DX, MSG1
; DECLARE AS PALINDRONE IF ZERO
; IF USING TASM WRITE THESE TWO LINES
MOV AH, 09H
INT 21H
JMP EXIT
NOPALIN:
LEA DX, MSG2
; DECLARE NOT A PALINDRONE
; IF USING TASM WRITE BELOW TWO LINES
MOV AH, 09H
INT 21H
EXIT:
; IF USING TASM WRITE THESE TWO LINES TO END
MOV AH, 4CH
INT 21H
CODE ENDS
END
X DW MY_NUMBER
MSG1 DB 'NUMBER IS A PALINDRONE'
MSG2 DB 'NUMBER IS NOT A PALINDRONE'
MY_DATA ENDS
CODE SEGMENT
ASSUME CS:CODE, DS:MY_DATA
START:
MOV AX, MY_DATA
MOV DS, AX
; THE AOVE 2 STTEMNETS INITILISE THE DATA SEGMENT
MOV CL, 10H ; AS DOUBLE WORD IS 16 BITS
UP:
ROR AX, 1
; ROTATE RIGHT ONE TIME
RCL DX, 1
; ROTATE LEFT WITH CARRY ONE TIME
LOOP UP
; TILL COUNTER GOES TO 0
CMP AX, DX
JNZ NOPALIN
; NO ZERO MEANS NOT A PALINDRONE SO DECLARE THAT
LEA DX, MSG1
; DECLARE AS PALINDRONE IF ZERO
; IF USING TASM WRITE THESE TWO LINES
MOV AH, 09H
INT 21H
JMP EXIT
NOPALIN:
LEA DX, MSG2
; DECLARE NOT A PALINDRONE
; IF USING TASM WRITE BELOW TWO LINES
MOV AH, 09H
INT 21H
EXIT:
; IF USING TASM WRITE THESE TWO LINES TO END
MOV AH, 4CH
INT 21H
CODE ENDS
END