Question

Write an assembly language program that corresponds to the following C program: int width; int length;...

Write an assembly language program that corresponds to the following C program:

int width;

int length;

int perim;

int main () {

scanf ("%d%d", &width, &length);

perim = (width + length) * 2;

printf ("width = %d\n", width);

printf ("length = %d\n\n", width);

printf ("perim = %d\n", perim);

return 0;

}

0 0
Add a comment Improve this question Transcribed image text
Answer #1

.Ltext0:

.LC0:

.string "%d%d"

.LC1:

.string "width = %d\n"

.LC2:

.string "length = %d\n\n"

.LC3:

.string "perim = %d\n"

main:

.LFB0:

push rbp

mov rbp, rsp

mov edx, OFFSET FLAT:length

mov esi, OFFSET FLAT:width

mov edi, OFFSET FLAT:.LC0

mov eax, 0

call scanf

mov edx, DWORD PTR width[rip]

mov eax, DWORD PTR length[rip]

add eax, edx

add eax, eax

mov DWORD PTR perim[rip], eax

mov eax, DWORD PTR width[rip]

mov esi, eax

mov edi, OFFSET FLAT:.LC1

mov eax, 0

call printf

mov eax, DWORD PTR width[rip]

mov esi, eax

mov edi, OFFSET FLAT:.LC2

mov eax, 0

call printf

mov eax, DWORD PTR perim[rip]

mov esi, eax

mov edi, OFFSET FLAT:.LC3

mov eax, 0

call printf

mov eax, 0

pop rbp

ret

f → C .godbolt.org G COMPILER EXPLORER Add... More Support diversity in C++ with #include <C++> * Share Other Policies C sour

Add a comment
Know the answer?
Add Answer to:
Write an assembly language program that corresponds to the following C program: int width; int length;...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT