Question

Convert the following program into MIPS Instructio
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Answer:

MIPS Assembly Language Code:

.zero 1
main:
push rbp
mov rbp, rsp
sub rsp, 16
mov DWORD PTR [rbp-4], 0
mov DWORD PTR [rbp-8], 10
mov DWORD PTR [rbp-12], 100
mov edx, DWORD PTR [rbp-12]
mov ecx, DWORD PTR [rbp-8]
mov eax, DWORD PTR [rbp-4]
mov esi, ecx
mov edi, eax
call isSorted(int, int, int)
mov DWORD PTR [rbp-16], eax
cmp DWORD PTR [rbp-16], 0
jne .L2
mov edx, DWORD PTR [rbp-4]
mov ecx, DWORD PTR [rbp-8]
mov eax, DWORD PTR [rbp-12]
mov esi, ecx
mov edi, eax
call isSorted(int, int, int)
.L2:
mov eax, 0
leave
ret
isSorted(int, int, int):
push rbp
mov rbp, rsp
mov DWORD PTR [rbp-4], edi
mov DWORD PTR [rbp-8], esi
mov DWORD PTR [rbp-12], edx
mov eax, DWORD PTR [rbp-4]
cmp eax, DWORD PTR [rbp-8]
jge .L5
mov eax, DWORD PTR [rbp-8]
cmp eax, DWORD PTR [rbp-12]
jge .L5
mov eax, 1
jmp .L6
.L5:
mov eax, 0
.L6:
pop rbp
ret
__static_initialization_and_destruction_0(int, int):
push rbp
mov rbp, rsp
sub rsp, 16
mov DWORD PTR [rbp-4], edi
mov DWORD PTR [rbp-8], esi
cmp DWORD PTR [rbp-4], 1
jne .L9
cmp DWORD PTR [rbp-8], 65535
jne .L9
mov edi, OFFSET FLAT:std::__ioinit
call std::ios_base::Init::Init()
mov edx, OFFSET FLAT:__dso_handle
mov esi, OFFSET FLAT:std::__ioinit
mov edi, OFFSET FLAT:std::ios_base::Init::~Init()
call __cxa_atexit

Add a comment
Know the answer?
Add Answer to:
Convert the following program into MIPS Instructions: int a = 0; int b = 10; int...
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