/*Given below is a code snippet in C showing a function that finds the
smallest of 2 numbers :
int get_smallest(int x,int y){
int smallest;
if(x<=y){
goto assign_x;
}
smallest=y;
goto done;
assign_x:
smallest=x;
done:
return smallest;
Write the complete program (to be run in Rapberry Pi Pico) where:
- The C Program should get the inputs (2 numbers) from the user and call the assembly
function
- The assembly function should compare and find the smallest number among the 2 inputs
and return the smallest one to the C program.*/
#include <stdio.h>
#include <stdlib.h>
extern "C"{
int get_smallest(int x,int y); //2 parameters.
}
void setup() {
Serial1.begin(9600); //initialising the serial port.
}
int main()
{
int x,y, smallest;
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.
smallest = get_smallest(x,y);
printf("\nThe smaller number is : %d \n",smallest);
}