
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
Question
For the whole question, pseudo-instructions are not allowed except “j target_label”
and “jr ra”. One suggestion for assembly
comments to one or a block of instructions.
Question's attached below in the images
![4.
void swap (int *xp, int *yp)
{
Consider the following C code snippet.
int temp = *xp;
*xp
*yp;
*yp = temp;
}
int findMinimum (int arr[], int N)
{
}
// variable to store the index of minimum element
int min_idx = 0;
int min_E =
// Traverse the given array
for (int i = 1; i < N; i++) {
// If current element is smaller than min_idx then update it
if (arr[i] < min_E) {
min idx = i;
min_E = arr [min_idx];
}
arr [min_idx];
}
return min_idx;
}
/* Function to sort an array using selection sort*/
void selectionSort (int arr[], int n)
{
int i, min_idx;
// One by one move boundary of unsorted subarray
for (i = 0; i < n-1; i++)
{
// Find the minimum element in unsorted array
min_idx = findMinimum (&arr[i], n-i);
// Swap the found minimum element with the first element
if (min_idx != 0)
swap (&arr [min_idx+i], &arr[i]);](https://content.bartleby.com/qna-images/question/c954a0cb-c6cd-409f-94c9-db9ed3cb3c10/59c5870a-0002-4b78-ad6f-8b0473ca0d53/iys19lb_thumbnail.png)
Transcribed Image Text:4.
void swap (int *xp, int *yp)
{
Consider the following C code snippet.
int temp = *xp;
*xp
*yp;
*yp = temp;
}
int findMinimum (int arr[], int N)
{
}
// variable to store the index of minimum element
int min_idx = 0;
int min_E =
// Traverse the given array
for (int i = 1; i < N; i++) {
// If current element is smaller than min_idx then update it
if (arr[i] < min_E) {
min idx = i;
min_E = arr [min_idx];
}
arr [min_idx];
}
return min_idx;
}
/* Function to sort an array using selection sort*/
void selectionSort (int arr[], int n)
{
int i, min_idx;
// One by one move boundary of unsorted subarray
for (i = 0; i < n-1; i++)
{
// Find the minimum element in unsorted array
min_idx = findMinimum (&arr[i], n-i);
// Swap the found minimum element with the first element
if (min_idx != 0)
swap (&arr [min_idx+i], &arr[i]);

Transcribed Image Text:(a)
Implement the C code snippet in RISC-V assembly language. Use s0-s2
to hold the variable i, j, and min_idx in the function selectionSort. Be sure
to handle the stack pointer appropriately. The array is stored on the stack of the
selectionSort function. Clearly comment your code.
(b)
Assume that the selectionSort is the function called. Draw the status of
the stack before calling selectionSort and during each function call. Indicate stack
addresses and names of registers and variables stored on the stack; mark the location
of sp; and clearly mark each stack frame. Assume the sp starts at 0x8000.
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution
Trending nowThis is a popular solution!
Step by stepSolved in 4 steps

Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- I think the question is asking for you to write the assembly code snippet without using NOR but you do. Is there an alternative wayarrow_forwardIs the assembly language version of a FOR loop, WHILE loop, DO WHILE loop, GOTO loop function the same or different? If different,identify the differences. Your comparison should be based on: Number of registers used Number of jumps (iterations) Total number of operationsarrow_forwardassembly language please with comment and screen shot of the out putarrow_forward
- Write an assembly function that uses a for loop to multiply all the numbers from 1 through and including N. Return the result. Print the returned value. Hello I was hoping someone could run through this code step by step as I am new to Assembly language, thank you!arrow_forwardBelow you can see a Mealy and Moore design code as well as simulation (test bench) code. Can you write note on side of code illustrating what the line represents and explain how the two codes are behaving differently? Mealy: Design source code: module mealy #Example of where the notes should go to represent how the lines are behaving ( input shift_start, input shift_stop, input rst, input clk, input d, output reg [7:0] q ); parameter Idle =2'd0; parameter Start =2'd1; parameter Run =2'd2; parameter Stop =2'd3; reg [1:0] state; reg [4:0] delay_cnt; always @(posedge clk or negedge rst) begin if(!rst) begin state <= Idle; delay_cnt <= 0; q <= 0; end else case(state) Idle : begin if(shift_start) state <= Start; end Start : begin if(delay_cnt ==5'd99) begin delay_cnt <= 0; state…arrow_forwardExample: The Problem Input File Using C programming language write a program that simulates a variant of the Tiny Machine Architecture. In this implementation memory (RAM) is split into Instruction Memory (IM) and Data Memory (DM). Your code must implement the basic instruction set architecture (ISA) of the Tiny Machine Architecture: //IN 5 //OUT 7 //STORE O //IN 5 //OUT 7 //STORE 1 //LOAD O //SUB 1 55 67 30 55 67 1 LOAD 2- ADD 3> STORE 4> SUB 5> IN 6> OUT 7> END 8> JMP 9> SKIPZ 31 10 41 30 //STORE O 67 //OUT 7 11 /LOAD 1 //OUT 7 //END 67 70 Output Specifications Each piece of the architecture must be accurately represented in your code (Instruction Register, Program Counter, Memory Address Registers, Instruction Memory, Data Memory, Memory Data Registers, and Accumulator). Data Memory will be represented by an integer array. Your Program Counter will begin pointing to the first instruction of the program. Your simulator should provide output according to the input file. Along with…arrow_forward
- Use the name "jobe" when you run your program. Find the "answer" in memory using the Labels display. What is the value in hexadecimal at answer? Run your program again with the name 4567. What is the value in hexadecimal at answer? If you select the ASCII button what appears at answer? Based on your observations, what is the byte ordering scheme of the mips processor as implemented in the simulator?arrow_forwardPlease read these instructions very carefully and follow them exactly how they are meant to be done the code is done and C code not C++ by the way 1) largest Write a function int largest(int a[],int n) that will find the largest int in the n ints in a. This should be the only function in the file. Generate assembly language for this code using -S. Identify the variables in this code, defining a table in comments in the code. Comment each line of code, indicating what it is doing in terms of the original C code. 2) Before you move on, make a copy of your .s file. 3) Generate optimized code for the same C code. You do this with the -O (-Os if you are on MacOS) switch to gcc For example, gcc -S -O largest.c will generate largest.s (clobbering your first version if you did not save it elsewhere!) Build the same variable table and code comments for this version. Submit largest.c and both copies of largest.s with your comments.arrow_forwardAnswser must be in MIPSzy assembly language. Max of 3 - Brancharrow_forward
- You must complete this in Python and the programs should not take any command-line arguments. You also need to make sure your programs will compile and run in at least a Linux environment. In this problem, you need to implement operation bit encoding for Assembly instructions. Given a line of text, your program should check whether it is a valid Assembly instruction type. If it is, your program should print out the opcode and optype of that instruction type; if the line of text is not exactly a valid Assembly instruction, your program should skip it and move to the next line of input without printing anything. Input Format The input to the program will consist of some number of lines. Each line contains some text, either a valid Assembly instruction type (with no extra whitespace or other characters, e.g. READ on a line by itself) or some other text. Constraints There are no specific constraints on the length or number of lines. They will be in a reasonable limit, as demonstrated by…arrow_forwardThere are two kinds of right-shift: arithmetic and logical. Unlike Java, which has two different right-shift operators, C has just one. On the Linux machines in the lab, how does the compiler decide which right-shift instruction to use?arrow_forwardCould you please define "preprocessor defined constant" for me?arrow_forward
arrow_back_ios
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education

Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON

C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON

Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning

Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education