-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsong.asm
196 lines (145 loc) · 6 KB
/
song.asm
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
;*******************************************************************************
;* Program : SONG.ASM
;* Programmer: Ruth Herbst
;* Purpose : Plays "The Entertainer" on the speaker attached to TOC5
;* Language : Motorola/Freescale/NXP 68HC11 Assembly Language (aspisys.com/ASM11)
;* Status : Public Domain
;* History : 03.04.02 v1.00 Original
;*******************************************************************************
#ifmain ;-----------------------------------------------------------------------
#ListOff
#Uses mcu.inc
#ListOn
#endif ;------------------------------------------------------------------------
;*******************************************************************************
; Data Section
;*******************************************************************************
;*******************************************************************************
#RAM ;.area DATA (rel,con)
;*******************************************************************************
Song rmb 38
Note rmb 2
;*******************************************************************************
#ROM
;*******************************************************************************
Start proc
lds #STACKTOP
ldx #Song
ldd #6810
std ,x
ldd #6428
std 2,x
ldd #6068
std 4,x
ldd #3822
std 6,x
ldd #6068
std 8,x
ldd #3822
std 10,x
ldd #6068
std 12,x
ldd #3822
std 14,x
ldd #0002
std 16,x
ldd #3822
std 18,x
ldd #3405
std 20,x
ldd #3034
std 22,x
ldd #3822
std 24,x
ldd #3405
std 26,x
ldd #3034
std 28,x
ldd #4050
std 30,x
ldd #3405
std 32,x
ldd #3822
std 34,x
ldd #0003
std 36,x
; bra Main
;*******************************************************************************
Main proc
ldx #Song
ldd ,x
std Note
bsr TOC5INI ; jump to subroutine
cli ; enable interrupts
Loop@@ bsr Wait250ms
inx:2
ldd ,x
std Note
cmpd #3
bne Loop@@
bra Main
;*******************************************************************************
; TMRINI subroutine
;*******************************************************************************
TOC5INI proc
pshd
lda PACTL
anda #%11111011
sta PACTL
ldd #Note
addd TCNT
std TOC5
lda TCTL1
anda #%11111100
ora #%00000001
sta TCTL1
lda TMSK1 ; use TMSK to enable the TOC5 interrupt
ora #%00001000
sta TMSK1
lda TFLG1
ora #%00001000
sta TFLG1
puld
rts
;*******************************************************************************
; TOC5ISR Subroutine
;*******************************************************************************
TOC5ISR proc
ldd TOC5
addd Note
std TOC5
lda #%00001000
sta TFLG1 ; clear the TOI interrupt flag
rti
;*******************************************************************************
Wait250ms proc
pshx
psha
tpa ; save condition codes
ldx #250 ; wait 250 milliseconds
Loop@@ bsr Wait1ms ; local label
dex
bne Loop@@ ; Branch if not equal to
tap
pula
pulx
rts
;*******************************************************************************
#Cycles
Wait1ms proc
pshx
psha
tpa
#Cycles
ldx #DELAY@@
Loop@@ dex
nop:2
bne Loop@@
#temp :cycles
tap
pula
pulx
rts
DELAY@@ equ BUS_KHZ-:cycles-:ocycles/:temp
;*******************************************************************************
@vector Vtoc5,TOC5ISR