Advertisement
ze3leX

Untitled

Mar 23rd, 2019
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. .section .data
  2. ulazni_tekst: .ascii "Unesite neku rec:"
  3. ulazni_tekst_len = .-ulazni_tekst
  4.  
  5.  
  6. str1: .fill 50,1,42
  7. str1_len = 50
  8.  
  9. str2: .fill 50,1,42
  10.  
  11. .section .text
  12. .global main
  13. main:
  14. #ispisuje Unesite Neku rec:
  15. movl $4, %eax
  16. movl $1, %ebx
  17. leal ulazni_tekst, %ecx
  18. movl $ulazni_tekst_len, %edx
  19. int $0x80
  20.  
  21. #upisivanje reci
  22. movl $3, %eax
  23. movl $0, %ebx
  24. leal str1, %ecx
  25. movl $str1_len, %edx
  26. int $0x80
  27.  
  28. movl %eax, %esi #stavljanje duzine niza u esi
  29. movl %esi, %edi #treba kasnije kad ispisuje
  30. decl %edi #jer je uracunato i \n
  31. leal str1, %eax #adresa string u eax
  32. addl %esi, %eax #pomera pokazivac za esi mesto tj, do kraja stringa i sad pokazuje iza \n
  33. decl %eax #sad pokazuje na \n
  34. leal str2, %ebx #adresa stringa gde stavljamo
  35.  
  36. prebaci:
  37. decl %eax
  38. decl %esi
  39.  
  40. cmpl $0, %esi
  41. je ispis
  42.  
  43. movb (%eax), %cl
  44. movb %cl, (%ebx)
  45. incl %ebx
  46.  
  47. jmp prebaci
  48.  
  49. ispis:
  50.  
  51. movl $4, %eax
  52. movl $1, %ebx
  53. leal str2, %ecx
  54. movl %edi, %edx
  55. int $0x80
  56.  
  57.  
  58.  
  59. kraj:
  60. movl $1, %eax
  61. movl $0, %ebx
  62. int $0x80
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement