Advertisement
MichaelPetch

Win32 compare 2 strings MASM32 - v2

Sep 17th, 2022 (edited)
323
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. .386
  2. .model flat, stdcall
  3. option casemap :none
  4.  
  5. include \masm32\include\masm32rt.inc
  6.  
  7. .data
  8. prompt db "Insert string:",0
  9. same_msg db "Both string are the same.",0
  10. diff_msg db "The strings are different.",0
  11. string db 50 dup(?)
  12. string2 db 50 dup(?)
  13.  
  14. .code
  15.  
  16. main:
  17. ; There are prototypes for all the libraries MASM32 supports
  18. ; so we can use invoke to handle all the parameter passing
  19. ; and stack cleanup for us (where necessary)
  20. invoke StdOut, offset prompt
  21. invoke StdIn, offset string, 50
  22.  
  23. invoke StdOut, offset prompt
  24. invoke StdIn, offset string2, 50
  25.  
  26. invoke crt__stricmp, offset string, offset string2
  27. cmp eax, 0 ; You can also use: test eax, eax
  28. jne diff
  29.  
  30. same:
  31. invoke StdOut, offset same_msg
  32. jmp fin ; We want to exit, not to fall into "diff" code
  33.  
  34. diff:
  35. invoke StdOut, offset diff_msg
  36.  
  37. fin:
  38. ret ; Return to exit or do: invoke ExitProcess, 0
  39.  
  40. end main
  41.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement