-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathChromaticScale.asm
116 lines (91 loc) · 1.37 KB
/
ChromaticScale.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
; ChromaticScale.asm
; Plays a chromatic scale using the
; tone generator peripheral with
; switches used to control volume.
ORG 0
; Set to note mode
LOADI 2
OUT Mode
; Set volume
LOADI 1
OUT Volume
LOADI &B001100000
STORE Value
;OUT NoteAddr
; Octave = 3
LOADI 3
STORE Octave
OctLoop:
; Octave < 7
LOAD Octave
ADDI -6
JPOS EndOctLoop
; Note = 0
LOADI 0
STORE Note
; Value = 0
LOAD Value
AND AndBitMask
STORE Value
NoteLoop:
; Note < 12
LOAD Note
ADDI -11
JPOS EndNoteLoop
;Set Volume
IN Switches
AND VolBitMask
OUT Volume
; Play Note
LOAD Value
OUT Hex0
OUT LEDs
OUT NoteAddr
CALL Delay
CALL Delay
; Note++
LOAD Note
ADDI 1
STORE Note
; Value++
LOAD Value
ADDI 1
STORE Value
JUMP NoteLoop
EndNoteLoop:
; Octave++
LOAD Octave
ADDI 1
STORE Octave
; Value++
LOAD Value
ADDI &B100000
STORE Value
JUMP OctLoop
EndOctLoop:
; Do it again
JUMP 0
; Subroutine to delay for 0.2 seconds.
Delay:
OUT Timer
WaitingLoop:
IN Timer
ADDI -2
JNEG WaitingLoop
RETURN
; LVs
Octave: DW 000
Note: DW 000
Value: DW 000
AndBitMask: DW &B111100000
VolBitMask: DW &B000000011
; IO address constants
Switches: EQU 000
LEDs: EQU 001
Timer: EQU 002
Hex0: EQU 004
Hex1: EQU 005
Mode: EQU &H40
TW: EQU &H41
NoteAddr: EQU &H42
Volume: EQU &H43