Hello, I'm having trouble completing this program in less than four lines using MIPS programming language, we are required to fill in the missing code as indicated (via comments). |
IMPORTANT: As indicated in the program's comments: |
⇒ | Write no more than certain number of lines of code as
indicated. (One instruction per line, and there will be penalty if your code consumes more lines.) |
⇒ | Code MUST use only instructions that are allowed i.e., only bit manipulating instructions: (ANDing, ORing, XORing,NORing and shifting). |
⇒ |
MUST NOT in any way change the lines of code already written. ############################ li $v0, 1
########################################################## |
Screenshot
-------------------------------------------------------
Program
############################
# prompt user to enter an integer in the range [0, 63], read the
integer,
# and display if the integer is of type 0 ( <= 31 ) or 1 ( >
31 )
############################ data segment
################################
.data
typeLeg: .asciiz "1 for
<=31, 0 for >31\n"
inputProm: .asciiz "Enter
integer between 0 and 63 (inclusive): "
outputLab: .asciiz "Integer
entered is of type "
############################ code segment
################################
.text
.globl
main
main:
li
$v0, 4
la
$a0, typeLeg
syscall
# print type legend
la
$a0, inputProm
syscall
# print input prompt
li
$v0, 5
syscall
# read integer
move
$v1, $v0 # save integer read in
$v1
li
$v0, 11
li
$a0, '\n'
li
$v0, 4
la
$a0, outputLab
syscall
# print output label
li $v0, 1
##########################################################
#
Insert below NO MORE THAN 4 lines of code that involve ONLY
# bit
manipulating instructions (ANDing, ORing, XORing,
#
NORing and shifting - only whatever that are needed)
# so
that the program will work just like the sample runs
#
shown at the bottom (some blank lines edited out).
#
HINT: Risking telling the obvious, the instructions you
#
insert are to cause the content of $a0 to become
# the
desive value (1 or 0) when printed as integer.
# You
MUST test your completed program for AT LEAST the
# test
cases shown (and include the result in hardcopy).
##########################################################
#Your Code
Here
#Integer
oring with 31
ori
$a0,$v1,31
#shift right
to 4 places means,<=31 get 1 >31 get 3
srl
$a0,$a0,4
#Xor with 3
get,<=31 end digits 10 and >31 get 00
xor
$a0,3
#right shift
1 generate proper type
srl
$a0,$a0,1
syscall
# display desired output
##########################################################
li
$v0, 10 # exit gracefully
syscall
-------------------------------------------------------------
Output
1 for <=31, 0 for >31
Enter integer between 0 and 63 (inclusive): 0
Integer entered is of type 1
-- program is finished running --
1 for <=31, 0 for >31
Enter integer between 0 and 63 (inclusive): 31
Integer entered is of type 1
-- program is finished running --
1 for <=31, 0 for >31
Enter integer between 0 and 63 (inclusive): 32
Integer entered is of type 0
-- program is finished running --
Hello, I'm having trouble completing this program in less than four lines using MIPS programming language,...
MIPS -
Takes two inputs from the user, which are the lengths of two
sides of a polygon. It adds those two lengths and prints the sum.
Your task is modify the program to make it specific to a triangle,
and to print the perimeter of that triangle.
See blue highlighted.
preamble: prompt1: prompt2: answer: endline: .data ascii .asciiz asciiz .asciiz asciiz .asciiz "\nThis program, written by <YOUR NAME>," " can be used to add the length of two sides...
Subroutines in MIPS Determines the minimum of two integers Functions within the MIPS slides describe how one can use subroutines (also called procedures, functions, and methods) in MIPS. Because of the importance of subroutines in modern programming, most hardware designers include mechanisms to help programmers. In a high-level language like C or Java, most of the details of subroutine calling are hidden from the programmer. MIPS has special registers to send information to and from a subroutine. The registers $a0,...
I have this MIPS program and I'm having trouble with it. This program is user inputs numbers until zero and sorts and print the numbers in order. Please soove this issue. You can use any sorting algorithm except bubble sort. Need it as soon as possible. Here is the code:.datanum: .word 0space: .byte ' ' .text main: # la $t0, val # loads val into a register # li $t1, 0 #keeps track of how many numbers entered la $a0,...
(USING THE PROGRAM MARS) Using the MemoryAccess program we wrote in class as a starting point, write a program called LoadStore # Title : Memory access.asm #Desc: Practice initially memory, #in val1 = 0x0a; #int val2 = 0x0b; #int result; #string resultstring = " final answer : "; #string returnchar = "\n"; #void main() { # result = val1 + val2; # cout<<< resultstring << returnchar; #} .data val1: .word 0x0a #store 0xa into variable val1 val2: .word 0x0b #store...
Assignment 4 File “quad_sol.s” contains a quadratic polynomial solver, which calculates the integer solution of a quadratic polynomial equation. 1. Rewrite the program using instructions reordering to reduce the number of cycles needed to execute the program. Indicate the number of cycle reduction. 2. Describe how forwarding would affect the execution of the program. CODE # quad_sol.s # This assembly program calculates the integer solutions of a quadratic polynomial. # Inputs : The coefficients a,b,c of the equation a*x^2 +...
im trying to complete mips program code about a calculator program that can calculate integer addition / subtraction written using the MIPS assembler. im having hard times to debug this. The input is given to the array of Formula char (base address $ s0) in the form of a formula. The null character (\ 0, ASCII code 0) is placed at the end. The calculation result is given to the register $ s1 and the overflow is ignored. For example,...
Write a MIPS program that prints(displays) "Hello World"
using MMIO (NOT syscall!)
Here is a screenshot of a MIPS program that prints user input to
the screen. And I need something that displays "Hello World"
without taking any input. Please help! Thanks.
The output should be something like this but without the
input
.data 7 strl:.asciiz "\nStart entering characters in the MMIO Simulator" .text 10 .globl echo 12 13 14 15 16 17 echo: al Read # single print statement...
Write a complete MIPS assembly language program that implements the following pseudocode. program h2 define global integer variables w, x, y, z -- in the .data section function main() SysPrintStr("Enter an integer >= 0 for w? ") w ← SysReadInt() SysPrintStr("Enter an integer >= 0 for x? ") x ← SysReadInt() SysPrintStr("Enter an integer < 0 for y? ") y ← SysReadInt() z ← 16(w + x) - (3 × -y mod 7) SysPrintStr("z = ") SysPrintInt(z) SysExit() end function...
ASSEMBLY LANGUAGE (Mars MIPS)
Starting code:
Factorial: #Factorial Recursive function
subu $sp, $sp, 4
sw $ra, 4($sp) # save the return address on stack
beqz $a0, terminate # test for termination
subu $sp, $sp, 4 # do not terminate yet
sw $a0, 4($sp) # save the parameter
sub $a0, $a0, 1 # will call with a smaller argument
jal Factorial
# after the termination condition is reached these lines
# will be executed
lw $t0, 4($sp) # the argument I...