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

Using the acceptable range of general purpose registers, write the equivalent AR

ID: 3840501 • Letter: U

Question

Using the acceptable range of general purpose registers, write the equivalent ARM inline assembly code from the x86 code snippet below that outputs the sum of two input integers. Your ARM code can be written in the space to the right of the original x86 code: #include "stdio.h" #include int main(void){int x, y, sum; printf("Enter an integer: "scanf_s("%d", &x;); printf ("Enter a second integer: "); scanf_s ("%d", &ty;);//find the sum _asm {MOV EAX, x//move x into EAX; MOV EBX, y//move y into EBX; ADD EAX, EBX MOV sum, EAX} printf("Addition result = %d ", sum); return 0; em ("pause")

Explanation / Answer

asm(" movl %1,%0;" // here we are reading the values
" addl %2,%0;" // just Add those values
: "=&r" (Sum)
: "r" (x), "r" (y)
);

In this Fuction we are not using any temporary registors.

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