Palindrome Program Using Assembly Language Code

In this post we will write Palindrome Program Using Assembly Language Code. For basic concept for Palindrome Program please take a look at my previous post “Palindrome Program Using Assembly Language Basic Concept

Please note that the register may not be same as i used in previous post.


start:
LDI R16,0X00
LDI R17,0XFF
LDI R28,0X04 ; 0000 0100
LDI R22,0X10
ldi lsb, 0x0f ;0000 1111
ldi msb, 0xf0; 1111 0000
OUT PORTD, R17
OUT PORTB, R17
OUT PORTC, R17
OUT PORTA, R17
OUT DDRD, R16
OUT DDRB, R17 ; OUTPUT
OUT DDRC, R17 ; OUTPUT
OUT DDRA, R17 ; OUTPUT FOR TEST  UNORDERBITS
forever:
IN r30,PIND
MOV r31,r30
MOV r27,r30 ; r27 is used as unorder to compare final result
And r30,lsb
And r31,msb
MOV r29,r30
SWAP r30              ;swap
MOV r23,r30
MOV r24,r30
MOV r25,r30
MOV r26,r30
LDI R19,0X80 ; 1000 0000
AND r23,r19 ;r35 = 1000 0000
LDI r19,0X40 ; 0100 0000
AND r24,r19 ;r36 = 0100 0000
LDI r19,0X20 ; 0010 0000
AND r25,r19 ;r37 = 0010 0000
LDI r19,0X10 ;0001 0000
AND r26,r19 ;r38 = 0001 0000

; shifting Register
LSR r23  ;0100 0000
LSR r23  ;0010 0000
LSR r23  ;0001 0000
LSR r24 ;0010  0000
LSL R25   ;0100 0000
LSL R26 ; 0010 0000
LSL R26 ; 0100 0000
LSL R26 ; 1000 0000
ADD r23,r24
ADD r23,r25
ADD r23,r26
CP r23,r31
BREQ GOOD
OUT PORTC,R28
JMP END
GOOD:
OUT PORTC,R22
END:
rjmp forever

<PART1         PART3>

Download Files

Let's Discuss