Write an ALP to check whether the given 16-bit number stored at 5000H location is palindrome or not. If number is palindrome then store number at 5100H location otherwise store at 5200H location.

Code:- 

org 100h

 

MOV SI , 5000H

MOV DI , 5004H

MOV CL , 05H

 

next_char:

    MOV AL , [DI]

    MOV BL , [SI]

    CMP AL , BL

    JNE not_palindrome ; jump not equal to not_palindrome

    INC SI

    DEC DI

LOOP next_char

 

is_palindrome:

    MOV CX,05H

    MOV SI , 5000H

    MOV DI , 5100H

    L1:

    MOV AX,[SI]

    INC SI

    MOV [DI],AX

    INC DI

LOOP L1

 

    INT 21H

                

 

not_palindrome:

   

    MOV CX,05H 

    MOV SI , 5000H

    MOV DI , 5200H

    L2:

    MOV AX,[SI]

    INC SI

    MOV [DI],AX

    INC DI

LOOP L2

   

    INT 21H

ret

 

OUTPUT :-







Number is palindrome :



 


Output 2 :-





Number is not  palindrome :









Comments

Popular Posts

What is Tinkercad ? How to use Tinkercad ?

Connect switch to Arduino. If switch is on than print ”ON” else print “OFF” on serial monitor.

Set the time using four switch and display the clock on LCD using arduino ** SW1 : when press, increment 1 digit ** SW2 : when press, decrement 1 digit ** SW3 : when press, display set time and start the clock ** SW4 : when press, reset the clock