Source code of Windows XP (NT5)
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.

165 lines
2.4 KiB

  1. title "Byte Swap Functions"
  2. ;++
  3. ;
  4. ; Copyright (c) 1997 Microsoft Corporation
  5. ;
  6. ; Module Name:
  7. ;
  8. ; movemem.asm
  9. ;
  10. ; Abstract:
  11. ;
  12. ; This module implements functions to perform byte swapping operations.
  13. ;
  14. ;
  15. ; Author:
  16. ;
  17. ; Forrest Foltz (forrestf) 12-Dec-1997
  18. ;
  19. ; Environment:
  20. ;
  21. ; User or Kernel mode.
  22. ;
  23. ; Revision History:
  24. ;
  25. ;--
  26. .486p
  27. .xlist
  28. include ks386.inc
  29. include callconv.inc ; calling convention macros
  30. .list
  31. ;
  32. ; Alignment for functions in this module
  33. ;
  34. CODE_ALIGNMENT macro
  35. align 16
  36. endm
  37. _TEXT$00 SEGMENT PARA PUBLIC 'CODE'
  38. ASSUME DS:FLAT, ES:FLAT, SS:NOTHING, FS:NOTHING, GS:NOTHING
  39. PAGE
  40. SUBTTL "RtlUshortByteSwap"
  41. ;++
  42. ;
  43. ; USHORT
  44. ; RtlUshortByteSwap(
  45. ; IN USHORT Source
  46. ; )
  47. ;
  48. ; /*++
  49. ;
  50. ; Routine Description:
  51. ;
  52. ; The RtlfUshortByteSwap function exchanges bytes 0 and 1 of Source
  53. ; and returns the resulting USHORT.
  54. ;
  55. ; Arguments:
  56. ;
  57. ; (cx) Source - 16-bit value to byteswap.
  58. ;
  59. ; Return Value:
  60. ;
  61. ; Swapped 16-bit value.
  62. ;
  63. ;--
  64. CODE_ALIGNMENT
  65. cPublicFastCall RtlUshortByteSwap ,1
  66. cPublicFpo 0, 0
  67. mov ah, cl
  68. mov al, ch
  69. fstRET RtlUshortByteSwap
  70. fstENDP RtlUshortByteSwap
  71. PAGE
  72. SUBTTL "RtlUlongByteSwap"
  73. ;++
  74. ;
  75. ; ULONG
  76. ; RtlUlongByteSwap(
  77. ; IN ULONG Source
  78. ; )
  79. ;
  80. ; /*++
  81. ;
  82. ; Routine Description:
  83. ;
  84. ; The RtlUlongByteSwap function exchanges byte pairs 0:3 and 1:2 of
  85. ; Source and returns the the resulting ULONG.
  86. ;
  87. ; Arguments:
  88. ;
  89. ; (ecx) Source - 32-bit value to byteswap.
  90. ;
  91. ; Return Value:
  92. ;
  93. ; Swapped 32-bit value.
  94. ;
  95. ;--
  96. CODE_ALIGNMENT
  97. cPublicFastCall RtlUlongByteSwap ,1
  98. cPublicFpo 0, 0
  99. mov eax, ecx
  100. bswap eax
  101. fstRET RtlUlongByteSwap
  102. fstENDP RtlUlongByteSwap
  103. PAGE
  104. SUBTTL "RtlUlonglongByteSwap"
  105. ;++
  106. ;
  107. ; ULONG
  108. ; RtlUlonglongByteSwap(
  109. ; IN ULONGLONG Source
  110. ; )
  111. ;
  112. ; /*++
  113. ;
  114. ; Routine Description:
  115. ;
  116. ; The RtlUlonglongByteSwap function exchanges byte pairs 0:7, 1:6, 2:5,
  117. ; and 3:4 of Source and returns the resulting ULONGLONG.
  118. ;
  119. ; Arguments:
  120. ;
  121. ; (esp + 4) Source - Low half of 64-bit value to byteswap.
  122. ;
  123. ; (esp + 8) Source - High half of 64-bit value to byteswap.
  124. ;
  125. ; Return Value:
  126. ;
  127. ; Swapped 64-bit value.
  128. ;
  129. ;--
  130. CODE_ALIGNMENT
  131. cPublicFastCall RtlUlonglongByteSwap ,2
  132. cPublicFpo 0, 0
  133. mov edx, [esp + 8]
  134. mov eax, [esp + 4]
  135. bswap edx
  136. bswap eax
  137. mov ecx, eax
  138. mov eax, edx
  139. mov edx, ecx
  140. fstRET RtlUlonglongByteSwap
  141. fstENDP RtlUlonglongByteSwap
  142. _TEXT$00 ends
  143. end