Advertisement
Guest User

Untitled

a guest
May 3rd, 2019
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
ARM 3.33 KB | None | 0 0
  1. .syntax unified
  2. .global main
  3.  
  4. .type main, %function
  5. main:
  6.   bl init
  7.   mov r3, 0
  8.   mov r4, 0
  9.   b restart
  10.  
  11. @Restart label to playback the song after it's stop
  12. restart:
  13.  
  14.  mov r0,0        
  15.  add r4,1          
  16.  
  17.  @Loading the location of the array for notes and use it's element in a register
  18.   ldr r6, =array  
  19.   ldr r7, [r6, 4]
  20.   mov r5, r7    
  21.   ldr r8, [r6]    
  22.   mov r9, 1
  23.  
  24.   @Loading the location of the array for each notes duration and use it's element in a register      
  25.  ldr r10, =duration  
  26.  ldr r11, [r10, 4]
  27.  
  28.  @increase the tempo of the song by substing duration of each notes
  29.  sub r11, r11, r3
  30.  
  31.  @Revert the tempo back to normal after 3 playback of continuously increasing tempo
  32.  cmp r4,4
  33.  itte eq
  34.  moveq r3, 0
  35.  moveq r4, 0
  36.  addne r3, 2000
  37.  
  38.  
  39.  
  40.  b positive_peak
  41.  
  42.  
  43. positive_peak:    
  44.  
  45.  @Set the positive peak for volume at 0x7fff
  46.  mov r0, 0x7fff      
  47.  
  48.  @Change notes or pitch when the notes has finished it's duration
  49.   sub r11, 1      
  50.   cmp r11, 0  
  51.   beq change_pitch
  52.  
  53.  
  54.   sub r7, 1      
  55.   cmp r7, 0      
  56.   beq negative_peak  
  57.  
  58.   @Using push and pull to store value in stack because it's reset to 0 when AUDIO is played
  59.  push {r3}
  60.  bl BSP_AUDIO_OUT_Play_Sample
  61.  pop {r3}
  62.  
  63. b positive_peak  
  64.  
  65. negative_peak:  
  66.  
  67.  
  68.  mov r0, 0x8000      
  69.  sub r11, 1
  70.  cmp r11, 0
  71.  beq change_pitch
  72.  add r7, 1      
  73.  cmp r7, r5
  74.  beq positive_peak
  75.  push {r3}
  76.  bl BSP_AUDIO_OUT_Play_Sample
  77.  pop {r3}
  78.  
  79. b negative_peak
  80.  
  81.  
  82. @Label to change to the next notes after finishing the current note's duration
  83. change_pitch:
  84.   add r9, 1      
  85.   cmp r8, r9
  86.  
  87.        
  88.   beq restart    
  89.   mov r12, 4    
  90.   mul r12, r9, r12
  91.  
  92.   @Load the next notes and duration to the register
  93.   ldr r7, [r6,r12]
  94.   mov r5, r7      
  95.   ldr r11, [r10, r12]
  96.   sub r11, r11, r3    
  97.   b positive_peak
  98.  
  99. .data
  100. array:
  101.   @Array Size
  102.   .word 122  
  103.   @Array of notes in the song      
  104.   .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
  105.  
  106.  
  107.  
  108. duration:  
  109.   @Array of duration for each notes
  110.   .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