i want to convert this program from C language to Assembly langauge #include \"s
ID: 3886416 • Letter: I
Question
i want to convert this program from C language to Assembly langauge
#include "stdio.h"
int main()
{
int i, a, b, c, d, e, f, j, k, l, m, s;
j = 0;
k = 0;
l = 0;
m = 0;
s = 0;
printf("Input UCF NID ");
scanf("%d", &a);
scanf("%d", &b);
scanf("%d", &c);
scanf("%d", &d);
scanf("%d", &e);
scanf("%d", &f);
for (i = 0; i < b; i++){
j = j + a;
};
for (i = 0; i < 18; i++) {
k = k + c;
};
for (i = 0; i < 9; i++) {
l = l + d;
};
for (i = 0; i < e; i++) {
m = m + f;
};
s = (j + k - l - m);
printf("S_ten = %d ", s);
int n;
int x = s;
printf("S_two = ");
for (n = 31; n >= 0; n--)
{
putchar('0' + ((x >> n) & 1));
}
printf(" ");
return 0;
}
Explanation / Answer
We use g++ compiler to turn provided C code into assembly language. To see the assembly code generated by the C compiler, we can use the “-S” option on the command line:
This will cause gcc to run the compiler, generating an assembly file. Suppose we write a C code and store it in a file name “filename.c”
This will cause gcc to run the compiler, generating an assembly file filename.s, and go no further. (Normally it would then invoke the assembler to generate an object- code file.)
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.