#pragma GCC optimize ("Og")
#include "ArduinoTrace.h"
// volatile uint8_t a=9, b=6, c=6; //prueba 1
// volatile uint8_t a=5, b=4, c=5; //prueba 2
volatile uint8_t a=5, b=8, c=8; //prueba 3
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
addressInfo();
Serial.println("INICIO:");
//------------- Proceso en alto nivel -------------------
// if (a>=b && b==c)
// {
// a=a+b;
// }
// else
// {
// a=a+6;
// }
//--------------------------------------------------------
//------------- Proceso en lenguaje ensamblador ----------
// if (a>=b && b==c)
// {
asm volatile(
"lds r16, a \n"
"lds r17, b \n"
"cp r16, r17 \n" //a-b
"brsh cond2 \n"
"rjmp else1 \n"
"cond2: "
"lds r16, b \n"
"lds r17, c \n"
"cp r16, r17 \n" //b-c
"breq true1 \n"
"rjmp else1 \n"
);
asm volatile("true1: ");
a=a+b;
asm volatile("rjmp endif1");
// }
// else
// {
asm volatile("else1: ");
a=a+6;
// }
asm volatile("endif1: ");
//--------------------------------------------------------
DUMP(a);
DUMP(b);
DUMP(c);
}
void loop() {
}
void addressInfo()
{
Serial.println("DIRECCIONES de VARIABLES (HEX):");
Serial.print("a: ");
Serial.println((int)&a,HEX); //direccion de a
Serial.print("b: ");
Serial.println((int)&b,HEX); //direccion de b
Serial.print("c: ");
Serial.println((int)&c,HEX); //direccion de c
}