PORTIO.ASM 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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. ;****************************************************************************
  19. ;*
  20. ;* C O N F I D E N T I A L -- W E S T W O O D S T U D I O S
  21. ;*
  22. ;*---------------------------------------------------------------------------
  23. ;*
  24. ;* FILE
  25. ;* portio.asm
  26. ;*
  27. ;* DESCRIPTION
  28. ;* I/O Port access. (32-Bit protected mode)
  29. ;*
  30. ;* PROGRAMMER
  31. ;* Denzil E. Long, Jr.
  32. ;*
  33. ;* DATE
  34. ;* January 26, 1995
  35. ;*
  36. ;*---------------------------------------------------------------------------
  37. ;*
  38. ;* PUBLIC
  39. ;* inp - Read a byte from a hardware port.
  40. ;* outp - Write a byte to a hardware port.
  41. ;*
  42. ;****************************************************************************
  43. IDEAL
  44. P386
  45. MODEL USE32 FLAT
  46. LOCALS ??
  47. CODESEG
  48. ;****************************************************************************
  49. ;*
  50. ;* NAME
  51. ;* inp - Read a byte from a hardware port.
  52. ;*
  53. ;* SYNOPSIS
  54. ;* Data = inp(PortID)
  55. ;*
  56. ;* short inp(unsinged short);
  57. ;*
  58. ;* FUNCTION
  59. ;*
  60. ;* INPUTS
  61. ;* PortID - Address if hardware port.
  62. ;*
  63. ;* RESULT
  64. ;* Data - Data read from port.
  65. ;*
  66. ;****************************************************************************
  67. GLOBAL C inp:NEAR
  68. PROC inp C NEAR USES edx
  69. ARG port:WORD
  70. mov dx,[port]
  71. xor eax,eax
  72. in al,dx
  73. ret
  74. ENDP inp
  75. ;****************************************************************************
  76. ;*
  77. ;* NAME
  78. ;* outp - Write a byte to a hardware port.
  79. ;*
  80. ;* SYNOPSIS
  81. ;* outp(PortID, Value)
  82. ;*
  83. ;* void outp(unsinged short, short);
  84. ;*
  85. ;* FUNCTION
  86. ;*
  87. ;* INPUTS
  88. ;* PortID - Address if hardware port.
  89. ;* Value - Value to write.
  90. ;*
  91. ;* RESULT
  92. ;* NONE
  93. ;*
  94. ;****************************************************************************
  95. GLOBAL C outp:NEAR
  96. PROC outp C NEAR USES edx
  97. ARG port:WORD
  98. ARG value:WORD
  99. mov dx,[port]
  100. mov ax,[value]
  101. out dx,al
  102. ret
  103. ENDP outp
  104. END