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

For this project, you will write a MIPS assembly language program to calculate t

ID: 3862863 • Letter: F

Question

For this project, you will write a MIPS assembly language program to calculate the summation of a series of numbers. You will take three parameters as input: A starting index, the number of integers in the series, and the distance between two numbers in the series. Your program should check that the user has entered reasonable data before attempting to process the request. After computing the summation, it should display the series and the summation. After each set of input, you should ask the user if they wish to continue. Your program should include appropriate comments indicating what the code should be doing and what registers are being used for. After displaying the results, your program should exit cleanly. Your programs should be turned in through HuskyCT before class starts on the due date. You should test your programs using the SPIM simulator to ensure their functionality before submitting them. Example output: Enter the first integer in the series: 5 Enter the number of integers in the series: 3 Enter the offset between integers in the series: 4 The series is: 5, 9, 13. The summation of the series is 27. Would you like to calculate another summation (Y/N)? y Enter the first integer in the series: 4 Enter the number of integers in the series: 5 Enter the offset between integers in the series: 27 The series is 4, 31, 58, 85, 112. The summation of the series is 290. Would you like to calculate another summation (Y/N)? Y Enter the first integer in the series: -16 Enter the number of integers in the series: -22 There must be a positive number of integers in the series. Would you like to calculate another summation (Y/N)? n Objectives: 1. To practice writing MIPS assembly language programs. 2. To introduce and practice working with conditional statements. 3. To introduce and practice building loop structures.

Explanation / Answer

Answer:

MIPS Assembly Language Code :

.LC0:
        .string "1+2+3+……+n"
.LC1:
        .string "nEnter the value of n:"
.LC2:
        .string "nSum="
main:
        push    rbp
        mov     rbp, rsp
        sub     rsp, 16
        mov     DWORD PTR [rbp-8], 0
        mov     esi, OFFSET FLAT:.LC0
        mov     edi, OFFSET FLAT:std::cout
        call    std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)
        mov     esi, OFFSET FLAT:.LC1
        mov     edi, OFFSET FLAT:std::cout
        call    std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)
        lea     rax, [rbp-12]
        mov     rsi, rax
        mov     edi, OFFSET FLAT:std::cin
        call    std::basic_istream<char, std::char_traits<char> >::operator>>(int&)
        mov     DWORD PTR [rbp-4], 1
.L3:
        mov     eax, DWORD PTR [rbp-12]
        cmp     DWORD PTR [rbp-4], eax
        jg      .L2
        mov     eax, DWORD PTR [rbp-4]
        add     DWORD PTR [rbp-8], eax
        add     DWORD PTR [rbp-4], 1
        jmp     .L3
.L2:
        mov     esi, OFFSET FLAT:.LC2
        mov     edi, OFFSET FLAT:std::cout
        call    std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)
        mov     rdx, rax
        mov     eax, DWORD PTR [rbp-8]
        mov     esi, eax
        mov     rdi, rdx
        call    std::basic_ostream<char, std::char_traits<char> >::operator<<(int)
        mov     eax, 0
        leave
        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
_GLOBAL__sub_I_main:
        push    rbp
        mov     rbp, rsp
        mov     esi, 65535
        mov     edi, 1
        call    __static_initialization_and_destruction_0(int, int)
        pop     rbp
        ret

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