Advertisement
Guest User

Untitled

a guest
May 7th, 2019
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. format PE console
  2. entry start
  3. include '../include/win32a.inc'
  4.  
  5. section '.imports'  import data readable
  6.  
  7. library kernel,'kernel32.dll', msvcrt,'msvcrt.dll'
  8.  
  9.  
  10. import kernel, ExitProcess,'ExitProcess'
  11.  
  12. import msvcrt,  printf,'printf' , getchar,'_fgetchar'
  13.  
  14. section '.data'  data readable writable
  15.  
  16. strformat db "%s",0ah,0      ; 0ah for  new line       and  0 for null charchter
  17.  
  18. nameSize dd 5
  19. name db "abcba",0
  20. palindrome db "Palindrome", 0
  21. notPalindrome db "Not palindrome", 0
  22.  
  23. section '.code'   code    readable   executable
  24.  
  25. solve :
  26.       mov eax, 1
  27.       mov ecx, [nameSize]
  28.       push ebx
  29.       mov ebx, 0
  30.       L1 :
  31.          push ebx
  32.          mov bl, [name + ebx]
  33.          cmp [name + ecx - 1], bl
  34.          je elsee
  35.          mov eax, 0
  36.          elsee:
  37.          pop ebx
  38.          inc ebx
  39.          loop L1
  40.       pop ebx
  41.       ret
  42.  
  43. start:
  44.         call solve
  45.         cmp eax, 1
  46.         jne notPal
  47.         invoke printf, strformat, palindrome
  48.         jmp Pal
  49.         notPal: invoke printf, strformat, notPalindrome
  50.         Pal:
  51.  
  52.         invoke getchar                       ; wait for any key
  53.         invoke ExitProcess, 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement