Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Napisati asemblerski program koji proverava da li je uneti string palindrom.
- Program vraća operativnom sistemu 0 ako string nije palindrom, a 1 ako jeste.
- Interakcija sa korisnikom treba da izgleda:
- Unesite string: aca
- Uneti string je palindrom.
- Unesite string: milan
- Uneti string nije palindrom.
- Promenljive za ispis se nalaze u palindrom.S fajlu.
- .section .data
- poruka: .ascii "Unesite string:\0"
- str_lenght1 = . - poruka
- nijep: .ascii "String nije palindrom.\n\0"
- str_lenght2 = . - nijep
- jestep: .ascii "String je palindrom.\n\0"
- str_lenght3 = . - jestep
- unos: .fill 50,1,42
- brojac: .long 0
- konst: .long 2
- .section .text
- .globl main
- main:
- movl $unos, %esi
- ulaz:
- movl $4, %eax
- movl $1, %ebx
- leal poruka, %ecx
- movl $str_lenght1, %edx
- int $0x80
- movl $3, %eax
- movl $0, %ebx
- leal unos, %ecx
- movl $50, %edx
- int $0x80
- movl $unos, %edi
- duzina:
- cmpb $10, (%edi)
- je gotovo
- incl %edi
- incl brojac
- jmp duzina
- gotovo:
- movl $0, %edx
- movl brojac, %eax
- divl konst
- movl %eax, brojac
- nastavi:
- movb (%esi), %cl
- cmpb %cl, -1(%edi)
- je proveri
- jne nije
- jmp nastavi
- jeste:
- movl $4, %eax
- movl $0, %ebx
- leal jestep, %ecx
- movl $str_lenght3, %edx
- int $0x80
- jmp kraj
- nije:
- movl $4, %eax
- movl $1, %ebx
- leal nijep, %ecx
- movl $str_lenght2, %edx
- int $0x80
- jmp kraj
- kraj:
- movl $1, %eax
- int $0x80
- proveri:
- decl brojac
- cmpl $0, brojac
- je jeste
- incl %esi
- decl %edi
- jmp nastavi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement