Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- .syntax unified
- .global main
- .type main, %function
- main:
- bl init
- mov r3, 0
- mov r4, 0
- b restart
- @Restart label to playback the song after it's stop
- restart:
- mov r0,0
- add r4,1
- @Loading the location of the array for notes and use it's element in a register
- ldr r6, =array
- ldr r7, [r6, 4]
- mov r5, r7
- ldr r8, [r6]
- mov r9, 1
- @Loading the location of the array for each notes duration and use it's element in a register
- ldr r10, =duration
- ldr r11, [r10, 4]
- @increase the tempo of the song by substing duration of each notes
- sub r11, r11, r3
- @Revert the tempo back to normal after 3 playback of continuously increasing tempo
- cmp r4,4
- itte eq
- moveq r3, 0
- moveq r4, 0
- addne r3, 2000
- b positive_peak
- positive_peak:
- @Set the positive peak for volume at 0x7fff
- mov r0, 0x7fff
- @Change notes or pitch when the notes has finished it's duration
- sub r11, 1
- cmp r11, 0
- beq change_pitch
- sub r7, 1
- cmp r7, 0
- beq negative_peak
- @Using push and pull to store value in stack because it's reset to 0 when AUDIO is played
- push {r3}
- bl BSP_AUDIO_OUT_Play_Sample
- pop {r3}
- b positive_peak
- negative_peak:
- mov r0, 0x8000
- sub r11, 1
- cmp r11, 0
- beq change_pitch
- add r7, 1
- cmp r7, r5
- beq positive_peak
- push {r3}
- bl BSP_AUDIO_OUT_Play_Sample
- pop {r3}
- b negative_peak
- @Label to change to the next notes after finishing the current note's duration
- change_pitch:
- add r9, 1
- cmp r8, r9
- beq restart
- mov r12, 4
- mul r12, r9, r12
- @Load the next notes and duration to the register
- ldr r7, [r6,r12]
- mov r5, r7
- ldr r11, [r10, r12]
- sub r11, r11, r3
- b positive_peak
- .data
- array:
- @Array Size
- .word 122
- @Array of notes in the song
- .word 132, 0, 111, 176, 0, 111, 0, 132, 166, 166, 166, 0, 0, 0, 0, 176, 166, 132, 111, 88, 0, 111, 0, 132, 74, 79, 83, 0, 0, 0, 0, 118, 0, 88, 132, 0, 88, 118, 0, 88, 0, 125, 132, 0, 148, 0, 148, 148, 148, 0, 0, 0, 148, 148, 148, 0, 0, 0, 157, 157, 166, 166, 176, 0, 111, 88, 0, 111, 0, 132, 148, 148, 148, 0, 0, 74, 74, 74, 0, 0, 0, 132, 111, 88, 0, 111, 0, 132, 88, 99, 0, 0, 0, 0, 99, 124, 166, 176, 99, 124, 176, 111, 132, 186, 198, 140, 166, 198, 148, 148, 148, 0, 0, 0, 0, 0, 105, 99, 88, 83, 66, 56
- duration:
- @Array of duration for each notes
- .word 14000, 14000, 14000, 14000, 14000, 14000, 14000, 14000, 14000, 14000, 14000, 14000, 14000, 14000, 14000, 14000, 14000, 14000, 14000, 14000, 14000, 14000, 14000, 14000, 48000, 14000, 14000, 14000, 14000, 14000, 14000, 14000, 14000, 14000, 14000, 14000, 14000, 14000, 14000, 14000, 14000, 14000, 14000, 14000, 14000, 14000, 14000, 14000, 14000, 14000, 14000, 14000, 14000, 14000, 14000, 14000, 14000, 14000, 14000, 14000, 14000, 14000, 14000, 14000, 14000, 14000, 14000, 14000, 14000, 14000, 14000, 14000, 14000, 14000, 14000, 14000, 14000, 14000, 14000, 14000, 14000, 14000, 14000, 14000, 14000, 14000, 14000, 14000, 48000, 14000, 14000, 14000, 14000, 14000, 14000, 14000, 14000, 26000, 14000, 14000, 14000, 14000, 14000, 14000, 26000, 14000, 14000, 14000, 14000, 14000, 14000, 14000, 14000, 14000, 14000, 14000, 14000, 14000, 14000, 14000, 14000, 14000
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement