Question

Please write an assembly language for: int a = 15; int b =5; if ((a>=5 &&...

Please write an assembly language for:

int a = 15;

int b =5;

if ((a>=5 && a<=15) || (b>=2 && b<=14)){

a =a+4;

b = b-2;

}

else{

a = a-2;

b=b-5;

}

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

assembly Language equivalent for the c code is given below , its is compiled using x86-64 gcc 9.1 version

Answer:

main:

push rbp

mov rbp, rsp

mov DWORD PTR [rbp-4], 15

mov DWORD PTR [rbp-8], 5

cmp DWORD PTR [rbp-4], 4

jle .L2

cmp DWORD PTR [rbp-4], 15

jle .L3

.L2:

cmp DWORD PTR [rbp-8], 1

jle .L4

cmp DWORD PTR [rbp-8], 14

jg .L4

.L3:

add DWORD PTR [rbp-4], 4

sub DWORD PTR [rbp-8], 2

jmp .L5

.L4:

sub DWORD PTR [rbp-4], 2

sub DWORD PTR [rbp-8], 5

.L5:

mov eax, 0

pop rbp

ret

Add a comment
Know the answer?
Add Answer to:
Please write an assembly language for: int a = 15; int b =5; if ((a>=5 &&...
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