Using MARS simulator, write MIPS programs according to the following scenarios: Receive a positive integer number from the user and print out “prime”/“not prime” result if the entered number is prime or not.
Remarks:
• Write your name and Id inside the program file.(my name is Nabil
Mohsen Alzeqri)and (my ID: 61330237)
• All programs must be commented.
• A description of the method used in the program should be
provided.
• The program should have been already tested using MARS
• For more information of how to input/output values in MIPS refer
to MARS help manual
The MIPS program is:
$LC0:
.ascii "Enter the Number to check Prime: \000"
$LC1:
.ascii "not prime.\000"
$LC2:
.ascii "prime.\000"
main:
addiu $sp,$sp,-48
sw $31,44($sp)
sw $fp,40($sp)
move $fp,$sp
sw $0,32($fp)
sw $0,28($fp)
lui $2,%hi($LC0)
addiu $5,$2,%lo($LC0)
lui $2,%hi(_ZSt4cout)
addiu $4,$2,%lo(_ZSt4cout)
jal std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> > (std::basic_ostream<char, std::char_traits<char> >&, char const*)
nop
addiu $2,$fp,36
move $5,$2
lui $2,%hi(_ZSt3cin)
addiu $4,$2,%lo(_ZSt3cin)
jal std::basic_istream<char, std::char_traits<char> >::operator>>(int&)
nop
lw $2,36($fp)
nop
srl $3,$2,31
addu $2,$3,$2
sra $2,$2,1
sw $2,32($fp)
li $2,2 # 0x2
sw $2,24($fp)
$L4:
lw $3,24($fp)
lw $2,32($fp)
nop
slt $2,$2,$3
bne $2,$0,$L2
nop
lw $3,36($fp)
lw $2,24($fp)
nop
bne $2,$0,1f
div $0,$3,$2
break 7
1:
mfhi $2
bne $2,$0,$L3
nop
lui $2,%hi($LC1)
addiu $5,$2,%lo($LC1)
lui $2,%hi(_ZSt4cout)
addiu $4,$2,%lo(_ZSt4cout)
jal std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> > (std::basic_ostream<char, std::char_traits<char> >&, char const*)
nop
move $3,$2
lui $2,%hi(_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
addiu $5,$2,%lo(_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
move $4,$3
jal std::basic_ostream<char, std::char_traits<char> >::operator<<(std::basic_ostream<char, std::char_traits<char> >& (*)(std::basic_ostream<char, std::char_traits<char> >&))
nop
li $2,1 # 0x1
sw $2,28($fp)
b $L2
nop
$L3:
lw $2,24($fp)
nop
addiu $2,$2,1
sw $2,24($fp)
b $L4
nop
$L2:
lw $2,28($fp)
nop
bne $2,$0,$L5
nop
lui $2,%hi($LC2)
addiu $5,$2,%lo($LC2)
lui $2,%hi(_ZSt4cout)
addiu $4,$2,%lo(_ZSt4cout)
jal std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)
nop
move $3,$2
lui $2,%hi(_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
addiu $5,$2,%lo(_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
move $4,$3
jal std::basic_ostream<char, std::char_traits<char> >::operator<<(std::basic_ostream<char, std::char_traits<char> >& (*)(std::basic_ostream<char, std::char_traits<char> >&))
nop
$L5:
move $2,$0
move $sp,$fp
lw $31,44($sp)
lw $fp,40($sp)
addiu $sp,$sp,48
j $31
nop
__static_initialization_and_destruction_0(int, int):
addiu $sp,$sp,-32
sw $31,28($sp)
sw $fp,24($sp)
move $fp,$sp
sw $4,32($fp)
sw $5,36($fp)
lw $3,32($fp)
li $2,1 # 0x1
bne $3,$2,$L9
nop
lw $3,36($fp)
li $2,65535 # 0xffff
bne $3,$2,$L9
nop
lui $2,%hi(_ZStL8__ioinit)
addiu $4,$2,%lo(_ZStL8__ioinit)
jal std::ios_base::Init::Init() [complete object constructor]
nop
lui $2,%hi(__dso_handle)
addiu $6,$2,%lo(__dso_handle)
lui $2,%hi(_ZStL8__ioinit)
addiu $5,$2,%lo(_ZStL8__ioinit)
lui $2,%hi(_ZNSt8ios_base4InitD1Ev)
addiu $4,$2,%lo(_ZNSt8ios_base4InitD1Ev)
jal __cxa_atexit
nop
$L9:
nop
move $sp,$fp
lw $31,28($sp)
lw $fp,24($sp)
addiu $sp,$sp,32
j $31
nop
_GLOBAL__sub_I_main:
addiu $sp,$sp,-32
sw $31,28($sp)
sw $fp,24($sp)
move $fp,$sp
li $5,65535 # 0xffff
li $4,1 # 0x1
jal __static_initialization_and_destruction_0(int, int)
nop
move $sp,$fp
lw $31,28($sp)
lw $fp,24($sp)
addiu $sp,$sp,32
j $31
nop
Using MARS simulator, write MIPS programs according to the following scenarios: Receive a positive integer number...
Using MARS simulator, write MIPS programs according to the following scenarios: Receive an integer from the user and print out the individual bit of that number in binary format
using Mips assembly to work on Mars simulator write a program that outputs the maximum and minimum values of an entered array
MIPS 1(a): Using MARS (MIPS assembly simulator), write and debug a program with comments that will store words in a RAM array using the instruction sw and indirect addressing as specified in the data table below. Although the addresses and data are in given hexadecimal, your code will contain corresponding values in decimal. Use (268501056)_10 = (10010040)_16 as the base address of the array. Since the instruction sw and indirect addressing (using offsets) are needed to store the data in...
Write the following program in MIPS for use in the SPIM simulator. 1) Determine the number of occurrences of a specific character in a string. The character and the string are input by the user. The program should output Character <ch> occurs in string <string> <n> times.
Introduction: In this lab, you will write a MIPS program to read in (up to) 50 integer values from the user, store them in an array, print out the amay, one number per line, reverse the elements in the array and finally print out the elements in the just-reversed) array. Feel free to do this lab and all assembly programming labs) in Windows. You must use MARS Getting started: l. In MARS, create a new assembly file with the name...
Your program write a program to test whether a number is prime or not. Your program should ask user to input an integer and respond: "Prime" or "Not prime". Don't use any library function that tests for prime numbers. The program should continue to ask for input, till it sees a 0, when it exits. Please submit printed pseudocodeshould ask user to input an integer and respond: "Prime" or "Not prime". Don't use any library function that tests for prime numbers....
Write a MIPS procedure using spim or MARS that implements the assignment A[k] = 28 for some specified value of k, where A is an integer array with elements indexed starting from 0. Your procedure should take as its arguments the base address of the array A, and the index k of the array element that is the target of the assignment. You must use the standard procedure conventions discussed in class. You do not need to write a main...
Q-1: Write a program in Assembly language using MIPS instruction set that reads 15 integer numbers from user and stores all the numbers in the array intArray. Now, read another integer number N from the user, find the total number of array elements that are greater or equal to the number N, and the total number of array elements that are lower than the number N You must have two procedures: i. ReadIntegerArray: this procedure should read integer array elements...
USING PYTHON 1. Write a small program that asks for an integer number from the user and print all the prime numbers (2,3,5,7,etc) less than the input number. 2. How long it takes for your program to print the prime numbers less than 100. (Use magic functions)
1. Write a program in Assembly language using MIPS instruction set that reads two integer numbers from the user named as start and end number and finds out all the prime numbers between start and end (including start and end). Your program should do the validation of both the numbers as follows: i. start number must be smaller or equal to the end number. ii. Both numbers must be positive. iii. The maximum value for the end number is 10000...