Guest User

int_m.src

a guest
Mar 31st, 2025
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.41 KB | None | 0 0
  1. ;****************************************************************
  2. ; MARS Check Program
  3. ; SH2 Master Interrupt
  4. ;
  5. ; Copyright SEGA ENTERPRISES,LTD. 1994
  6. ; SEGA ENTERPRISES,LTD.
  7. ; CS Hardware R&D Dept.
  8. ; T.Okawa
  9. ;---------------------------------------------------------------*
  10. ;
  11. ;****************************************************************
  12.  
  13. .import pwmint_rtn ; shsound.src
  14. .import _hotreset ; master.src
  15.  
  16. .export m_int
  17.  
  18. .include "include\shmap.i"
  19. .include "include\sdram.ass"
  20. .include "include\sh_const.ass"
  21.  
  22.  
  23. ;---------------------------------------------------------------*
  24. ; Interrupt Control
  25. ;---------------------------------------------------------------*
  26.  
  27. m_int:
  28. push 0,1
  29. sts.l pr,@-r15
  30.  
  31. stc sr,r0
  32. shlr2 r0
  33. and #h'3c,r0
  34. mov.l #inttable,r1
  35. add r1,r0
  36. mov.l @r0,r1
  37. jsr @r1
  38. nop
  39.  
  40. lds.l @r15+,pr
  41. pop 0,1
  42. rte
  43. nop
  44.  
  45. .align 4
  46. inttable:
  47. .data.l noret, ; Illigal Interrupt
  48. + noret, ; Level 1
  49. + noret, ; Level 2
  50. + noret, ; Level 3
  51. + sciint, ; Level 4
  52. + noret, ; Level 5
  53. + pwmint, ; Level 6
  54. + pwmint, ; Level 7
  55. + cmdint, ; Level 8
  56. + cmdint, ; Level 9
  57. + hint, ; Level 10
  58. + hint, ; Level 11
  59. + vint, ; Level 12
  60. + vint, ; Level 13
  61. + vresint, ; Level 14
  62. + vresint ; Level 15
  63.  
  64. ;---------------------------------------------------------------*
  65. ; Illigal Interrupt
  66. ;---------------------------------------------------------------*
  67.  
  68. noret:
  69. rts
  70. nop
  71.  
  72.  
  73.  
  74. ;---------------------------------------------------------------*
  75. ; VRES Interrupt (Hot Reset)
  76. ;---------------------------------------------------------------*
  77.  
  78. vresint:
  79. mov.l #_sysreg,r0
  80. ldc r0,gbr
  81.  
  82. mov.w r0,@(vresintclr,gbr) ; V interrupt clear
  83.  
  84. mov.b @(dreqctl,gbr),r0 ; Vres‘΍ô
  85. tst #RV,r0
  86. bf mars_reset
  87.  
  88. mov.l #M_STACK-8,r15 ; ƒXƒ^ƒbƒN‚̕ύX
  89. mov.l #_hotreset,r0
  90. mov r0,@r15 ; PC ‚̕ύX
  91. mov.w #h'f0,r0
  92. mov r0,@(4,r15) ; SR ‚̃}ƒXƒN
  93.  
  94. mov.l #_DMAOPERATION,r1
  95. mov #0,r0
  96. mov.l r0,@r1 ; DMA off
  97.  
  98. mov #0,r0
  99. mov.b r0,@(m_sysflug,flugbase)
  100.  
  101. rte
  102. nop
  103.  
  104. mars_reset
  105. mov.l #_FRT,r1 ; System Reset
  106. mov.b @(_TOCR,r1),r0 ;
  107. or #h'01,r0 ;
  108. mov.b r0,@(_TOCR,r1) ;
  109. vresloop:
  110. bra vresloop
  111. nop
  112.  
  113.  
  114. ;---------------------------------------------------------------*
  115. ; V Interrupt
  116. ;---------------------------------------------------------------*
  117.  
  118. vint:
  119. mov.l #h'f0,r0
  120. ldc r0,sr
  121.  
  122. mov.l #_FRT,r1
  123. mov.b @(_TOCR,r1),r0
  124. xor #h'02,r0
  125. mov.b r0,@(_TOCR,r1)
  126.  
  127. mov.w r0,@(vintclr,gbr) ; V interrupt clear
  128.  
  129. mov.w @(m_vint_timer,workbase),r0
  130. add #1,r0
  131. mov.w r0,@(m_vint_timer,workbase)
  132. mov #0,r0
  133. mov.w r0,@(m_hint_timer,workbase)
  134.  
  135. rts
  136. nop
  137.  
  138.  
  139.  
  140. ;---------------------------------------------------------------*
  141. ; H Interrupt
  142. ;---------------------------------------------------------------*
  143.  
  144. hint:
  145. mov.l #h'f0,r0
  146. ldc r0,sr
  147.  
  148. mov.l #_FRT,r1
  149. mov.b @(_TOCR,r1),r0
  150. xor #h'02,r0
  151. mov.b r0,@(_TOCR,r1)
  152.  
  153. mov.w r0,@(hintclr,gbr) ; H interrupt clear
  154.  
  155. mov.w @(m_hint_timer,workbase),r0
  156. add #1,r0
  157. mov.w r0,@(m_hint_timer,workbase)
  158. mov.w @(m_hint1_timer,workbase),r0
  159. add #1,r0
  160. mov.w r0,@(m_hint1_timer,workbase)
  161.  
  162. rts
  163. nop
  164.  
  165.  
  166. ;---------------------------------------------------------------*
  167. ; Command Interrupt
  168. ;---------------------------------------------------------------*
  169.  
  170. cmdint:
  171. mov.l #h'f0,r0
  172. ldc r0,sr
  173.  
  174. mov.l #_FRT,r1
  175. mov.b @(_TOCR,r1),r0
  176. xor #h'02,r0
  177. mov.b r0,@(_TOCR,r1)
  178.  
  179. mov.w r0,@(cmdintclr,gbr) ; CMD interrupt clear
  180.  
  181. mov.w @(comm0,gbr),r0
  182. mov r0,r1
  183. shlr8 r0
  184. shlr2 r0
  185. shlr2 r0
  186. tst #h'8,r0
  187. bt no_command
  188. mov r1,r0
  189. mov.w r0,@(m_command,workbase) ; Set Command No.
  190. mov.b @(m_sysflug,flugbase),r0
  191. or #M_CMD_ON,r0 ; Command On
  192. mov.b r0,@(m_sysflug,flugbase)
  193. no_command:
  194. mov.w @(m_cmdint_timer,workbase),r0
  195. add #1,r0
  196. mov.w r0,@(m_cmdint_timer,workbase)
  197.  
  198. rts
  199. nop
  200.  
  201.  
  202. ;---------------------------------------------------------------*
  203. ; PWM Timer Interrupt
  204. ;---------------------------------------------------------------*
  205.  
  206. pwmint:
  207. push 2,3
  208.  
  209. mov.l #h'f0,r0
  210. ldc r0,sr
  211.  
  212. mov.l #_FRT,r1
  213. mov.b @(_TOCR,r1),r0
  214. xor #h'02,r0
  215. mov.b r0,@(_TOCR,r1)
  216.  
  217. mov.w r0,@(pwmintclr,gbr) ; PWM interrupt clear
  218.  
  219. mov.w @(m_pwmint_timer,workbase),r0
  220. add #1,r0
  221. mov.w r0,@(m_pwmint_timer,workbase)
  222.  
  223. mov.b @(m_sysflug,flugbase),r0
  224. tst #M_SOUNDINT,r0
  225. bt pwmint_00
  226.  
  227. sts.l pr,@-r15
  228. bsr pwmint_rtn
  229. nop
  230. lds.l @r15+,pr
  231. pwmint_00:
  232. pop 2,3
  233. rts
  234. nop
  235.  
  236.  
  237. ;---------------------------------------------------------------*
  238. ; Serial Interrupt
  239. ;---------------------------------------------------------------*
  240.  
  241. sciint:
  242. mov.l #_SCI,r1
  243. mov.b @(_SSR,r1),r0
  244. tst #h'08,r0
  245. bf sci_eri
  246. tst #h'10,r0
  247. bf sci_eri
  248. tst #h'20,r0
  249. bf sci_eri
  250. tst #h'40,r0
  251. bf sci_rxi
  252. tst #h'80,r0
  253. bf sci_txi
  254. tst #h'04,r0
  255. bf sci_tei
  256.  
  257. rts
  258. nop
  259.  
  260.  
  261. ;---------------------------------------------------------------*
  262. ; ŽóMƒGƒ‰[
  263. ;---------------------------------------------------------------*
  264.  
  265. sci_eri:
  266. push 0,1
  267.  
  268. mov.l #_SCI,r1
  269.  
  270. mov.b @(_SSR,r1),r0
  271. mov.b r0,@(m_sci_ssr,flugbase)
  272. mov.b @(_RDR,r1),r0
  273. mov.b r0,@(m_receivedata,flugbase)
  274. mov #h'c7,r0
  275. mov.b r0,@(_SSR,r1) ; Error flug clear
  276.  
  277. mov.b @(m_sysflug,flugbase),r0
  278. or #SCI_ERR,r0
  279. mov.b r0,@(m_sysflug,flugbase)
  280.  
  281. pop 0,1
  282. rts
  283. nop
  284.  
  285.  
  286. ;---------------------------------------------------------------*
  287. ; ŽóMƒf[ƒ^ƒtƒ‹
  288. ;---------------------------------------------------------------*
  289.  
  290. sci_rxi:
  291. push 0,2
  292.  
  293. mov.l #_SCI,r1
  294.  
  295. mov.b @(_SSR,r1),r0
  296. mov.b r0,@(m_sci_ssr,flugbase)
  297. mov.b @(_RDR,r1),r0
  298. mov.b r0,@(m_receivedata,flugbase)
  299. mov #h'bf,r0
  300. mov.b r0,@(_SSR,r1) ; RDRF clear
  301. nop
  302. nop
  303. mov.b @(_SSR,r1),r0
  304. mov.b r0,@(m_sci_ssr,flugbase)
  305. nop
  306. nop
  307.  
  308. mov.b @(m_sysflug,flugbase),r0
  309. or #SCI_RXI,r0
  310. mov.b r0,@(m_sysflug,flugbase)
  311.  
  312. ; mov #-1,r2
  313. ; mov.b @(m_receivedata,flugbase),r0
  314. ; cmp/eq r0,r2
  315. ; bt txi_end
  316. ;rxi00:
  317. ; mov.b @(_SSR,r1),r0
  318. ; tst #h'80,r0
  319. ; bt rxi00
  320. ; mov.b @(m_receivedata,flugbase),r0
  321. ; mov.b r0,@(_TDR,r1)
  322. ; mov #h'7f,r0
  323. ; mov.b r0,@(_SSR,r1) ; TDRE clear
  324. ;
  325. ; mov #SCI_TXOK,r0
  326. ; not r0,r1
  327. ; mov.b @(m_sysflug,flugbase),r0
  328. ; and r1,r0
  329. ; mov.b r0,@(m_sysflug,flugbase)
  330. txi_end:
  331. pop 0,2
  332. rts
  333. nop
  334.  
  335.  
  336. ;---------------------------------------------------------------*
  337. ; ‘—Mƒf[ƒ^ƒGƒ“ƒvƒeƒB[
  338. ;---------------------------------------------------------------*
  339.  
  340. sci_txi:
  341. push 0,1
  342.  
  343. mov.l #_SCI,r1
  344.  
  345. mov.b @(_SSR,r1),r0
  346. mov.b r0,@(m_sci_ssr,flugbase)
  347. ; mov #h'7f,r0
  348. ; mov.b r0,@(_SSR,r1) ; TDRE clear
  349.  
  350. ; mov.b @(m_sysflug,flugbase),r0
  351. ; or #SCI_TXOK,r0
  352. ; mov.b r0,@(m_sysflug,flugbase)
  353.  
  354. pop 0,1
  355. rts
  356. nop
  357.  
  358.  
  359. ;---------------------------------------------------------------*
  360. ; ‘—MI—¹
  361. ;---------------------------------------------------------------*
  362.  
  363. sci_tei:
  364. push 0,1
  365.  
  366. mov.l #_SCI,r1
  367.  
  368. mov.b @(_SSR,r1),r0
  369. mov.b r0,@(m_sci_ssr,flugbase)
  370. ; mov #h'7f,r0
  371. ; mov.b r0,@(_SSR,r1) ; TDRE clear
  372.  
  373. mov.b @(m_sysflug,flugbase),r0
  374. or #SCI_TXOK,r0
  375. mov.b r0,@(m_sysflug,flugbase)
  376.  
  377. pop 0,1
  378. rts
  379. nop
  380.  
  381.  
  382. ;****************************************************************
  383. ; end of file
  384. ;****************************************************************
  385. .end
  386.  
Advertisement
Add Comment
Please, Sign In to add comment