Skip to content

Paschalis/ASM-MIPS-Assembly

Repository files navigation

Introduction to Computers Lab - MIPS Assembly Exercises

Welcome to the lab exercises for the "Introduction to Computers" course in the Computer Science degree program. This lab focuses on MIPS assembly language programming, specifically on addition operations.

Course Details

  • Course Name: Introduction to Computers
  • Course Code: CS221
  • Instructor: Dimitriou Georgios
  • Semester: 2020
  • Prerequisites: None

Lab Exercises

Exercise 1: Read and Display a Number

Write a MIPS assembly program that reads and displays a number on the screen. The program should provide a prompt message before reading the number from the keyboard to guide the user.

Exercise 2: Read and Display Three Numbers

Write a MIPS assembly program that reads and displays three numbers on the screen. The program should use prompt messages for reading and displaying the numbers.

Exercise 3: Addition of Two Numbers

Create an assembly program that adds two numbers initially loaded into registers t1 and t2. The result should go to t3 and be displayed on the screen.

Exercise 4: Addition of User-input Numbers

Implement an assembly program that adds two numbers given each time from the keyboard. The result should go to t3 and be displayed on the screen.

Exercise 5: Calculate the Difference

Create an assembly program that calculates the difference between two numbers given each time from the keyboard. The result should go to t3 and be printed on the screen.

Exercise 6: Display Name Multiple Times

Implement an assembly program that displays your name 10 times on the screen, using line breaks for readability.

Exercise 7: Conditional Comparison

Write an assembly program that reads two numbers from the keyboard, a and b. It checks if a < b, a > b, or a = b, and displays the corresponding message on the screen.

Exercise 8: Finding Zeros of a Function

Write an assembly program to find the integer values of x that zero the function f(x) = ax^2 + bx in the interval [X1, X2]. The values of a, b, X1, and X2 should be entered from the keyboard. If the function does not zero in the interval [X1, X2], display the message "end of program."

Exercise 9: Counting Positive, Negative, and Zero Numbers

Write an assembly program that reads integer numbers from the keyboard and stores them in memory, creating an array of 10 positions. It finds the number of positive, negative, and zero numbers in the array and displays them.

Exercise 10: Finding the Largest Number in an Array

Write an assembly program that creates an array of 10 positions and finds the largest number in the array.

Exercise 11: Adding Arrays

Write an assembly program that creates two arrays of 10 elements each. Then, create a third array with the sum of the corresponding elements of the two arrays and display the elements of the third array.

Exercise 12: Manipulating Array Elements

Write a program that creates an array of 6 elements, calculates the smallest number, adds it to each element of the array, and then displays the elements in reverse order from input.

Exercise 13: Swapping Array Elements

Write a program that fills two one-dimensional arrays A and B with ten positions each, swaps the elements of the arrays, and then displays the contents of the arrays to verify the process.

Exercise 14: Sum of Products

Write an assembly program to calculate the sum of products 12 + 23 + 34 + 45 + ... where the user specifies how many products to add each time.

Exercise 15: Counting Even and Odd Numbers

Write a program that continuously reads numbers from the keyboard until the number zero is given. When zero is entered, print the number of even and odd numbers given up to that point.

Exercise 16: [Calculate the sum of cubes from 1 to 10]

Write a program to calculate the sum:

$$ \sum_{i=1}^{10} i^{3} $$

How to Use

Running MIPS Assembly Programs with SPIM on Linux

To run a MIPS assembly program with SPIM on the terminal in Linux, follow these steps:

  1. Install SPIM: If not already installed, you can install SPIM using your package manager.

  2. Write your MIPS assembly program: Save your MIPS assembly program with a .s extension.

  3. Open a terminal.

  4. Navigate to the directory containing your assembly file.

  5. Run the program using SPIM: spim -file your_program.s

Author

Paschalis Moschogiannis (Contact: pmoschogiannis@uth.gr)

License

This project is licensed under the GNU General Public License Version 3 (GPLv3).

About

Introduction to Computers Lab - MIPS Assembly Exercises

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages