-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path8bit_palindrome.asm
34 lines (26 loc) · 908 Bytes
/
8bit_palindrome.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
; Check for 8 bit Palindrome
;
; input is taken at 0x5000H
; output is stored at 0x5001H
; if palindrome, then output is 0x255H else 0x000H
LXI H, 5000H ; load input
MOV A, M ; move to accumulator
ANI 18H ; selects bits 000b b000
JPO NP ; checks if bits are same
MOV A, M ; reload input to accumulator
ANI 24H ; select bits 00b0 0b00
JPO NP ; checks if bits are same
MOV A, M ; reload input to accumulator
ANI 42H ; select bits 0b00 00b0
JPO NP ; checks if bits are same
MOV A, M ; reload input to accumulator
ANI 81H ; select bits b000 000b
JPO NP ; checks if bits are same
; if no jump, then its palindrome
P: INX H ; move to next address
MVI M, 0FFH ; store it as HIGH
JMP Quit ; jump to end
; if jump, then it's not palindrome
NP: INX H ; move to next address
MVI M, 000H ; store it as LOW
Quit: HLT ; HALT program