Advertisement
CosminVarlan

15. brne = Branch if not equal (!=0) (ASM)

Dec 16th, 2021
1,215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. volatile byte v = 2;
  2. volatile byte cnt = 5;
  3.  
  4. void setup()
  5. {
  6.   Serial.begin(9600);
  7.   asm(
  8.     "1: \n"
  9.     "lsl %0 \n"
  10.     "dec %1 \n" // reg %1 face "--"
  11.     "brne 1b \n" // daca nu e egal cu 0 sari la 1 (b = backward)  
  12.     : "+r" (v): "r" (cnt)
  13.     );
  14.     Serial.println(v); // 2<<5 = 2 * (2*2*2*2*2) = 64
  15. }
  16.  
  17. void loop(){}
  18.  
  19.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement