-
Notifications
You must be signed in to change notification settings - Fork 111
/
palindrome.masm
50 lines (40 loc) · 1.08 KB
/
palindrome.masm
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
section .text
global _start
_start:
mov ecx, string
mov edx, length
mov ebx, 1
mov eax, 4
int 0x80
mov ebx, string
mov eax, (string + length - 1)
mov ecx, (length / 2)
check:
mov dl, [ebx]
cmp [eax], dl
jne failure
inc ebx
dec eax
loop check
;; success
mov ecx, msg1
mov edx, length1
mov ebx, 1
mov eax, 4
int 0x80
jmp done
failure:
mov ecx, msg2
mov edx, length2
mov ebx, 1
mov eax, 4
int 0x80
done:
ret
section .data
string db "malayalam"
length equ $ - string
msg1 db " is pallindrome",0
length1 equ $ - msg1
msg2 db " is not pallindrome",0
length2 equ $ - msg2