Question

Write a program in MIPS ASSEMBLY LANGUAGE.. Take no of students as input from the user,...

Write a program in MIPS ASSEMBLY LANGUAGE..
Take no of students as input from the user, then take marks of 5 subjects for each student from the user.
Then find Minimun, Maximum and Median of all the subjects. and comment each line in code

also make flow chart

Homework Answers

Answer #1

MIPS Code as follows:

.LC0:

        .ascii  "Enter the limit:\000"

.LC1:

        .ascii  "Enter the name of \000"

.LC2:

        .ascii  "th student:\000"

.LC3:

        .ascii  "Enter the mark:\000"

.LC4:

        .ascii  "Menu\000"

.LC5:

        .ascii  "1.Minimum\000"

.LC6:

        .ascii  "2.Maximum\000"

.LC7:

        .ascii  "3.Median\000"

.LC8:

        .ascii  "4.Enter your choice:\000"

.LC9:

        .ascii  "Minimum Marks among 5 subject is:\000"

.LC10:

        .ascii  "Maximum Marks among 5 subject is:\000"

.LC11:

        .ascii  "Median among 5 subject is :\000"

.LC12:

        .ascii  "Wrong Choice\000"

main:

        daddiu  $sp,$sp,-112

        sd      $31,104($sp)

        sd      $fp,96($sp)

        sd      $28,88($sp)

        move    $fp,$sp

        lui     $28,%hi(%neg(%gp_rel(main)))

        daddu   $28,$28,$25

        daddiu  $28,$28,%lo(%neg(%gp_rel(main)))

        ld      $2,%got_page(.LC0)($28)

        daddiu  $5,$2,%got_ofst(.LC0)

        ld      $4,%got_disp(_ZSt4cout)($28)

        ld      $2,%call16(_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc)($28)

        move    $25,$2

        nop

        daddiu  $2,$fp,68

        move    $5,$2

        ld      $4,%got_disp(_ZSt3cin)($28)

        ld      $2,%call16(_ZNSirsERi)($28)

        move    $25,$2

        nop

        sw      $0,0($fp)

.L5:

        lw      $2,68($fp)

        lw      $3,0($fp)

        slt     $2,$3,$2

        beq     $2,$0,.L2

        nop

        ld      $2,%got_page(.LC1)($28)

        daddiu  $5,$2,%got_ofst(.LC1)

        ld      $4,%got_disp(_ZSt4cout)($28)

        ld      $2,%call16(_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc)($28)

        move    $25,$2

        nop

        move    $3,$2

        lw      $2,0($fp)

        move    $5,$2

        move    $4,$3

        ld      $2,%call16(_ZNSolsEi)($28)

        move    $25,$2

        nop

        move    $3,$2

        ld      $2,%got_page(.LC2)($28)

        daddiu  $5,$2,%got_ofst(.LC2)

        move    $4,$3

        ld      $2,%call16(_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc)($28)

        move    $25,$2

        nop

        daddiu  $3,$fp,24

        lw      $2,0($fp)

        daddu   $2,$3,$2

        move    $5,$2

        ld      $4,%got_disp(_ZSt3cin)($28)

        ld      $2,%call16(_ZStrsIcSt11char_traitsIcEERSt13basic_istreamIT_T0_ES6_RS3_)($28)

        move    $25,$2

        nop

        ld      $2,%got_page(.LC3)($28)

        daddiu  $5,$2,%got_ofst(.LC3)

        ld      $4,%got_disp(_ZSt4cout)($28)

        ld      $2,%call16(_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc)($28)

        move    $25,$2

        nop

        sw      $0,4($fp)

.L4:

        lw      $2,4($fp)

        slt     $2,$2,5

        beq     $2,$0,.L3

        nop

        daddiu  $3,$fp,48

        lw      $2,4($fp)

        dsll    $2,$2,2

        daddu   $2,$3,$2

        move    $5,$2

        ld      $4,%got_disp(_ZSt3cin)($28)

        ld      $2,%call16(_ZNSirsERi)($28)

        move    $25,$2

        nop

        lw      $2,4($fp)

        addiu   $2,$2,1

        sw      $2,4($fp)

        b       .L4

        nop

.L3:

        lw      $2,0($fp)

        addiu   $2,$2,1

        sw      $2,0($fp)

        b       .L5

        nop

.L2:

        ld      $2,%got_page(.LC4)($28)

        daddiu  $5,$2,%got_ofst(.LC4)

        ld      $4,%got_disp(_ZSt4cout)($28)

        ld      $2,%call16(_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc)($28)

        move    $25,$2

        nop

        ld      $2,%got_page(.LC5)($28)

        daddiu  $5,$2,%got_ofst(.LC5)

        ld      $4,%got_disp(_ZSt4cout)($28)

        ld      $2,%call16(_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc)($28)

        move    $25,$2

        nop

        ld      $2,%got_page(.LC6)($28)

        daddiu  $5,$2,%got_ofst(.LC6)

        ld      $4,%got_disp(_ZSt4cout)($28)

        ld      $2,%call16(_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc)($28)

        move    $25,$2

        nop

        ld      $2,%got_page(.LC7)($28)

        daddiu  $5,$2,%got_ofst(.LC7)

        ld      $4,%got_disp(_ZSt4cout)($28)

        ld      $2,%call16(_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc)($28)

        move    $25,$2

        nop

        ld      $2,%got_page(.LC8)($28)

        daddiu  $5,$2,%got_ofst(.LC8)

        ld      $4,%got_disp(_ZSt4cout)($28)

        ld      $2,%call16(_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc)($28)

        move    $25,$2

        nop

        daddiu  $2,$fp,72

        move    $5,$2

        ld      $4,%got_disp(_ZSt3cin)($28)

        ld      $2,%call16(_ZNSirsERi)($28)

        move    $25,$2

        nop

        lw      $2,72($fp)

        li      $3,2                        # 0x2

        beq     $2,$3,.L7

        nop

        li      $3,3                        # 0x3

        beq     $2,$3,.L8

        nop

        li      $3,1                        # 0x1

        bne     $2,$3,.L21

        nop

        lw      $2,48($fp)

        sw      $2,12($fp)

        sw      $0,4($fp)

.L12:

        lw      $2,4($fp)

        slt     $2,$2,5

        beq     $2,$0,.L10

        nop

        lw      $2,4($fp)

        dsll    $2,$2,2

        daddu   $2,$fp,$2

        lw      $2,48($2)

        lw      $3,12($fp)

        slt     $2,$2,$3

        beq     $2,$0,.L11

        nop

        lw      $2,4($fp)

        dsll    $2,$2,2

        daddu   $2,$fp,$2

        lw      $2,48($2)

        sw      $2,12($fp)

.L11:

        lw      $2,4($fp)

        addiu   $2,$2,1

        sw      $2,4($fp)

        b       .L12

        nop

.L10:

        ld      $2,%got_page(.LC9)($28)

        daddiu  $5,$2,%got_ofst(.LC9)

        ld      $4,%got_disp(_ZSt4cout)($28)

        ld      $2,%call16(_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc)($28)

        move    $25,$2

        nop

        move    $3,$2

        lw      $2,12($fp)

        move    $5,$2

        move    $4,$3

        ld      $2,%call16(_ZNSolsEi)($28)

        move    $25,$2

        nop

        b       .L13

        nop

.L7:

        lw      $2,48($fp)

        sw      $2,8($fp)

        sw      $0,4($fp)

.L16:

        lw      $2,4($fp)

        slt     $2,$2,5

        beq     $2,$0,.L14

        nop

        lw      $2,4($fp)

        dsll    $2,$2,2

        daddu   $2,$fp,$2

        lw      $2,48($2)

        lw      $3,8($fp)

        slt     $2,$3,$2

        beq     $2,$0,.L15

        nop

        lw      $2,4($fp)

        dsll    $2,$2,2

        daddu   $2,$fp,$2

        lw      $2,48($2)

        sw      $2,8($fp)

.L15:

        lw      $2,4($fp)

        addiu   $2,$2,1

        sw      $2,4($fp)

        b       .L16

        nop

.L14:

        ld      $2,%got_page(.LC10)($28)

        daddiu  $5,$2,%got_ofst(.LC10)

        ld      $4,%got_disp(_ZSt4cout)($28)

        ld      $2,%call16(_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc)($28)

        move    $25,$2

        nop

        move    $3,$2

        lw      $2,8($fp)

        move    $5,$2

        move    $4,$3

        ld      $2,%call16(_ZNSolsEi)($28)

        move    $25,$2

        nop

        b       .L13

        nop

.L8:

        sw      $0,16($fp)

        sw      $0,4($fp)

.L18:

        lw      $2,4($fp)

        slt     $2,$2,5

        beq     $2,$0,.L17

        nop

        lw      $2,4($fp)

        dsll    $2,$2,2

        daddu   $2,$fp,$2

        lw      $2,48($2)

        lw      $3,16($fp)

        addu    $2,$3,$2

        sw      $2,16($fp)

        lw      $2,4($fp)

        addiu   $2,$2,1

        sw      $2,4($fp)

        b       .L18

        nop

.L17:

        lw      $5,16($fp)

        move    $4,$5

        move    $3,$4

        dsll    $2,$3,1

        move    $3,$2

        dsll    $2,$3,2

        dsubu   $2,$2,$3

        dsll    $3,$2,4

        daddu   $2,$2,$3

        dsll    $3,$2,8

        daddu   $2,$2,$3

        dsll    $3,$2,16

        daddu   $2,$2,$3

        daddu   $2,$2,$4

        dsrl    $2,$2,32

        sll     $2,$2,0

        sra     $3,$2,1

        sra     $2,$5,31

        subu    $2,$3,$2

        mtc1    $2,$f0

        cvt.s.w $f0,$f0

        swc1    $f0,20($fp)

        ld      $2,%got_page(.LC11)($28)

        daddiu  $5,$2,%got_ofst(.LC11)

        ld      $4,%got_disp(_ZSt4cout)($28)

        ld      $2,%call16(_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc)($28)

        move    $25,$2

        nop

        lwc1    $f13,20($fp)

        move    $4,$2

        ld      $2,%call16(_ZNSolsEf)($28)

        move    $25,$2

        nop

        b       .L13

        nop

.L21:

        ld      $2,%got_page(.LC12)($28)

        daddiu  $5,$2,%got_ofst(.LC12)

        ld      $4,%got_disp(_ZSt4cout)($28)

        ld      $2,%call16(_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc)($28)

        move    $25,$2

        nop

        nop

.L13:

        lw      $3,72($fp)

        li      $2,3                        # 0x3

        beq     $3,$2,.L19

        nop

        b       .L2

        nop

.L19:

        move    $2,$0

        move    $sp,$fp

        ld      $31,104($sp)

        ld      $fp,96($sp)

        ld      $28,88($sp)

        daddiu  $sp,$sp,112

        j       $31

        nop

__static_initialization_and_destruction_0(int, int):

        daddiu  $sp,$sp,-48

        sd      $31,40($sp)

        sd      $fp,32($sp)

        sd      $28,24($sp)

        move    $fp,$sp

        lui     $28,%hi(%neg(%gp_rel(__static_initialization_and_destruction_0(int, int))))

        daddu   $28,$28,$25

        daddiu  $28,$28,%lo(%neg(%gp_rel(__static_initialization_and_destruction_0(int, int))))

        move    $3,$4

        move    $2,$5

        sll     $3,$3,0

        sw      $3,0($fp)

        sll     $2,$2,0

        sw      $2,4($fp)

        lw      $3,0($fp)

        li      $2,1                        # 0x1

        bne     $3,$2,.L24

        nop

        lw      $3,4($fp)

        li      $2,65535                    # 0xffff

        bne     $3,$2,.L24

        nop

        ld      $2,%got_page(_ZStL8__ioinit)($28)

        daddiu  $4,$2,%got_ofst(_ZStL8__ioinit)

        ld      $2,%call16(_ZNSt8ios_base4InitC1Ev)($28)

        move    $25,$2

        nop

        ld      $6,%got_disp(__dso_handle)($28)

        ld      $2,%got_page(_ZStL8__ioinit)($28)

        daddiu  $5,$2,%got_ofst(_ZStL8__ioinit)

        ld      $4,%got_disp(_ZNSt8ios_base4InitD1Ev)($28)

        ld      $2,%call16(__cxa_atexit)($28)

        move    $25,$2

        nop

.L24:

        nop

        move    $sp,$fp

        ld      $31,40($sp)

        ld      $fp,32($sp)

        ld      $28,24($sp)

        daddiu  $sp,$sp,48

        j       $31

        nop

_GLOBAL__sub_I_main:

        daddiu  $sp,$sp,-32

        sd      $31,24($sp)

        sd      $fp,16($sp)

        sd      $28,8($sp)

        move    $fp,$sp

        lui     $28,%hi(%neg(%gp_rel(_GLOBAL__sub_I_main)))

        daddu   $28,$28,$25

        daddiu  $28,$28,%lo(%neg(%gp_rel(_GLOBAL__sub_I_main)))

        li      $5,65535                    # 0xffff

        li      $4,1                        # 0x1

        ld      $2,%got_page(__static_initialization_and_destruction_0(int, int))($28)

        daddiu  $2,$2,%got_ofst(__static_initialization_and_destruction_0(int, int))

        move    $25,$2

        nop

        move    $sp,$fp

        ld      $31,24($sp)

        ld      $fp,16($sp)

        ld      $28,8($sp)

        daddiu  $sp,$sp,32

        j       $31

        nop

#include <iostream>
using namespace std;

int main() 
{
    char name[20];
    int marks[5];
    
    int i,j,n,ch,t,temp,sum;
    float median;
    
    
    cout<<"Enter the limit:";
    cin>>n;
    
    for(i=0;i<n;i++)
    {
        cout<<"Enter the name of "<<i<<"th student:";
        cin>>name[i];
        cout<<"Enter the mark:";
        for(j=0;j<5;j++)
            cin>>marks[j];
    }
    
    do
    {
        cout<<"Menu";
        cout<<"1.Minimum";
        cout<<"2.Maximum";
        cout<<"3.Median";
        cout<<"4.Enter your choice:";
        cin>>ch;
        switch(ch)
        {
            case 1:
                    temp = marks[0];
                    for(j=0;j<5;j++)
                    {
                        
                        if(temp>marks[j])
                        {
                            temp=marks[j];
                        }
                    }
                    cout<<"Minimum Marks among 5 subject is:"<<temp;
                    break;
            case 2 :
                    t = marks[0];
                    for(j=0;j<5;j++)
                    {
                        
                        if(t<marks[j])
                        {
                            t=marks[j];
                        }
                    }
                    cout<<"Maximum Marks among 5 subject is:"<<t;
                    break;
            case 3:
                    sum=0;
                    for(j=0;j<5;j++)
                    {
                        sum= sum+marks[j];
                    }
                    median = sum/5;
                    cout<<"Median among 5 subject is :"<<median;
                    break;
                    
            default:
                    cout<<"Wrong Choice";
                    break;
        }
        
    }
    
  while(ch!=3);  
return 0;
}
Know the answer?
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
Similar Questions
write a MIPS assembly program to get an integer input from the user and multiply it...
write a MIPS assembly program to get an integer input from the user and multiply it by 2 and print output to the console
Write a mips assembly language program that asks the user to enter and integer number and...
Write a mips assembly language program that asks the user to enter and integer number and read it. Then ask him to enter a bit position (between 0 and 31) and display the value of that bit.
Write and test code in MIPS assembly language program to implement algorithms "The Non-Restoring Algorithm "of...
Write and test code in MIPS assembly language program to implement algorithms "The Non-Restoring Algorithm "of an 8-bit integer the user shoud insert the number then by the algo well find the square root
Write a MIPS Assembly Language program to request a name and reflect it back to the...
Write a MIPS Assembly Language program to request a name and reflect it back to the user. The request must be "Please enter your full name:" And it should be output following "The name you entered was: '
Write a MIPS assembly language procedure that simulates/implements the multiplication of two unsigned integers. The procedure...
Write a MIPS assembly language procedure that simulates/implements the multiplication of two unsigned integers. The procedure receives the mulitiplicand and the multiplier and returns the product. IT CANNOT USE A MULTIPLY INSTRUCTION! Write a MIPS assembly language program that demonstrates your multiplication procedure. Your program should ask the user for two integers to multiply. You can assume that the input integers are positive. Adhere to the procedure call convention.
Write a program in Mars MIPS Assembly Language that asks the user for an 8-digit hexadecimal...
Write a program in Mars MIPS Assembly Language that asks the user for an 8-digit hexadecimal and then prints out its 32-bit binary representation, the operation of the function, the format (I, R, or J), the fields associated with the format (op, rs, rt, imm, shamt, funct), and the instruction associated with the hexadecimal. All five parts must be written as functions.
Can someone write a method in MIPS assembly language that asks the user for a hexadecimal...
Can someone write a method in MIPS assembly language that asks the user for a hexadecimal value and converts it into a decimal?
Write a MIPS Assembly Language program which runs interactively to convert between decimal, binary, and hexadecimal....
Write a MIPS Assembly Language program which runs interactively to convert between decimal, binary, and hexadecimal. 1. Request input data type. 2. Request input data. 3. Request output data type. 4. Output the data. The suggested approach was to take the input data as a string. But I am really lost as to how to process the string and then converting it to another data type. Thanks for the help!
1.Write pseudocode for a program that allows the user to input two numbers (X and Y)...
1.Write pseudocode for a program that allows the user to input two numbers (X and Y) and a code C. If the code has value 1, the program should output the larger of X and Y and otherwise output the smaller. Now convert your pseudocode to an assembly language program. Enter the program into the lab software assembler. Assemble the program and execute it with different input data. 2. Write pseudocode for a program that allows the user to input...
In MIPS only!! make a program that multiplies a user input by 15. YOU CAN ONLY...
In MIPS only!! make a program that multiplies a user input by 15. YOU CAN ONLY USE ADDITION AND BITSHIFT OPERATIONS. Also very important, make sure its correct by using the mult and mflo operators (!More Important, explain to me how that's done!) . make sure to display user input and display the output. !!!please put comments on each line of what's happening!!!
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT