Advertisement
DMG

Palindrom

DMG
Nov 5th, 2014
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # Program provjerava da li je rijec palindrom
  2. # autor: dmarjanovic
  3.  
  4. .section .data
  5.     string: .ascii "anavolimilovana\0"
  6. .section .text
  7. .globl main
  8.  
  9. main:
  10.     movl $0, %esi
  11.  
  12. for_length:
  13.     cmpb $0, string(,%esi,1)
  14.     je continue
  15.  
  16.     incl %esi
  17.     jmp for_length
  18.  
  19. continue:
  20.     decl %esi
  21.     movl $0, %eax
  22.  
  23. for_cmp:
  24.     cmpl %esi, %eax
  25.     je its_palindrome
  26.  
  27.     movb string(,%eax,1), %bl
  28.     cmpb string(,%esi,1), %bl
  29.     jne not_palindrome
  30.  
  31.     incl %eax
  32.     decl %esi
  33.  
  34.     jmp for_cmp
  35.  
  36. its_palindrome:
  37.     movl $2, %eax
  38.     jmp end
  39.  
  40. not_palindrome:
  41.     movl $-2, %eax
  42.  
  43. end:
  44.     movl $1, %eax
  45.     int $0x80
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement