home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / emulate / systems / apple / device.asm < prev    next >
Assembly Source File  |  1990-03-30  |  9KB  |  256 lines

  1.     Page    58,132
  2.     Title    DEVICE.ASM    Apple Expansion Slot Devices
  3. ;******************************************************************************
  4. ;
  5. ;   Name:    DEVICE.ASM    Apple Expansion Slot Devices
  6. ;
  7. ;   Group:    Emulator
  8. ;
  9. ;   Revision:    1.00
  10. ;
  11. ;   Date:    January 30, 1988
  12. ;
  13. ;   Author:    Randy W. Spurlock
  14. ;
  15. ;******************************************************************************
  16. ;
  17. ;  Module Functional Description:
  18. ;
  19. ;        This module contains all the code for the Apple
  20. ;    expansion slot devices.
  21. ;
  22. ;******************************************************************************
  23. ;
  24. ;  Changes:
  25. ;
  26. ;    DATE     REVISION                DESCRIPTION
  27. ;  --------   --------    -------------------------------------------------------
  28. ;   1/30/88    1.00    Original
  29. ;
  30. ;******************************************************************************
  31.     Page
  32. ;
  33. ;  Public Declarations
  34. ;
  35.     Public    Device_Init        ; Expansion slot device initialization
  36.     Public    Slot_Address        ; Expansion slot address routine
  37.     Public    Exp_Slot_Read        ; Expansion slot read routine
  38.     Public    Exp_Slot_Write        ; Expansion slot write routine
  39.     Public    Exp_Mem_Read        ; Expansion memory read routine
  40.     Public    Exp_Mem_Write        ; Expansion memory write routine
  41. ;
  42. ;  External Declarations
  43. ;
  44.     Extrn    Slot_Init:Word        ; Expansion slot init. table     (DATA)
  45.     extrn    Slot_Ctrl:Word        ; Expansion slot control table     (DATA)
  46.     Extrn    Mem_Read:Word        ; Exp. slot memory read table     (DATA)
  47.     Extrn    Mem_Write:Word        ; Exp. slot memory write table     (DATA)
  48.     Extrn    Exp_Read:Word        ; Expansion memory read table     (DATA)
  49.     Extrn    Exp_Write:Word        ; Expansion memory write table     (DATA)
  50.     Extrn    Current_Slot:Byte    ; Current active expansion slot  (DATA)
  51.     Extrn    Error:Near        ; Apple emulator error routine    (APPLE)
  52.     Extrn    Exit:Near        ; Apple emulator exit routine    (APPLE)
  53. ;
  54. ;  LOCAL Equates
  55. ;
  56. SLOT_MASK    Equ    0Fh        ; Expansion slot mask value
  57. ;
  58. ;  Define any include files needed
  59. ;
  60.     Include     Macros.inc    ; Include the macro definitions
  61.     Include     Equates.inc    ; Include the equate definitions
  62.     .286c                ; Include 80286 instructions
  63.     Page
  64. ;
  65. ;  Define the emulator code segment
  66. ;
  67. Emulate Segment Word Public 'EMULATE'   ; Emulator code segment
  68.     Assume    cs:Emulate, ds:Nothing, es:Nothing
  69.     Subttl    Device_Init    Expansion Slot Device Initialization
  70.     Page    +
  71. ;******************************************************************************
  72. ;
  73. ;    Device_Init(RAM_Space)
  74. ;
  75. ;        Set Slot_Counter to Zero
  76. ;        While Slot_Counter < Slot_Max (8)
  77. ;            Call current slot initialization routine
  78. ;            Increment Slot_Counter
  79. ;        EndWhile
  80. ;        Return to the caller
  81. ;
  82. ;    Registers on Entry:
  83. ;
  84. ;        DS    - 65C02 RAM space
  85. ;
  86. ;    Registers on Exit:
  87. ;
  88. ;        AX-DX - Destroyed
  89. ;        SI-DI - Destroyed
  90. ;
  91. ;******************************************************************************
  92.         Even            ; Force procedure to even address
  93. Device_Init    Proc    Near        ; Expansion slot device init. procedure
  94.     xor    ax,ax            ; Zero the slot counter value
  95. Slot_Loop:
  96.     mov    bx,ax            ; Get the current slot number
  97.     shl    bx,1            ; Convert slot number to table index
  98.     Save    ax            ; Save the current slot number
  99.     call    cs:[bx + Slot_Init]    ; Call device initialization routine
  100.     Restore ax            ; Restore the current slot number
  101.     inc    ax            ; Increment the current slot number
  102.     cmp    ax,SLOT_MAX        ; Check current slot number against max.
  103.     jne    Slot_Loop        ; Jump if more slots to initialize
  104.     ret                ; Return to the caller
  105. Device_Init    Endp            ; End of the Device_Init procedure
  106.     Subttl    Slot_Address    Expansion Slot Address
  107.     Page    +
  108. ;******************************************************************************
  109. ;
  110. ;    Slot_Address(Slot_Number)
  111. ;
  112. ;        Logically OR in the hardware page number
  113. ;        Calculate the actual slot address
  114. ;        Return to the caller
  115. ;
  116. ;    Registers on Entry:
  117. ;
  118. ;        AX    - Slot number
  119. ;
  120. ;    Registers on Exit:
  121. ;
  122. ;        AX    - Destroyed
  123. ;        SI    - Slot address
  124. ;
  125. ;******************************************************************************
  126.         Even            ; Force procedure to even address
  127. Slot_Address    Proc    Near        ; Expansion slot address procedure
  128.     or    al,HARDWARE_PAGE    ; Logically OR in the hardware page
  129.     xchg    al,ah            ; Calculate the actual page address
  130.     mov    si,ax            ; Move actual page address to SI
  131.     ret                ; Return to the caller
  132. Slot_Address    Endp            ; End of the Slot_Address procedure
  133.     Subttl    Exp_Slot_Read    Expansion Slot Read
  134.     Page    +
  135. ;******************************************************************************
  136. ;
  137. ;    Exp_Slot_Read(Effective_Address)
  138. ;
  139. ;        Isolate the slot number being read
  140. ;        Jump to correct routine to handle read
  141. ;
  142. ;    Registers on Entry:
  143. ;
  144. ;        DS:DI - 65C02 Effective address
  145. ;
  146. ;    Registers on Exit:
  147. ;
  148. ;        AL    - Memory value
  149. ;
  150. ;******************************************************************************
  151.         Even            ; Force procedure to even address
  152. Exp_Slot_Read    Proc    Near        ; Expansion slot read procedure
  153.     mov    ax,di            ; Get the effective address
  154.     mov    al,ah            ; Move MSB of address into AL register
  155.     and    al,SLOT_MASK        ; Mask off all but the slot number
  156.     xor    ah,ah            ; Convert slot number to full word
  157.     shl    ax,1            ; Convert slot number to table index
  158.     mov    bp,ax            ; Setup to jump to correct routine
  159.     jmp    cs:[bp + Mem_Read]    ; Jump to correct routine to read
  160.     ret                ; Return to the caller (Never Executed)
  161. Exp_Slot_Read    Endp            ; End of the Exp_Slot_Read procedure
  162.     Subttl    Exp_Slot_Write    Expansion Slot Write
  163.     Page    +
  164. ;******************************************************************************
  165. ;
  166. ;    Exp_Slot_Write(Effective_Address, Value)
  167. ;
  168. ;        Isolate the slot number being written
  169. ;        Jump to correct routine to handle write
  170. ;
  171. ;    Registers on Entry:
  172. ;
  173. ;        AL    - Memory value
  174. ;        DS:DI - 65C02 Effective address
  175. ;
  176. ;    Registers on Exit:
  177. ;
  178. ;        None
  179. ;
  180. ;******************************************************************************
  181.         Even            ; Force procedure to even address
  182. Exp_Slot_Write    Proc    Near        ; Expansion slot write procedure
  183.     mov    bp,ax            ; Save the memory value in BP register
  184.     mov    ax,di            ; Get the effective address
  185.     mov    al,ah            ; Move MSB of address into AL register
  186.     and    al,SLOT_MASK        ; Mask off all but the slot number
  187.     xor    ah,ah            ; Convert slot number to full word
  188.     shl    ax,1            ; Convert slot number to table index
  189.     xchg    bp,ax            ; Setup to jump to correct routine
  190.     jmp    cs:[bp + Mem_Write]    ; Jump to correct routine to read
  191.     ret                ; Return to the caller
  192. Exp_Slot_Write    Endp            ; End of the Exp_Slot_Write procedure
  193.     Subttl    Exp_Mem_Read    Expansion Memory Read
  194.     Page    +
  195. ;******************************************************************************
  196. ;
  197. ;    Exp_Mem_Read(Effective_Address)
  198. ;
  199. ;        Get the current slot number
  200. ;        Jump to correct routine to handle read
  201. ;
  202. ;    Registers on Entry:
  203. ;
  204. ;        DS:DI - 65C02 Effective address
  205. ;
  206. ;    Registers on Exit:
  207. ;
  208. ;        AL    - Memory value
  209. ;
  210. ;******************************************************************************
  211.         Even            ; Force procedure to even address
  212. Exp_Mem_Read    Proc    Near        ; Expansion memory read procedure
  213.     mov    al,cs:[Current_Slot]    ; Get the current active slot number
  214.     xor    ah,ah            ; Convert slot number to full word
  215.     shl    ax,1            ; Convert slot number to table index
  216.     mov    bp,ax            ; Setup to jump to correct routine
  217.     jmp    cs:[bp + Exp_Read]    ; Jump to correct routine to read
  218.     ret                ; Return to the caller (Never Executed)
  219. Exp_Mem_Read    Endp            ; End of the Exp_Mem_Read procedure
  220.     Subttl    Exp_Mem_Write    Expansion Memory Write
  221.     Page    +
  222. ;******************************************************************************
  223. ;
  224. ;    Exp_Mem_Write(Effective_Address, Value)
  225. ;
  226. ;        Get the current slot number
  227. ;        Jump to correct routine to handle write
  228. ;
  229. ;    Registers on Entry:
  230. ;
  231. ;        AL    - Memory value
  232. ;        DS:DI - 65C02 Effective address
  233. ;
  234. ;    Registers on Exit:
  235. ;
  236. ;        None
  237. ;
  238. ;******************************************************************************
  239.         Even            ; Force procedure to even address
  240. Exp_Mem_Write    Proc    Near        ; Expansion memory write procedure
  241.     mov    bp,ax            ; Save memory value in BP register
  242.     mov    al,cs:[Current_Slot]    ; Get the current active slot number
  243.     xor    ah,ah            ; Convert slot number to full word
  244.     shl    ax,1            ; Convert slot number to table index
  245.     xchg    bp,ax            ; Setup to jump to correct routine
  246.     jmp    cs:[bp + Exp_Write]    ; Jump to correct routine to read
  247.     ret                ; Return to the caller (Never Executed)
  248. Exp_Mem_Write    Endp            ; End of the Exp_Mem_Write procedure
  249. ;******************************************************************************
  250. ;
  251. ;    Define the end of the Emulator Code Segment
  252. ;
  253. ;******************************************************************************
  254. Emulate Ends
  255.     End                ; End of the Device module
  256.