Advertisement
Guest User

Untitled

a guest
May 3rd, 2019
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
ARM 8.36 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:
  12.  
  13.   mov r0,0        @ Initialize r0 to be played
  14.   add r4,1        @ Reference register as the current peak
  15.   cmp r4,5
  16.   ittee eq
  17.   moveq r3, 0
  18.   moveq r4, 0
  19.   addne r3, 2000
  20.   addne r3, 2000
  21.   ldr r6, =array  @ Loading the array location
  22.   ldr r7, [r6, 4] @ Loading the first element on the array
  23.   mov r5, r7      @ Use r5 for reference to compare to r7
  24.   ldr r8, [r6]    @ Size of the array
  25.   mov r9, 1       @ Array Index
  26.   ldr r10, =duration  @ Loading the array location
  27.   ldr r11, [r10, 4] @ Loading the first element on the array
  28.   sub r11, r11, r3
  29.   @mov r3, r11      @ Use r5 for reference to compare to r7
  30.  
  31.  
  32.   b positive_peak
  33.  
  34. @ normal:
  35. @   mov r3, 1
  36. @   bx lr
  37.  
  38. @ faster:
  39. @   add r3, 2000
  40. @   bx lr
  41.  
  42. positive_peak:    
  43.  
  44.   @ ldr r4, =0x7fff  
  45.   mov r0, 0x7fff      @ Putting the positive peak value to r0 to be played
  46.   sub r11, 1      @ Checking the duration counter
  47.   cmp r11, 0    @ Comparing it to 12000 to change pitch
  48.   beq change_pitch
  49.   sub r7, 1       @ Adding 1 to the counter
  50.   cmp r7, 0       @ Because the Period = 1/f and the BSP is 48khz then to get the period for 1/440HZ we multiply is by 48khz
  51.                   @ But we need the point for half of a period because each peak is only half a period
  52.                   @ Which is 54.5 but since we can't use float in integer then we use
  53.  beq negative_peak   @This will change the peak to negative peak if high peak has reach the half period
  54.  push {r3}
  55.  bl BSP_AUDIO_OUT_Play_Sample
  56.  pop {r3}
  57.  
  58. b positive_peak  
  59.  
  60. negative_peak:  
  61.  
  62.  @ ldr r4, =0x8000
  63.  mov r0, 0x8000      
  64.  sub r11, 1
  65.  cmp r11, 0
  66.  beq change_pitch
  67.  add r7, 1      @Substracting 1 to the counter
  68.  cmp r7, r5
  69.                  @ bleq change
  70.                  @when the subs reach 0 then the negative peak has reach half of the period which is 55 then we change it to positive
  71.  beq positive_peak
  72.  push {r3}
  73.  bl BSP_AUDIO_OUT_Play_Sample @This will play the sound at the particular value of r0
  74.  pop {r3}
  75.  
  76. b negative_peak
  77.  
  78.  
  79. change_pitch:
  80.  add r9, 1      @ Add the Array index
  81.  cmp r8, r9     @ Restart if it has reach the array limit
  82.  beq restart    
  83.  mov r12, 4    
  84.  mul r12, r9, r12 @ Multiply index with 4 to change the array index by *4 each loop
  85.  ldr r7, [r6,r12]
  86.  mov r5, r7      @ Change the reference pitch to the current pitch
  87.  ldr r11, [r10, r12] @ Loading the first element on the array
  88.  sub r11, r11, r3
  89.  @mov r3, r11      @ Use r5 for reference to compare to r7    
  90.  b positive_peak
  91.  
  92. .data
  93. array:
  94.  .word 122        @ Array Size
  95.  @.word 122, 130, 122, 122, 109, 109, 122, 122, 130, 130, 122, 122, 97, 97, 122, 0, 122, 130, 122, 122, 109, 0, 122, 0, 130, 0, 122, 0, 97, 97, 122, 0
  96.  .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
  97.  
  98.  
  99.  
  100. duration:  
  101. @.word 12000, 12000, 12000, 12000, 12000, 12000, 12000, 12000, 12000, 12000, 12000, 12000, 12000, 12000, 12000, 12000, 12000, 12000, 12000, 12000, 12000, 12000, 12000, 12000, 60000, 12000, 12000, 12000, 12000, 12000, 12000, 12000, 12000, 12000, 12000, 12000, 12000, 12000, 12000, 12000, 12000, 12000, 12000, 12000, 12000, 12000, 12000, 12000, 12000, 12000, 12000, 12000, 12000, 12000, 12000, 12000, 12000, 12000, 12000, 12000, 12000, 12000, 12000, 12000, 12000, 12000, 12000, 12000, 12000, 12000, 12000, 12000, 12000, 12000, 12000, 12000, 12000, 12000, 12000, 12000, 12000, 12000, 12000, 12000, 12000, 12000, 12000, 12000, 60000, 12000, 12000, 12000, 12000, 12000, 12000, 12000, 12000, 24000, 12000, 12000, 12000, 12000, 12000, 12000, 24000, 12000, 12000, 12000, 12000, 12000, 12000, 12000, 12000, 12000, 12000, 12000,  12000, 12000, 12000, 12000, 12000, 12000
  102. @.word 18000, 18000, 18000, 18000, 18000, 18000, 18000, 18000, 18000, 18000, 18000, 18000, 18000, 18000, 18000, 18000, 18000, 18000, 18000, 18000, 18000, 18000, 18000, 18000, 66000, 18000, 18000, 18000, 18000, 18000, 18000, 18000, 18000, 18000, 18000, 18000, 18000, 18000, 18000, 18000, 18000, 18000, 18000, 18000, 18000, 18000, 18000, 18000, 18000, 18000, 18000, 18000, 18000, 18000, 18000, 18000, 18000, 18000, 18000, 18000, 18000, 18000, 18000, 18000, 18000, 18000, 18000, 18000, 18000, 18000, 18000, 18000, 18000, 18000, 18000, 18000, 18000, 18000, 18000, 18000, 18000, 18000, 18000, 18000, 18000, 18000, 18000, 18000, 66000, 18000, 18000, 18000, 18000, 18000, 18000, 18000, 18000, 30000, 18000, 18000, 18000, 18000, 18000, 18000, 30000, 18000, 18000, 18000, 18000, 18000, 18000, 18000, 18000, 18000, 18000, 18000, 18000, 18000, 18000, 18000, 18000, 18000
  103. .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
  104. @ @196 , 185, 220, 246.94
  105. @ @122.448  ,  129.729  ,  109.0909  ,  97.189
  106.  
  107. @ @132.144, 0,  111.111,    176.379,    0,  111.111,    0,  132.144,    166.481,    166.481, 166.481,   0,  0,  0,  0
  108.  
  109. @ 132, 0, 111, 176, 0, 111, 0, 132, 166, 166, 166, 0, 0, 0, 0
  110. @ 12000, 12000, 12000, 12000, 12000, 12000, 12000, 12000, 12000, 12000, 12000, 12000, 12000, 12000, 12000
  111.  
  112.  
  113. @ @176.379, 166.481,    132.144,    111.111,    88.189, 0,  111.111,    0,  132.144,    74.158, 74.158, 74.158, 74.158, 78.567, 83.237, 0,  0,  0,  0
  114.  
  115. @ 176, 166, 132, 111, 88, 0, 111, 0, 132, 74, 79, 83, 0, 0, 0, 0
  116. @                                         Continous
  117. @ 12000, 12000, 12000, 12000, 12000, 12000, 12000, 12000, 12000, 60000, 12000, 12000, 12000, 12000, 12000, 12000
  118. @ @117.718, 0,  88.189, 132.144,    0,  88.189, 117.718,    0,  88.189, 0,  124.72, 132.144,    0,  148.312,    0,  148.312,    148.312,    148.312,    0, 0,   0,  148.312,    148.312,    148.312,    0,  0,  0
  119.  
  120. @ 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
  121. @ 12000, 12000, 12000, 12000, 12000, 12000, 12000, 12000, 12000, 12000, 12000, 12000, 12000, 12000, 12000, 12000, 12000, 12000, 12000, 12000, 12000, 12000, 12000, 12000, 12000, 12000, 12000
  122. @ @157.129, 157.129,    166.481,    166.481,    176.379,    0,  111.111,    88.189, 0,  111.111,    0,  132.144,    148.312,    148.312,    148.312,    0,  0,  74.158, 74.158, 74.158, 0,  0,  0
  123.  
  124. @ 157, 157, 166, 166, 176, 0, 111, 88, 0, 111, 0, 132, 148, 148, 148, 0, 0, 74, 74, 74, 0, 0, 0
  125. @ 12000, 12000, 12000, 12000, 12000, 12000, 12000, 12000, 12000, 12000, 12000, 12000, 12000, 12000, 12000, 12000, 12000, 12000, 12000, 12000, 12000, 12000, 12000
  126. @ @132.144, 111.111,    88.189, 0,  111.111,    0,  132.144,    88.189, 88.189, 88.189, 88.189, 88.189, 98.98, 0, 0,    0,  0
  127.  
  128. @ 132, 111, 88, 0, 111, 0, 132, 88, 99, 0, 0, 0, 0
  129. @                               Continous
  130. @ 12000, 12000, 12000, 12000, 12000, 12000, 12000, 60000, 12000, 12000, 12000, 12000, 12000                            
  131. @ @98.98,   124.72, 166.481,    176.379,    176.379,    98.98,  124.72, 176.379,    111.111,    132.144,    186.8722,   197.9,  197.9,  139.99, 166.481,    197.9,  148.312,    148.312,    148.312,    0,  ,0  ,0  ,0  ,0
  132.  
  133. @ 99, 124, 166, 176, 99, 124, 176, 111, 132, 186, 198, 140, 166, 198, 148, 148, 148, 0, 0, 0, 0, 0
  134. @               Continous                               Continous
  135. @ 12000, 12000, 12000, 24000, 12000, 12000, 12000, 12000, 12000, 12000, 24000, 12000, 12000, 12000, 12000, 12000, 12000, 12000, 12000, 12000, 12000, 12000
  136. @ @104.876, 98.98,  88.189, 83.237, 66.066, 55.55
  137.  
  138. @ 105, 99, 88, 83, 66, 56
  139. @ 12000, 12000, 12000, 12000, 12000, 12000
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement