Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

102 lines
2.2 KiB

  1. title "Interlocked Support"
  2. ;++
  3. ;
  4. ; Copyright (c) 1996 Microsoft Corporation
  5. ;
  6. ; Module Name:
  7. ;
  8. ; slist.asm
  9. ;
  10. ; Abstract:
  11. ;
  12. ; This module implements functions to support interlocked S-List
  13. ; operations.
  14. ;
  15. ; Author:
  16. ;
  17. ; David N. Cutler (davec) 13-Mar-1996
  18. ;
  19. ; Environment:
  20. ;
  21. ; Any mode.
  22. ;
  23. ; Revision History:
  24. ;
  25. ;--
  26. .386p
  27. .xlist
  28. include ks386.inc
  29. include callconv.inc ; calling convention macros
  30. include mac386.inc
  31. .list
  32. _TEXT$00 SEGMENT DWORD PUBLIC 'CODE'
  33. ASSUME DS:FLAT, ES:FLAT, SS:NOTHING, FS:NOTHING, GS:NOTHING
  34. ;++
  35. ;
  36. ; LONG64
  37. ; FASTCALL
  38. ; xInterlockedCompareExchange64 (
  39. ; IN OUT PLONG64 Destination,
  40. ; IN PLONG64 Exchange,
  41. ; IN PLONG64 Comperand
  42. ; )
  43. ;
  44. ; Routine Description:
  45. ;
  46. ; This function performs a compare and exchange of 64-bits.
  47. ;
  48. ; Arguments:
  49. ;
  50. ; (ecx) Destination - Supplies a pointer to the destination variable.
  51. ;
  52. ; (edx) Exchange - Supplies a pointer to the exchange value.
  53. ;
  54. ; (esp+4) Comperand - Supplies a pointer to the comperand value.
  55. ;
  56. ; Return Value:
  57. ;
  58. ; The current destination value is returned as the function value.
  59. ;
  60. ;--
  61. cPublicFastCall xInterlockedCompareExchange64, 3
  62. cPublicFpo 0,2
  63. ;
  64. ; Save nonvolatile registers and read the exchange and comperand values.
  65. ;
  66. push ebx ; save nonvolatile registers
  67. push ebp ;
  68. mov ebp, ecx ; set destination address
  69. mov ebx, [edx] ; get exchange value
  70. mov ecx, [edx] + 4 ;
  71. mov edx, [esp] + 12 ; get comperand address
  72. mov eax, [edx] ; get comperand value
  73. mov edx, [edx] + 4 ;
  74. .586
  75. lock cmpxchg8b qword ptr [ebp] ; compare and exchange
  76. .386
  77. ;
  78. ; Restore nonvolatile registers and return result in edx:eax.
  79. ;
  80. cPublicFpo 0,0
  81. pop ebp ; restore nonvolatile registers
  82. pop ebx ;
  83. fstRET xInterlockedCompareExchange64
  84. fstENDP xInterlockedCompareExchange64
  85. _TEXT$00 ends
  86. end