-
Notifications
You must be signed in to change notification settings - Fork 0
/
Check_palidrome.asm
79 lines (50 loc) · 963 Bytes
/
Check_palidrome.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
;a string will be give and have to check if it is a palidrome
;check palidrome without using any
;"loop" , "ret" command
;must have to use stack and function
;can use either 'si' or 'di' register
;if palidrome make dx=1 else dx=0
org 100h
.data
str db 'pritommotirp'
len equ ($-str)
check db 0
.code
jmp start
end_code:
hlt ;using 'hlt' for halting program
start:
mov si,offset str
mov cx,len
stack: ;this is for pushing the
push [si] ;string in stack
inc si
dec cx
cmp cx,0
jg stack
mov si,offset str
mov cx,len
com: ;comparing the string
pop ax
mov bx,[si]
inc si
cmp bl,al
je up
con:
dec cx
cmp cx,0
jg com
cmp check,len
je equal
jne note
equal: ;if palidrome it will exicute
mov dx,1
jmp endc
note: ;if not palidrome it will exicute
mov dx,0
jmp endc
up:
inc check
jmp con:
endc:
jmp end_code