Convert the for loop Into MIPS Instructions Use the sit inst
Solution
Answer:
a)
.zero 1
 main:
 push rbp
 mov rbp, rsp
 mov DWORD PTR [rbp-8], 1
 .L3:
 cmp DWORD PTR [rbp-8], 6
 jg .L2
 mov eax, DWORD PTR [rbp-8]
 add DWORD PTR [rbp-4], eax
 add DWORD PTR [rbp-8], 1
 jmp .L3
 .L2:
 mov eax, 0
 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 .L7
 cmp DWORD PTR [rbp-8], 65535
 jne .L7
 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
 .L7:
 nop
 leave
 ret
 push rbp
 mov rbp, rsp
 mov esi, 65535
 mov edi, 1
 call __static_initialization_and_destruction_0(int, int)
 pop rbp
 ret
b)
.zero 1
 main:
 push rbp
 mov rbp, rsp
 mov eax, DWORD PTR [rbp-4]
 cmp eax, DWORD PTR [rbp-8]
 jle .L2
 mov eax, DWORD PTR [rbp-4]
 cmp eax, DWORD PTR [rbp-12]
 jge .L2
 mov eax, DWORD PTR [rbp-4]
 cdqe
 mov DWORD PTR [rbp-96+rax*4], 1
 jmp .L3
 .L2:
 mov eax, DWORD PTR [rbp-4]
 cdqe
 mov DWORD PTR [rbp-96+rax*4], 0
 .L3:
 mov eax, 0
 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 .L7
 cmp DWORD PTR [rbp-8], 65535
 jne .L7
 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
 .L7:
 nop
 leave
 ret
 push rbp
 mov rbp, rsp
 mov esi, 65535
 mov edi, 1
 call __static_initialization_and_destruction_0(int, int)
 pop rbp
 ret


