Write the assembly code in AT&T syntax for digits.c and height.c intended for people to be able to read it, not in assembly compiled and generated by a machine. They are both in C. Write the assembly code for both as separate assignments.
Code:
digits.c
#include
//Global input variable
int input = 247; // 0<=input<1000
//Global output variable declarations
int ones = 0;
int tens = 0;
int hundreds = 0;
int main(){
int temp = input;
ones = temp%10;
temp /= 10;
tens = temp%10;
temp /= 10;
hundreds = temp;
printf("Input: %d\n",input);
printf("Ones: %d\n",ones);
printf("Tens: %d\n",tens);
printf("Hundreds: %d\n",hundreds);
}
height.c
#include
#include
#define g 9.8
//Global input variable
double velocity = 24.7; // unit: m/s
//Global output variable declarations
double height;
int main(){
//Formula used: height = (1/2) * (((velocity)^2)/g)
height = (1.0/2) * ((pow(velocity,2))/g);
printf("Initial Velocity: %lf m/s\n",velocity);
printf("Height: %lf m\n",height);
}
Sid M.
05/27/21