Advertisement
Guest User

Untitled

a guest
Mar 24th, 2019
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. .section .data
  2. poruka: .ascii "Unesite string:\0"
  3. str_lenght1 = . - poruka
  4.  
  5. nijep:  .ascii "String nije palindrom.\n\0"
  6. str_lenght2 = . - nijep
  7.  
  8. jestep: .ascii "String je palindrom.\n\0"
  9. str_lenght3 = . - jestep
  10.  
  11. unos:   .fill 50,1,42
  12.  
  13. brojac: .long 0
  14.  
  15. konst: .long 2
  16. .section .text
  17. .globl main
  18. main:
  19.     movl $unos, %esi
  20.  
  21. ulaz:
  22.     movl $4, %eax
  23.     movl $1, %ebx
  24.     leal poruka, %ecx
  25.     movl $str_lenght1, %edx
  26.     int $0x80
  27.  
  28.     movl $3, %eax
  29.     movl $0, %ebx
  30.     leal unos, %ecx
  31.     movl $50, %edx
  32.     int $0x80
  33.  
  34.     movl $unos, %edi
  35.  
  36.  
  37. duzina:
  38.     cmpb $10, (%edi)
  39.     je gotovo
  40.     incl %edi
  41.     incl brojac
  42.     jmp duzina
  43.  
  44. gotovo:
  45.     movl $0, %edx
  46.     movl brojac, %eax
  47.     divl konst
  48.     movl %eax, brojac
  49.  
  50. nastavi:
  51.     movb (%esi), %cl
  52.     cmpb %cl, -1(%edi)
  53.     je proveri
  54.     jne nije
  55.     jmp nastavi
  56.  
  57. jeste:
  58.     movl $4, %eax
  59.     movl $0, %ebx
  60.     leal jestep, %ecx
  61.     movl $str_lenght3, %edx
  62.     int $0x80
  63.     jmp kraj
  64.  
  65. nije:
  66.     movl $4, %eax
  67.     movl $1, %ebx
  68.     leal nijep, %ecx
  69.     movl $str_lenght2, %edx
  70.     int $0x80
  71.     jmp kraj
  72.  
  73. kraj:
  74.     movl $1, %eax
  75.     int $0x80
  76.  
  77. proveri:
  78.     decl brojac
  79.     cmpl $0, brojac
  80.     je jeste
  81.     incl %esi
  82.     decl %edi
  83.     jmp nastavi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement