-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpa_cop.inc
69 lines (69 loc) · 2.3 KB
/
pa_cop.inc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
;*******************************************************************************
; Purpose: Special COP reset sequence for PA and compatible derivatives
; Input : None
; Output : None
; Note(s):
#ifmdef COP
#Drop COP
#endif
COP macro #SAVE# ;kick the COP watchdog
#ifdef NO_COP||!WDOG_CNT
mexit
#endif
#ifparm ~1~ = #SAVE#
#ifdef KickCop
merror KickCop proc is already defined
#endif
#push
#MapOff
#Cycles
KickCop proc
push
tpa
sei
ldhx #$A602
#temp :ccycles
sthx WDOG_CNT
ldhx #$B480
sthx WDOG_CNT
#if :ccycles-:temp > 16
#Warning COP sequence longer than 16 cycles ({:ccycles-:temp})
#endif
tap
pull
rtc
KICKCOP_CYCLES equ :cycles
#pull
mexit
#endif
#ifdef KickCop
#temp1 :ocycles
#temp2 :cycles
call KickCop
#temp :cycles+KICKCOP_CYCLES
#Cycles :temp1
#Cycles :temp2+:temp
#endif
endm
;-------------------------------------------------------------------------------
DisableCOP macro
push
tpa
sei
ldhx #$C520
#temp :ccycles
sthx WDOG_CNT
ldhx #$D928
sthx WDOG_CNT
#if :ccycles-:temp > 16
#Warning COP sequence longer than 16 cycles ({:ccycles-:temp})
#endif
clrx
stx WDOG_CS1
stx WDOG_CS2
comx
stx WDOG_TOVAL
stx WDOG_TOVAL+1
tap
pull
endm