#pragma GCC optimize ("Og")
#include "ArduinoTrace.h"
volatile int8_t x = 3,y = 3,z,w;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
Serial.println("INICIO");
//------------- Proceso en alto nivel -------------------
// if(x<y)
// {
// goto then1 (z=x+y);
// }
// else
// {
// goto else1 (w=x-y);
// }
//--------------------------------------------------------
cond:
asm goto(
"lds r16,x \n" // r16 <--- (x)
"lds r17,y \n" // r17 <--- (y)
"cp r16,r17 \n" // (x) - (y)
"brlt %l[then1] \n" // if x < y (branch if less than) goto then1
"jmp %l[else1]" // else goto else1
::::then1,else1
);
then1:{
asm goto(
"add r16,r17 \n" // r16 <--- (x) + (y)
"sts z,r16 \n" // z <--- (x) + (y)
"jmp %l[endif1] \n" // goto endif1
::::endif1
);
}
else1:{
asm volatile(
"sub r16,r17 \n" // r16 <--- (x) - (y)
"sts w,r16" // w <--- (x) - (y)
);
}
endif1: {
}
DUMP(x);
DUMP(y);
DUMP(z);
DUMP(w);
}
void loop() {
}