Advertisement
anja99

Untitled

Mar 25th, 2019
578
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. #spajanje 2 stringa
  2.  
  3. .section .data
  4.  
  5. poruka1: .ascii "Unesite string 1:\0"
  6. len1 = .-poruka1
  7. poruka2: .ascii "Unesite string 2:\0"
  8. len2 = .-poruka2
  9. poruka3: .ascii "Spojeno:\0"
  10. len3 = .-poruka3
  11.  
  12. max1 = 20
  13. max2 = 20
  14. spojmax = max1+max2
  15.  
  16. str1: .fill spojmax, 1, 42
  17. str2: .fill max2, 1, 42
  18.  
  19. str1_len: .long 0
  20. str2_len: .long 0
  21.  
  22. .section .text
  23. .globl main
  24.  
  25. main:
  26. movl $4, %eax
  27. movl $1, %ebx
  28. leal poruka1, %ecx
  29. movl $len1, %edx
  30. int $0x80 #ispisuje "Unesite string 1: "
  31.  
  32. movl $3, %eax
  33. movl $0, %ebx
  34. leal str1, %ecx
  35. movl $max1, %edx
  36. int $0x80 #upisuje prvi string
  37.  
  38. decl %eax #smanjujemo duzinu za 1 zbog NULL-a
  39. movl %eax, str1_len
  40.  
  41. movl $4, %eax
  42. movl $1, %ebx
  43. leal poruka2, %ecx
  44. movl $len2, %edx
  45. int $0x80 #ispisuje "Unesite string 2: "
  46.  
  47. movl $3, %eax
  48. movl $0, %ebx
  49. leal str2, %ecx
  50. movl $max2, %edx
  51. int $0x80 #upisuje drugi string
  52.  
  53. movl %eax, str2_len
  54.  
  55. spoj:
  56. movl $0, %esi
  57. movl str1_len, %edi
  58. petlja:
  59.  
  60. cmpl str2_len, %esi
  61. je ispis
  62. movb str2(,%esi,1), %al
  63. movb %al, str1(, %edi,1)
  64. incl %esi
  65. incl %edi
  66. jmp petlja
  67.  
  68.  
  69. ispis:
  70. movl %edi, str1_len
  71.  
  72. movl $4, %eax
  73. movl $1, %ebx
  74. leal poruka3, %ecx
  75. movl $len3, %edx
  76. int $0x80 #ispisuje "Spojeno: "
  77.  
  78. movl $4, %eax
  79. movl $1, %ebx
  80. leal str1, %ecx
  81. movl str1_len, %edx
  82. int $0x80 #ispisuje spojeni string
  83.  
  84. kraj:
  85. movl $1, %eax
  86. movl $0, %ebx
  87. int $0x80
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement