Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Hello, I need help translating my code into assembly x86 AT&T Syntax, and not us

ID: 3835884 • Letter: H

Question

Hello, I need help translating my code into assembly x86 AT&T Syntax, and not using the -s to compile it into a .s file.
I need 'a' to be a label with 4 bytes of space, and 'b' to be a label with 4 bytes of space.
Also, place the upper 32 bits of the product into EDX
and the lower 32 bits of the product into EAX
Thank you!

This is my code:

#include <stdio.h>
#include <stdlib.h>

long long mult(long long a, long long b) {
long long ret = 0;

while (b) {
if (b & 1) ret += a;
a <<= 1;
b >>= 1;
}
return ret;
}

int main(int argc, char *argv[]) {
unsigned int a = 0;
unsigned int b = 0;

sscanf(argv[1], "%u", &a);
sscanf(argv[2], "%u", &b);
printf("%u * %u = %llu ", a, b, mult(a, b));
}

Explanation / Answer

try in assembler compiler to execute the code

#include <stdio.h>
#include <stdlib.h>

long long mult(long long a, long long b) {
long long ret = 0;

while (b) {
if (b & 1) ret += a;
a <<= 1;
b >>= 1;
}
return ret;
}

int main(int argc, char *argv[]) {
unsigned int a = 0;
unsigned int b = 0;

sscanf(argv[1], "%u", &a);
sscanf(argv[2], "%u", &b);
printf("%u * %u = %llu ", a, b, mult(a, b));
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote