Advertisement
Guest User

Untitled

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