/* Write an assembly function that performs the sum of four constants 10, 20, 30 and 40, and returns the result.
Function name:
int my_asm_add_four_constants(void) */
#include <stdio.h>
#include <stdlib.h>
void myPrint(char * fnName, unsigned int result);
extern "C"{
unsigned int my_asm_add_four_constants(void);
}
void setup() {
// put your setup code here, to run once:
Serial1.begin(9600);
pinMode(LED_BUILTIN,OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
unsigned int asm_ret_val;
asm_ret_val = my_asm_add_four_constants();
myPrint("my_asm_add_four_constants()",asm_ret_val);
digitalWrite(LED_BUILTIN,HIGH);
delay(1000);
digitalWrite(LED_BUILTIN,LOW);
delay(1000);
}
void myPrint(char * fnName, unsigned int result)
{
Serial1.print("The value returned from the assembly fn ");
Serial1.print(fnName);
Serial1.print(" : ");
Serial1.println(result);
}
/* NOTE : ONLY THE VALUE IN R0 GETS RETURNED --> EITHER MOVE THE VALUE TO R0. */