Advertisement
Guest User

Untitled

a guest
Jun 10th, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. segment .data
  2.     komunikat db "Podaj łańcuch znaków: ", 0
  3.     format db "%s", 0
  4.     znak db "%c", 0
  5.     spacja db " ", 0
  6.     nl db 10, 0
  7.     tekst times 4096 db 0
  8.  
  9. segment .text
  10.     global  main
  11.     extern printf
  12.     extern scanf
  13.  
  14. main:
  15.     push ebp
  16.     mov ebp, esp
  17.     push komunikat
  18.     call printf
  19.     add esp, 4
  20.     push tekst
  21.     push format
  22.     call scanf
  23.     add esp, 8
  24.     call wypisz_pierwsze
  25.     push spacja
  26.     call printf
  27.     add esp, 4
  28.     call wypisz_ostatnie
  29.     push nl
  30.     call printf
  31.     add esp, 4
  32.     pop ebp
  33.     ret
  34.  
  35. wypisz_pierwsze:
  36.     push ebp
  37.     mov ebp, esp
  38.     mov eax, tekst
  39. .petla:
  40.     cmp byte [eax], 0
  41.     je .petla_koniec
  42.     push eax
  43.     push dword [eax]
  44.     push znak
  45.     call printf
  46.     add esp, 8
  47.     pop eax
  48.     inc eax
  49.     jmp .petla
  50. .petla_koniec:
  51.     pop ebp
  52.     ret
  53.  
  54. wypisz_ostatnie:
  55.     push ebp
  56.     mov ebp, esp
  57.     mov eax, tekst
  58.     xor ebx, ebx
  59.     xor ecx, ecx
  60. .petla1:
  61.     cmp byte [eax], 0
  62.     je .petla1_koniec
  63.     cmp byte [eax], ' '
  64.     je .spacja
  65.     jmp .spacja_koniec
  66. .spacja:
  67.     mov ecx, ebx
  68. .spacja_koniec:
  69.     inc eax
  70.     inc ebx
  71.     jmp .petla1
  72. .petla1_koniec:
  73. break:
  74.     mov eax, tekst
  75.     add eax, ecx
  76. .petla2:
  77.     cmp byte [eax], 0
  78.     je .petla2_koniec
  79.     push eax
  80.     push dword [eax]
  81.     push znak
  82.     call printf
  83.     add esp, 8
  84.     pop eax
  85.     inc eax
  86.     jmp .petla2
  87. .petla2_koniec:
  88.     pop ebp
  89.     ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement