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.

125 lines
2.3 KiB

  1. // TITLE("Byte Swap Functions")
  2. //++
  3. //
  4. // Copyright (c) 1998 Intel Corporation
  5. // Copyright (c) 1997 Microsoft Corporation
  6. //
  7. // Module Name:
  8. //
  9. // byteswap.s
  10. //
  11. // Abstract:
  12. //
  13. // This module implements functions to perform byte swapping operations.
  14. //
  15. // Author:
  16. //
  17. // William Cheung (v-willc) 30-Nov-1998
  18. //
  19. // Environment:
  20. //
  21. // User or Kernel mode.
  22. //
  23. // Revision History:
  24. //
  25. //--
  26. #include "ksia64.h"
  27. SBTTL("RtlUshortByteSwap")
  28. //++
  29. //
  30. // USHORT
  31. // RtlUshortByteSwap(
  32. // IN USHORT Source
  33. // )
  34. //
  35. // Routine Description:
  36. //
  37. // The RtlUshortByteSwap function exchanges bytes 0 and 1 of Source
  38. // and returns the resulting USHORT.
  39. //
  40. // Arguments:
  41. //
  42. // Source (a0[0..15]) - 16-bit value to byteswap.
  43. //
  44. // Return Value:
  45. //
  46. // The 16-bit integer result is returned as the function value
  47. // in v0[0..15].
  48. //
  49. //--
  50. LEAF_ENTRY(RtlUshortByteSwap)
  51. shl t0 = a0, 48
  52. ;;
  53. mux1 v0 = t0, @rev
  54. br.ret.sptk brp
  55. LEAF_EXIT(RtlUshortByteSwap)
  56. SBTTL("RtlUlongByteSwap")
  57. //++
  58. //
  59. // ULONG
  60. // RtlUlongByteSwap(
  61. // IN ULONG Source
  62. // )
  63. //
  64. // Routine Description:
  65. //
  66. // The RtlUlongByteSwap function exchanges byte pairs 0:3 and 1:2 of
  67. // Source and returns the the resulting ULONG.
  68. //
  69. // Arguments:
  70. //
  71. // Source (a0[0..31]) - 32-bit value to byteswap.
  72. //
  73. // Return Value:
  74. //
  75. // The 32-bit integer result is returned as the function value
  76. // in v0[0..31].
  77. //
  78. //--
  79. LEAF_ENTRY(RtlUlongByteSwap)
  80. shl t0 = a0, 32
  81. ;;
  82. mux1 v0 = t0, @rev
  83. br.ret.sptk brp
  84. LEAF_EXIT(RtlUlongByteSwap)
  85. SBTTL("RtlUlonglongByteSwap")
  86. //++
  87. //
  88. // ULONG
  89. // RtlUlonglongByteSwap(
  90. // IN ULONGLONG Source
  91. // )
  92. //
  93. // /*++
  94. //
  95. // Routine Description:
  96. //
  97. // The RtlUlonglongByteSwap function exchanges byte pairs 0:7, 1:6, 2:5,
  98. // and 3:4 of Source and returns the resulting ULONGLONG.
  99. //
  100. // Arguments:
  101. //
  102. // Source (a0[0..63]) - 64-bit value to byteswap.
  103. //
  104. // Return Value:
  105. //
  106. // Swapped 64-bit value.
  107. //
  108. //--
  109. LEAF_ENTRY(RtlUlonglongByteSwap)
  110. mux1 v0 = a0, @rev
  111. br.ret.sptk brp
  112. LEAF_EXIT(RtlUlonglongByteSwap)