Advertisement
Guest User

Untitled

a guest
Apr 7th, 2016
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. .486
  2. .model flat, stdcall
  3. option casemap:none   ; case sensitive
  4.  
  5. ; ####################################################
  6.  
  7. include windows.inc
  8. include user32.inc
  9. include kernel32.inc
  10. include comdlg32.inc
  11. ;include advapi32.inc
  12. ;include masm32.inc
  13.  
  14. includelib user32.lib
  15. includelib kernel32.lib
  16. includelib comdlg32.lib
  17. ;includelib advapi32.lib
  18. ;includelib masm32.lib
  19. ; ####################################################
  20.  
  21.  
  22.  
  23.  
  24. .DATA
  25. dddd db "03/12/2016 20:15:30", 0
  26. eeee db "23/11/2015 21:05:32", 0
  27. ffff db "03/12/2016 20:15:30", 0
  28. fffg db "03/12/2016 20:15:31", 0
  29. .CODE
  30.  
  31. ;
  32. ; accepts two date strings in format "23/11/2016 20:15:30"
  33. ;
  34. ; returns -1 if first comes before second, 0 if equal, 1 if second comes before first
  35. ; just like sorting function for list items needs
  36. ;
  37. CompareDate proc uses esi edi date1:DWORD, date2:DWORD
  38.     mov esi, date1
  39.     mov edi, date2
  40.  
  41.     mov cl, byte ptr [esi+6]
  42.     cmp cl, byte ptr [edi+6]
  43.     jb @exit1
  44.     ja @exitm1
  45.     mov cl, byte ptr [esi+7]
  46.     cmp cl, byte ptr [edi+7]
  47.     jb @exit1
  48.     ja @exitm1
  49.     mov cl, byte ptr [esi+8]
  50.     cmp cl, byte ptr [edi+8]
  51.     jb @exit1
  52.     ja @exitm1
  53.     mov cl, byte ptr [esi+9]
  54.     cmp cl, byte ptr [edi+9]
  55.     jb @exit1
  56.     ja @exitm1
  57.     mov cl, byte ptr [esi+3]
  58.     cmp cl, byte ptr [edi+3]
  59.     jb @exit1
  60.     ja @exitm1
  61.     mov cl, byte ptr [esi+4]
  62.     cmp cl, byte ptr [edi+4]
  63.     jb @exit1
  64.     ja @exitm1
  65.     mov cl, byte ptr [esi+0]
  66.     cmp cl, byte ptr [edi+0]
  67.     jb @exit1
  68.     ja @exitm1
  69.     mov cl, byte ptr [esi+1]
  70.     cmp cl, byte ptr [edi+1]
  71.     jb @exit1
  72.     ja @exitm1
  73.     mov cl, byte ptr [esi+0Bh]
  74.     cmp cl, byte ptr [edi+0Bh]
  75.     jb @exit1
  76.     ja @exitm1
  77.     mov cl, byte ptr [esi+0Ch]
  78.     cmp cl, byte ptr [edi+0Ch]
  79.     jb @exit1
  80.     ja @exitm1
  81.     mov cl, byte ptr [esi+0Eh]
  82.     cmp cl, byte ptr [edi+0Eh]
  83.     jb @exit1
  84.     ja @exitm1
  85.     mov cl, byte ptr [esi+0Fh]
  86.     cmp cl, byte ptr [edi+0Fh]
  87.     jb @exit1
  88.     ja @exitm1
  89.     mov cl, byte ptr [esi+11h]
  90.     cmp cl, byte ptr [edi+11h]
  91.     jb @exit1
  92.     ja @exitm1
  93.     mov cl, byte ptr [esi+12h]
  94.     cmp cl, byte ptr [edi+12h]
  95.     jb @exit1
  96.     ja @exitm1
  97.  
  98.     mov eax, 0
  99.     ret
  100. @exitm1:
  101.     mov eax, -1
  102.     ret
  103. @exit1:
  104.     mov eax, 1
  105.     ret
  106. CompareDate endp
  107.  
  108. start:
  109.     ; just a few tests
  110.     invoke  CompareDate, offset dddd, offset eeee
  111.     invoke  CompareDate, offset eeee, offset ffff
  112.     invoke  CompareDate, offset dddd, offset ffff
  113.     invoke  CompareDate, offset fffg, offset ffff
  114.     invoke  ExitProcess, 0
  115.  
  116. end start
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement