REVERSE.ASM 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. ;
  2. ; Command & Conquer Red Alert(tm)
  3. ; Copyright 2025 Electronic Arts Inc.
  4. ;
  5. ; This program is free software: you can redistribute it and/or modify
  6. ; it under the terms of the GNU General Public License as published by
  7. ; the Free Software Foundation, either version 3 of the License, or
  8. ; (at your option) any later version.
  9. ;
  10. ; This program is distributed in the hope that it will be useful,
  11. ; but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ; GNU General Public License for more details.
  14. ;
  15. ; You should have received a copy of the GNU General Public License
  16. ; along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. ;
  18. ; $Header: g:/library/wwlib32/misc/rcs/reverse.asm 1.3 1994/04/25 12:22:45 scott_bowen Exp $
  19. ;***************************************************************************
  20. ;** C O N F I D E N T I A L --- W E S T W O O D A S S O C I A T E S **
  21. ;***************************************************************************
  22. ;* *
  23. ;* Project Name : LIBRARY *
  24. ;* *
  25. ;* File Name : REVERSE.ASM *
  26. ;* *
  27. ;* Programmer : Christopher Yates *
  28. ;* *
  29. ;* Last Update : April 20, 1994 [SKB] *
  30. ;* *
  31. ;*-------------------------------------------------------------------------*
  32. ;* Functions: *
  33. ;* *
  34. ; LONG Reverse_Long(LONG number); *
  35. ; WORD Reverse_Short(WORD number); *
  36. ; LONG Swap_LONG(LONG number);
  37. ;* *
  38. ;* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
  39. IDEAL
  40. P386
  41. MODEL USE32 FLAT
  42. GLOBAL C Reverse_Short :NEAR
  43. GLOBAL C Swap_Long :NEAR
  44. GLOBAL C Reverse_Long :NEAR
  45. CODESEG
  46. ; ----------------------------------------------------------------
  47. ;
  48. ; Here are prototypes for the routines defined within this module:
  49. ;
  50. ; LONG Reverse_LONG(LONG number);
  51. ; WORD Reverse_Short(WORD number);
  52. ; LONG Swap_LONG(LONG number);
  53. ;
  54. ; ----------------------------------------------------------------
  55. ;-----------------------------------------------------------------
  56. ;
  57. ; REVERSE_LONG
  58. ;
  59. ; LONG Reverse_LONG(LONG number);
  60. ;
  61. ;*
  62. PROC Reverse_Long C near
  63. ARG number:DWORD
  64. IF 1
  65. mov eax,[DWORD PTR number]
  66. xchg al,ah
  67. ror eax,16
  68. xchg al,ah
  69. ELSE
  70. ; This is old 16 bit code.
  71. mov ax,[WORD PTR number]
  72. mov dx,[WORD PTR number+2]
  73. xchg ah,dl
  74. xchg al,dh
  75. ENDIF
  76. ret
  77. ENDP Reverse_Long
  78. ;-----------------------------------------------------------------
  79. ;-----------------------------------------------------------------
  80. ;
  81. ; REVERSE_WORD
  82. ;
  83. ; WORD Reverse_Short(WORD number);
  84. ;
  85. ;*
  86. PROC Reverse_Short C near
  87. ARG number:WORD
  88. mov ax,[number]
  89. xchg ah,al
  90. ret
  91. ENDP Reverse_Short
  92. ;-----------------------------------------------------------------
  93. ;-----------------------------------------------------------------
  94. ;
  95. ; SWAP_Long
  96. ;
  97. ; Long Swap_Long(Long number);
  98. ;
  99. ;*
  100. PROC Swap_Long C near
  101. ARG number:DWORD
  102. IF 1
  103. ; 32 bit code.
  104. mov eax,[DWORD PTR number]
  105. ror eax,16
  106. ELSE
  107. ; 16 bit code.
  108. mov ax,[WORD PTR number+2]
  109. mov dx,[WORD PTR number]
  110. ENDIF
  111. ret
  112. ENDP Swap_Long
  113. ;-----------------------------------------------------------------
  114. END
  115.