Modifications

Sauter à la navigation Sauter à la recherche
164 octets ajoutés ,  19 avril 2015 à 09:45
Ligne 53 : Ligne 53 :     
== Les boucles ==
 
== Les boucles ==
We can assign labels with {{fname|label(my_label)}}, and branch to them using {{fname|b(my_label)}}, or a conditional branch like {{fname|bgt(my_label)}}.
+
Nous pouvons assigner un libellé (''label'' en anglais) a l'aide de {{fname|label(mon_label)}}, et faire sauter l'exécution du code vers l'étiquette (''to branch'' en anglais) en utilisant {{fname|b(mon_label)}}, ou un branchement conditionnel tel que {{fname|bgt(mon_label)}}.
   −
The following example flashes the green LED. It flashes it {{fname|r0}} times.
+
L'example de code suivant fait clignoter la LED vertes. La LED clignotera {{fname|r0}} fois.
    
  <nowiki>@micropython.asm_thumb
 
  <nowiki>@micropython.asm_thumb
 
def flash_led(r0):
 
def flash_led(r0):
     # get the GPIOA address in r1
+
     # placer l'adresse GPIOA dans r1
 
     movwt(r1, stm.GPIOA)
 
     movwt(r1, stm.GPIOA)
   −
     # get the bit mask for PA14 (the pin LED #2 is on)
+
     # obtenir un masque de bits pour PA14 (broche de la LED #2)
 
     movw(r2, 1 << 14)
 
     movw(r2, 1 << 14)
   Ligne 69 : Ligne 69 :  
     label(loop1)
 
     label(loop1)
   −
     # turn LED on
+
     # allumer la LED
 
     strh(r2, [r1, stm.GPIO_BSRRL])
 
     strh(r2, [r1, stm.GPIO_BSRRL])
   −
     # delay for a bit
+
     # attendre un moment
 
     movwt(r4, 5599900)
 
     movwt(r4, 5599900)
 
     label(delay_on)
 
     label(delay_on)
Ligne 79 : Ligne 79 :  
     bgt(delay_on)
 
     bgt(delay_on)
   −
     # turn LED off
+
     # éteindre la LED
 
     strh(r2, [r1, stm.GPIO_BSRRH])
 
     strh(r2, [r1, stm.GPIO_BSRRH])
   −
     # delay for a bit
+
     # Attendre un peu
 
     movwt(r4, 5599900)
 
     movwt(r4, 5599900)
 
     label(delay_off)
 
     label(delay_off)
Ligne 89 : Ligne 89 :  
     bgt(delay_off)
 
     bgt(delay_off)
   −
     # loop r0 times
+
     # boucler r0 fois
 
     sub(r0, r0, 1)
 
     sub(r0, r0, 1)
 
     label(loop_entry)
 
     label(loop_entry)
29 917

modifications

Menu de navigation