Advertisement
Guest User

probl5

a guest
Nov 22nd, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. bits 32
  2. global start        
  3.  
  4. extern exit, printf, scanf
  5. import exit msvcrt.dll
  6. import printf msvcrt.dll
  7. import scanf msvcrt.dll
  8.  
  9. segment data use32 class=data
  10.     ; ...
  11.     sir db "cojoc ana are un cojoc frumos si un capac z b tanat iei barba iearbaabraei ", 0
  12.     lsir equ $-sir-1
  13.     sirDest times lsir db 0
  14.     pozSirDest dd 0
  15.     pozSir dd 0
  16.     aux db 0
  17.     formatSir1 db "Sirul contine: %s", 0
  18.     formatSir2 db `\nCuvintele palindroame sunt: %s`, 0
  19. ; segmentul de cod
  20. segment code use32 class=code
  21.     start:
  22.         ; ...
  23.         mov ecx, lsir
  24.         mov esi, sir
  25.         mov edi, sir
  26.         jecxz finalCautare
  27.             repeta:
  28.                 lodsb
  29.                 cmp al, 20h
  30.                 jz foundSpace
  31.                 loop repeta
  32.                 foundSpace:
  33.                 push ecx
  34.                 mov [pozSir], esi
  35.                 sub esi, 2
  36.                 mov ecx, esi
  37.                 sub ecx, edi
  38.                 mov edx, ecx
  39.                 comparaCarac:
  40.                     cmpsb
  41.                     jnz afara
  42.                     sub esi, 2
  43.                 loop comparaCarac
  44.                 mov ecx, edx
  45.                 inc ecx
  46.                 push edi
  47.                     mov edi, sirDest
  48.                     add edi, [pozSirDest]
  49.                 putCarac:
  50.                     movsb
  51.                 loop putCarac
  52.                 mov al, 20h
  53.                 push esi
  54.                 mov esi, edi
  55.                 stosb
  56.                 pop esi
  57.                 add [pozSirDest], edx
  58.                 add [pozSirDest], dword 2
  59.                 pop edi
  60.                 afara:
  61.                 pop ecx
  62.                 mov edi, [pozSir]
  63.                 mov esi, [pozSir]
  64.             loop repeta
  65.         finalCautare:
  66.        
  67.         push sir
  68.         push formatSir1
  69.         call [printf]
  70.         add esp, 4*2
  71.         push sirDest
  72.         push formatSir2
  73.         call [printf]
  74.         add esp, 4*2
  75.            
  76.         finalPr:
  77.         ; exit(0)
  78.         push    dword 0      ; push the parameter for exit onto the stack
  79.         call    [exit]       ; call exit to terminate the program
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement