MIPS Assembly Mini Projects 20202
MIPS Assembly Mini Projects 20202
Projects
(1). Create a program to input a text line from the keyboard and test if it is a
palindrome. For example: “abc121cba” is a palindrome. Store all palindromes which
the user typed into the memory, to make sure that the user doesn’t duplicate
palindromes.
(2). Find all prime numbers (such as 2, 3, 5, 7..) in a range from the integer N to the
integer M. N, M is entered from the keyboard.
For example:
Input: 1432
- Calculate the number of elements in the range of (m, M). Range m, M are
inputted from the keyboard.
(5). Write a program to get decimal numbers, display those numbers in binary and
hexadecimal.
(6) Given an array of .word elements and the number of elements, write a procedure
to find the pair of adjacent elements that has the largest product and return that
product.
Example: For inputArray = [3, 6, -2, -5, 7, 3], the output should be the product of 7
and 3 (21)
(7) Some people are standing in a row in a park. There are trees between them
which cannot be moved. Your task is to rearrange the people by their heights in a
non-descending order without moving the trees. People can be very tall!
Example: For a = [-1, 150, 190, 170, -1, -1, 160, 180], the output should be
sortByHeight(a) = [-1, 150, 160, 170, -1, -1, 180, 190].
You have to create 1 variable (number students) and 2 array (student name, mark)
to store the input data
Assume that you already have 1 variable (number students) and 2 arrays (student
name, mark) in memory
- List the names of all students who haven’t passed the Math exam.
(10*) Write a program that gets an integer i from the user and creates the table
shown below on the screen (example inputs provided). Subroutines are required for
power, square, and hexadecimal (in 32 bit arithmetic, attend to overflowed results).
Hint: Hexadecimal can be done with shifts and masks because the size is 32 bits.
7 128 49 0x7
1. Input name of 2 students with space character, for example “Vu Thi XYZ”.
Store them into the memory.
Write a function that converts a string of ASCII digits into a 32-bit integer. The
function will receive as an argument the starting address of the string and must
return a 32-bit integer containing the integer value of the string. Assume that the
string is an ASCIIZ string, i.e., ends with the null character (ASCII code 0). You don't
need to check for errors in the string, i.e., you may assume the string contains only
characters '0' through '9' (i.e., their corresponding ASCII codes), and will not
represent a negative number or a non-decimal value or too large a number. For
example, a_to_i called with the argument "12345" will return the integer 12345. atoi()
(13) Ticket numbers usually consist of an even number of digits. A ticket number is
considered lucky if the sum of the first half of the digits is equal to the sum of the
second half. Given a ticket number n, determine if it's lucky or not.
Example
(14). Given two strings, find the number of common characters between them.
(15) You are given an array of integers. On each move you are allowed to increase
exactly one of its elements by one. Find the minimal number of moves required to
obtain a strictly increasing sequence from the input.
The minimal number of moves needed to obtain a strictly increasing sequence from
inputArray. It's guaranteed that for the given test cases the answer always fits signed
32-bit integer type.
Note: sequence a0, a1, ..., an is considered to be strictly increasing if a0 < a1 < ... <
an. Sequences containing only one element are also considered to be strictly
increasing.
Example:
- For sequence = [1, 3, 2, 1], the output should be
almostIncreasingSequence(sequence) = false. There is no one element in this array
that can be removed in order to get a strictly increasing sequence.
(17) Write a program that inputs a string. Extract number characters and show to
screen in inverse order using stack.
(18) Two arrays are called similar if one can be obtained from another by swapping
at most one pair of elements in one of the arrays.
Given two arrays a and b, check whether they are similar. Example:
- For a = [1, 2, 3] and b = [1, 2, 3], the output should be areSimilar(a, b) = true. The
arrays are equal, no need to swap any elements.
- For a = [1, 2, 3] and b = [2, 1, 3], the output should be areSimilar(a, b) = true. We
can obtain b from a by swapping 2 and 1 in b.
- For a = [1, 2, 2] and b = [2, 1, 1], the output should be areSimilar(a, b) = false. Any
swap of any two elements either in a or in b won't make a and b equal.
(19) Write a program that input some variable names. Check if variable names
consist only of English letters, digits and underscores and they can't start with a digit.
Example
(20) Given a string which consists of lower alphabetic characters (a-z), count the
number of different characters in it.
Example
Cyclone words are English words that have a sequence of characters in alphabetical
order when following a cyclic pattern.
Example:
#---------------------------------------------------------------------
# @brief Kiem tra hieu ung cua mot scene bang cach polling
# @param[in] Scene_Ptr bien toan cuc, co gia tri la dia chi cua
# Scene vua duoc thiet lap, dia chi cua Scene 1,2,3,4
#---------------------------------------------------------------------
.ent Test_Scene
Test_Scene:
jal NextFrame
nop
jal ShowScene
nop
j Test_Scene
.end Test_Scene
- Khi gặp giáo viên kiểm tra, các SV có thể dùng máy tính laptop, nếu
không có thể mời giáo viên tới bàn máy tính tại Lab.
- Mỗi SV sẽ trình bày trả lời các câu hỏi của giáo viên về 1 (trong 2 bài
tập của nhóm).
2. Hạn chế được các lỗi thao tác nhập liệu của người dùng (ví dụ nếu
người dùng cố tính nhập giá trị số nguyên là hello)
3. Hạn chế được các số quá lớn, ngoài phạm vi chương trình (ví dụ,
tính giai thừa của 1 tỷ)
5. Trả lời được các câu hỏi lý thuyết ứng với các lệnh trong chương
trình (khuôn dạng của lệnh này là gì? Lệnh này mất bao nhiêu chu
kì để thực hiện…)