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
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 an integer from the...
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...
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...
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...
Create a cache memory using mips in mars. The input of the simulator will be a file (or an array) with integers that represent a sequence of accesses to memory blocks. Each number represents a block of memory. The output of the simulator will be the number of hits for each cache configuration as well as the number of instructions executed. The results must be presented with the sequence of memory blocks delivered. While you are implementing your cache, you...
Accept 2 numbers from user add them and print the sum using MARS mips
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.
Please I need the correct and comment of code in MIPS assembly program to Receive a positive integer number from the user and print out “prime”/“not prime” result if the entered number is prime or not.
The program I'm using is MIPS (mars) assembly; Write a program that in the main routine ask the user input n numbers(2<n<11) and pass n and array pointer to FillArray to stores numbers in the array. Main again passes the pointer to AddElement Function to add the elements of the array, and return the result back to main to print it.
MIPS Programming 1 In this project, you are going to write a MIPS program to read an integer number and convert it to 8- bit signed binary in a string. Your program should do the followings: Part II (50%, due date: March 1) for negative number . Write a non-leaf function to convert a negative integer number to 2's complement in string . Two parameters: integer number, string array or pointer -Get absolute value of the negative number o Call...