Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #spajanje 2 stringa
- .section .data
- poruka1: .ascii "Unesite string 1:\0"
- len1 = .-poruka1
- poruka2: .ascii "Unesite string 2:\0"
- len2 = .-poruka2
- poruka3: .ascii "Spojeno:\0"
- len3 = .-poruka3
- max1 = 20
- max2 = 20
- spojmax = max1+max2
- str1: .fill spojmax, 1, 42
- str2: .fill max2, 1, 42
- str1_len: .long 0
- str2_len: .long 0
- .section .text
- .globl main
- main:
- movl $4, %eax
- movl $1, %ebx
- leal poruka1, %ecx
- movl $len1, %edx
- int $0x80 #ispisuje "Unesite string 1: "
- movl $3, %eax
- movl $0, %ebx
- leal str1, %ecx
- movl $max1, %edx
- int $0x80 #upisuje prvi string
- decl %eax #smanjujemo duzinu za 1 zbog NULL-a
- movl %eax, str1_len
- movl $4, %eax
- movl $1, %ebx
- leal poruka2, %ecx
- movl $len2, %edx
- int $0x80 #ispisuje "Unesite string 2: "
- movl $3, %eax
- movl $0, %ebx
- leal str2, %ecx
- movl $max2, %edx
- int $0x80 #upisuje drugi string
- movl %eax, str2_len
- spoj:
- movl $0, %esi
- movl str1_len, %edi
- petlja:
- cmpl str2_len, %esi
- je ispis
- movb str2(,%esi,1), %al
- movb %al, str1(, %edi,1)
- incl %esi
- incl %edi
- jmp petlja
- ispis:
- movl %edi, str1_len
- movl $4, %eax
- movl $1, %ebx
- leal poruka3, %ecx
- movl $len3, %edx
- int $0x80 #ispisuje "Spojeno: "
- movl $4, %eax
- movl $1, %ebx
- leal str1, %ecx
- movl str1_len, %edx
- int $0x80 #ispisuje spojeni string
- kraj:
- movl $1, %eax
- movl $0, %ebx
- int $0x80
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement