Search for question
Question

You are asked to implement a MIPS procedure named string_insert. The procedure will

take two null-terminated ASCII strings: strl and str2 and an integer position value pos as

input parameters. When invoked, the string_insert procedure will insert a copy of str2

into str1 right before the index location indicated by pos. For example, if str1 contains the

string "ABCDEFG" and str2 contains "123", then a procedure call string_insert with the

pos parameter value of 5 would update str1 into "ABCDE123FG"; since the letter F had the

index location of 5. If the pos value exceeds the lengths of str1, then str2 should be

concatenated at the end of str1. Of the pos value equals to 0; then str2 will be prepended to

str1. The string_insert procedure will not return any value.

Furthermore, you also need to implement a second MIPS procedure named strlen. Like the C

library function of the same name, strlen will take a string as input parameter, and return

the number of characters in that string, excluding the null character. The return value of

strlen will be available at the $v0 register for the caller procedure to read.

You should try to implement strlen first, and then focus on string_insert because the

implementation of substring_count can be greatly simplified when it can invoke the strlen

procedure.

The main function of the program is given in the following. You may define any additional

number of helper procedures as necessary. However, the data segment as well as the body of

the main function should be used exactly as given. If you need space to temporarily hold bulks

of data, you can and should utilize the stack segment of the process./n.data

#Static arrays used to store the two string inputs

stri: .space 200 # reserve a 200-byte memory block

str2: .space 200 # reserve a 200-byte memory block

#String literals

printstri: asciiz "Enter the first string:

printstr2: .asciiz "Enter the second substring: "

printstr3: .asciiz "Enter the insertion position:

printstr4: .asciiz "After insertion, updated first string is: "

-text

.globl main

main:

11, $v0, 4 #to print prompt #1

la $a0, printstri

syscall

li, $v0, 8 #input the first string

la $a0, stri

li $al, 200

syscall

11, $v0, 4 #print prompt #2

la $a0, printstr2

syscall

li, $v0, 8 #input the second string

la $a0, str2

li $al, 200

syscall

11, $v0, 4 #to print prompt #3

la $a0, printstr3

syscall

"

li, $v0, 5 #input the position value (integer)

syscall #pos stored in $v0

la $a0, stri

la Sal, str2

add $a2, $0, SVO

jal string_insert

#load the address of strl to $a0

#load the address of substri to Sal

#load the position value to $a2¹

#procedure call from main/n11, $v0, 4

la $a0, printstr4

syscall

la $a0, strl

syscall

11, $v0, 10

syscall

string_insert:

#print string mode

#Literal part of Output

#load address of strl for output

#clean exit

#definition of string_insert goes below

# Any additional function definition (s), including strlren

To get full credit for your work, your MIPS code must be sufficiently documented with single-

line comments explaining the purpose of the key parts of the program.

Save your MIPS program in a single plaintext file and submit it to Moodle. Good Luck!

Fig: 1

Fig: 2

Fig: 3


Most Viewed Questions Of Assembly Programming

Instructions translate the "cppFunction" into "asmFunction" and enter your assembler code in "AssemblerFunction.asm", do not change the Main.cpp. You can use the newest Visual Studio project, then you upload the whole project, but you still cannot change the Main.cpp file. This is an easy Leetcode problem (#121), without any complicated data structures, so it should not be a problem. Everything is set up; you only enter the assembler code.


Submit your assembly language source code (.asm file) and screen shots that display your program's successful execution (the output screen). Do not submit screenshots of your code./nCOSC 2425 - Project 3 Write an assembly language program that asks the user to enter an integer dollar amount between 1 and 3,000. Your program should display the corresponding class description using the following table. Donation Amount (dollars) $2,000 and above $1,500 to $1,999 $1,000 to $1,499 $500 to $999 $1 to $499 Class of Donation Platinum Gold Silver Bronze Brass Write the program so that it executes (loops!) until the user inputs some value that you determine to be the "sentinel value". Your program must guard against and provide user messages for input values that are outside the valid range.


Objective Write an ARM program that takes two integers as input, x and y, and calculates x*y using only addition. Convert the following C code into ARM: int main() { int x, y, result=0; //read x printf("Please enter x: "); scanf("%d", &Xx); //read y printf("Please enter y: "); scanf("%d", &y); if (y<0) { } x=0-X; y=0-y;/nif (y<0) { } x=0-X; y=0-y; for (int counter=0; counter


You are asked to implement a MIPS procedure named string_insert. The procedure will take two null-terminated ASCII strings: strl and str2 and an integer position value pos as input parameters. When invoked, the string_insert procedure will insert a copy of str2 into str1 right before the index location indicated by pos. For example, if str1 contains the string "ABCDEFG" and str2 contains "123", then a procedure call string_insert with the pos parameter value of 5 would update str1 into "ABCDE123FG"; since the letter F had the index location of 5. If the pos value exceeds the lengths of str1, then str2 should be concatenated at the end of str1. Of the pos value equals to 0; then str2 will be prepended to str1. The string_insert procedure will not return any value. Furthermore, you also need to implement a second MIPS procedure named strlen. Like the C library function of the same name, strlen will take a string as input parameter, and return the number of characters in that string, excluding the null character. The return value of strlen will be available at the $v0 register for the caller procedure to read. You should try to implement strlen first, and then focus on string_insert because the implementation of substring_count can be greatly simplified when it can invoke the strlen procedure. The main function of the program is given in the following. You may define any additional number of helper procedures as necessary. However, the data segment as well as the body of the main function should be used exactly as given. If you need space to temporarily hold bulks of data, you can and should utilize the stack segment of the process./n.data #Static arrays used to store the two string inputs stri: .space 200 # reserve a 200-byte memory block str2: .space 200 # reserve a 200-byte memory block #String literals printstri: asciiz "Enter the first string: printstr2: .asciiz "Enter the second substring: " printstr3: .asciiz "Enter the insertion position: printstr4: .asciiz "After insertion, updated first string is: " -text .globl main main: 11, $v0, 4 #to print prompt #1 la $a0, printstri syscall li, $v0, 8 #input the first string la $a0, stri li $al, 200 syscall 11, $v0, 4 #print prompt #2 la $a0, printstr2 syscall li, $v0, 8 #input the second string la $a0, str2 li $al, 200 syscall 11, $v0, 4 #to print prompt #3 la $a0, printstr3 syscall " li, $v0, 5 #input the position value (integer) syscall #pos stored in $v0 la $a0, stri la Sal, str2 add $a2, $0, SVO jal string_insert #load the address of strl to $a0 #load the address of substri to Sal #load the position value to $a2¹ #procedure call from main/n11, $v0, 4 la $a0, printstr4 syscall la $a0, strl syscall 11, $v0, 10 syscall string_insert: #print string mode #Literal part of Output #load address of strl for output #clean exit #definition of string_insert goes below # Any additional function definition (s), including strlren To get full credit for your work, your MIPS code must be sufficiently documented with single- line comments explaining the purpose of the key parts of the program. Save your MIPS program in a single plaintext file and submit it to Moodle. Good Luck!


Task 6.2: Pipeline Simulate the flow of the following code if it passes through a pipeline as in the The lecture is on! To do this, expand the diagram below, which indicates which Stage each command in which beat goes through: The pipeline consists (as discussed in the lecture) of the 5 stages of Instruction Fetch (IF), Instruction Decode (ID), Execute (EX), Memory Access (MA) and Write Back (WB), Values calculated in the EX phase are only calculated at the end of the WB phase written back to the register. When a subsequent command is in its EX-phase this value is required for the calculation, the pipeline must therefore be delayed for so long (stalled) until the corresponding value has been written back to the register. Also Iw and sw can only start execution when all source registers for Are available. As can be seen in the diagram, register r2 is set to clock 6 (WB of the second command) written back. Since the add command requires this register, the pipeline must be be delayed for a long time until r2 is available for execution (EX) in clock 7. In contrast to the lecture, it is assumed here that a written register value is only available for reading in the next bar. 1 lw r1.0x1000 (ro) 2 lw r2.0x1004 (ro) 3 add r3, rl, r2 4 sub r4, rl, r2 5 sw r4, 0x100c (ro) 6 sw r3.0x1008 (ro) 7 addi r5, ro, 0x10 8 sub r6, r0, r5 9 sw r5, 0x2000 (1) 10 sw r6.0x2000 (2) 1. Expand the diagram by the required delay! 2. How many cycles does the pipeline have to be delayed for? 3. What acceleration was achieved with the pipeline for this code? Go You assume that 200 hp are required for one cycle with pipelining. Without Pipelining takes one cycle and thus an instruction of 800 hp. 4. Rearrange the instructions so that when processing in the pipeline no delays are needed! The semantics of the program should be stay the same! This means in concrete terms. At the end of the execution, the registers should contain the same values and the same values should be written to the memory have been. What acceleration is being achieved now? 6 Points 1 Point 2 Points 6 Points


Your assignment is to replace the portion in HA4-main.s that is within hyphened comments (i.e. everything between lines 40 and 64) by a mainline program. Your program will compute: 1+2+3+4+5+........ ....+n. You could prompt the user for n and display the sum. You might want to use Gauss formula: n(n+1)/2. Create your own sensible prompts and output messages. An example execution of your program could be: Please enter the number of terms in your series: 20 The sum of your series is 210.


8. (8 pts) Registers A. Which register points to the next instruction to be executed? B. Which register points to the current top of the stack? C. Which register is as a base pointer during function calls? D. Which register is used for status and CPU control information?


4. Assume a CPU with a fixed 36-bit instruction length has the following instruction format: opcode [num-operands] [model operand1] [mode2 operand2] [mode3 operand3] The opcode is the instruction. num-operands is 0-3 depending on the number of operands and each operand has its own addressing mode specifier. Assume there are 150 instructions and 7 addressing modes. Answer the following questions. a. If an instruction uses three registers, how many registers can be referenced? b. If an instruction uses two registers and one immediate datum (in two's complement), what is the largest immediate datum that can be referenced assuming there are 16 registers? c. If an instruction has two operands, a register and a direct memory address, what is the largest address (which is an unsigned binary number) if there are 64 registers? d. If an instruction has two operands, both of which are memory addresses using base- displacement mode where the base is a base register and there are 8 base registers, and the displacement is an unsigned binary number, how long can the displacement be? Remember, there are two separate base registers and two separate displacements.


translate the "cppFunction" into "asmFunction" and enter your assembler code in "AssemblerFunction.asm", do not change the Main.cpp. You can use the newest Visual Studio project, then you upload the whole project, but you still cannot change the Main.cpp file. This is an easy Leetcode problem (#121), without any complicated data structures, so it should not be a problem. Everything is set up; you only enter the assembler code.


This goal of this Final Project is for you to design a PowerShell Script that could be used in the day-to-day management of an Active Directory-based network. It is worth nothing that the script you will create could be used in your portfolio that would demonstrate your understanding of PowerShell and how PowerShell can be used in an Active Directory network.