/* Given below is a code snippet in C showing a function that increments the input
by 1 if the input is greater than 0 :
int inc_by_1(int n){
if(n<=0)
return 0;
return n+1
Write the complete program (to be run in Rapberry Pi Pico) where:
- The C Program should get the input from the user and call the assembly
function
- The assembly function should perform the increment based on the condition and return
the result to the C program.
*/
#include <stdio.h>
#include <stdlib.h>
extern "C"{
int inc_by_1(int x); //2 parameters.
}
void setup() {
Serial1.begin(9600); //initialising the serial port.
}
int main()
{
int x,newVal;
printf("Enter the number: ");
scanf("%d",&x);
printf("%d\n",x); //to make sure it shows up on the serial monitor.
newVal = inc_by_1(x);
printf("\nThe new number is : %d \n", newVal);
}