/* Write ARM assembly functions for:
a) Function to take two unsigned parameters, and performs an ADD operation.
b) Function to Read the flag bits from the PSR.
Return both outputs to the main function.
Function prototype: lab5_act_1_1_add(int, int)
lab5_act_1_1_flag(int, int) */
#include <stdio.h>
#include <stdlib.h>
extern "C"{
unsigned int lab5_act_1_1_add(int x, int y); //2 parameters.
unsigned int lab5_act_1_1_flag(int x, int y);
}
void setup() {
Serial1.begin(9600); //initialising the serial port.
}
int main()
{
int x,y,result_add,result_flag;
printf("Enter the 1st value: ");
scanf("%d",&x);
printf("%d\n",x); //to make sure it shows up on the serial monitor.
printf("Enter the 2nd value: ");
scanf("%d",&y);
printf("%d\n",y); //to make sure it shows up on the serial monitor.
result_add = lab5_act_1_1_add(x,y);
result_flag = lab5_act_1_1_flag(x,y);
printf("Result of addition: %d\n", result_add);
printf("Flag bits from PSR: %X\n", result_flag);
// Serial1.println(result_flag, HEX);
}