
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
Write a complete program that sorts dword unsigned integer array in descending order. Assume that the user doesn’t enter more than 40 integers. You MUST use the template-1-2.asm Download template-1-2.asm and follow all the directions there.
Note: you have to review 3 peer assignments.
- You can’t add any more procedures to the template.
- The procedures can’t use any global variables (variables that are inside .data segment).
- The caller of any procedures sends its argument through the stack.
- Inside any procedures, if you need to use a register, you have to preserve its original value. You can't use uses, pushad operators.
- The callee is in charge of cleaning the stack
-
Sample run:
Enter up to 40 unsigned dword integers. To end the array, enter 0.
After each element press enter:
1
4
3
8
99
76
34
5
2
17
0
Initial array:
1 4 3 8 99 76 34 5 2 17
Array sorted in descending order:
99 76 34 17 8 5 4 3 2 1
template-1-2.asm
include irvine32.inc
; ===============================================
.data
; Fill your data here
;=================================================
.code
main proc
; FILL YOUR CODE HERE
; YOU NEED TO CALL ENTER_ELEM, SORT_ARR AND PRINT_ARR PROCEDURES
;
exit
main endp
; ================================================
; int enter_elem(arr_addr)
;
; Input:
; ARR_ADDRESS THROUGH THE STACK
; Output:
; ARR_LENGTH THROUGH THE STACK
; Operation:
; Fill the array and count the number of elements
;
enter_elem proc
; FILL YOUR CODE HERE
enter_elem endp
; ================================================
; void print_arr(arr_addr,arr_len)
;
; Input:
; ?
; Output:
; ?
; Operation:
; print out the array
;
print_arr proc
; FILL YOUR CODE HERE
print_arr endp
; ================================================
; void sort_arr(arr_addr,arr_len)
;
; Input:
; ?
; Output:
; ?
; Operation:
; sort the array
;
sort_arr proc
; FILL YOUR CODE HERE
; YOU NEED TO CALL COMPARE_AND_SWAP PROCEDURE
sort_arr endp
; ===============================================
; void compare_and_swap(x_addr,y_addr)
;
; Input:
; ?
; Output:
; ?
; Operation:
; compare and call SWAP ONLY IF Y < X
;
compare_and_swap proc
; FILL YOUR CODE HERE
; YOU NEED TO CALL SWAP PROCEDURE
compare_and_swap endp
; =================================================
; void swap(x_addr,y_addr)
;
; Input:
; ?
; Output:
; ?
; Operation:
; swap the two inputs
;
swap proc
; FILL YOUR CODE HERE
swap endp
end main
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by stepSolved in 3 steps with 2 images

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
- can you fill this one with entitties?arrow_forwardHow do I solve this exercise below on Arrays using Swift code? 1/4 Exercise - Arrays Assume you are an event coordinator for a community charity event and are keeping a list of who has registered. Create a variable registrationList that will hold strings. It should be empty after initialization. Your friend Sara is the first to register for the event. Add her name to registrationList using the append(_:) method. Print the contents of the collection. Add four additional names into the array using the += operator. All of the names should be added in one step. Print the contents of the collection. Use the insert(_:at:) method to add Charlie into the array as the second element. Print the contents of the collection. Somebody had a conflict and decided to transfer registration to someone else. Use array subscripting to change the sixth element to Rebecca. Print the contents of the collection. Call removeLast() on registrationList. If done correctly, this should remove Rebecca from the…arrow_forwardCampground reservations, part 3: Available campsites Excellent job! This next one's a little more challenging. Which campsites are available to reserve? We want to be able to quickly find which campsites are available. Can you help us? Given a campgrounds array, return an array with the campsite numbers of all currently unreserved (isReserved === false) campsites. Call the function availableCampsites. Dataset As a reminder, our data looks like this. It's an array with a bunch of campsite objects in it. Here is a small subset of the data to give you an idea: const campgrounds = [ { number: 1, view: "ocean", partySize: 8, isReserved: false }, { number: 5, view: "ocean", partySize: 4, isReserved: false }, { number: 12, view: "ocean", partySize: 4, isReserved: true }, { number: 18, view: "forest", partySize: 4, isReserved: false }, { number: 23, view: "forest", partySize: 4, isReserved: true }, ];arrow_forward
- Create a program that will encrypt letters and create a secret code. You will create an array of numbers from 0 - 25. use [i for i in range (26)] to create an array of numbers from 0 - 25. use random.shuffle to to shuffle the above array. This will be used for a new letter index order. For example: The first created array [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25] gets shuffled to become[2, 14, 12, 20, 16, 5, 11, 1, 13, 17, 15, 21, 19, 10, 23, 22, 25, 3, 6, 7, 18, 4, 9, 24, 0, 8] This will be used as the new index for the encrypted alphabet. create an array of letters using list(string.ascii_lowercase), this requires importing the string module. This will create: ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'] Accept an input of a word. Using the above tables take each letter of the word and convert it to the encrypted letter. Print each…arrow_forwardWrite a for loop to print all elements in courseGrades, following each element with a space (including the last). Print forwards, then backwards. End each loop with a newline. Ex: If courseGrades = {7, 9, 11, 10), print: 7 9 11 10 10 11 9 7 Hint: Use two for loops. Second loop starts with i = NUM_VALS - 1. Note: These activities may test code with different test values. This activity will perform two tests, both with a 4-element array (int courseGrades[4]). Also note: If the submitted code tries to access an invalid array element, such as courseGrades[9] for a 4-element array, the test may generate strange results. Or the test may crash and report "Program end never reached", in which case the system doesn't print the test case that caused the reported message. 1 #include HNm in 10 m DO G 2 3 int main(void) { 4 5 6 const int NUM_VALS = 4; int courseGrades [NUM_VALS]; int i; 7 8 for (i = 0; i < NUM_VALS; ++i) { scanf("%d", &(courseGrades[i])); 9 } 10 11 12 13 14 15 } /*Your solution…arrow_forwardWrite a script that creates a dictionary of name-age pair. Add some entries to your dictionary. Add a menu to support ADD, REMOVE, SERACH, AGE INCREASE, PRINT operations.The “Age Increase” option increases the age by 1 for all the entries in the dictionary.Test the four operationsarrow_forward
- In the attached Python code, use the array built to shuffle and deal two poker hands. Change the corresponding values for all Jacks through Aces to 11, 12, 13, 14 respectively. Shuffle the deck using your written shuffle routine, then deal two hands. COMMENT (explain) YOUR CODE Code: dCardNames = ['2','3','4','5','6','7','8','9','10','J','Q','K','A'] dCardValues = ['2','3','4','5','6','7','8','9','10','10','10','10','11'] dSuits = ["Clubs","Spades","Diamonds","Hearts"] # Build a two dimensional deck with Cards suits and values. aCards = [['' for i in range(52)] for j in range(3)] i = 0 n = 0 while i < 13: aCards[0][i] = dCardNames[i] aCards[0][i + 13] = dCardNames[i] aCards[0][i + 26] = dCardNames[i] aCards[0][i + 39] = dCardNames[i] aCards[1][i] = dSuits[0] aCards[1][i + 13] = dSuits[1] aCards[1][i + 26] = dSuits[2] aCards[1][i + 39] = dSuits[3] aCards[2][i] = dCardValues[i] aCards[2][i + 13] = dCardValues[i] aCards[2][i + 26] = dCardValues[i] aCards[2][i…arrow_forwardplease include a picture of the program and the output too and thank you!!!arrow_forwardWrite a for loop to print all elements in courseGrades, following each element with a space (including the last). Print forwards, then backwards. End each loop with a newline. Ex: If courseGrades = {7, 9, 11, 10}, print:7 9 11 10 10 11 9 7 Hint: Use two for loops. Second loop starts with i = NUM_VALS - 1. Note: These activities may test code with different test values. This activity will perform two tests, both with a 4-element array (int courseGrades[4]). Also note: If the submitted code tries to access an invalid array element, such as courseGrades[9] for a 4-element array, the test may generate strange results. Or the test may crash and report "Program end never reached", in which case the system doesn't print the test case that caused the reported message. #include <iostream>using namespace std; int main() { const int NUM_VALS = 4; int courseGrades[NUM_VALS]; int i; for (i = 0; i < NUM_VALS; ++i) { cin >> courseGrades[i]; } /* Your solution goes…arrow_forward
- Create a for-each loop that outputs all elements in the role collection of Student objects. What is necessary for that loop to function?arrow_forwardPlease explain. In this code, assuming no errors, what does 'docs' represent? Item.collection.insert(newItems, function (err, docs){... an array of all data objects in the collection an array of data objects that were inserted. an array of data objects that failed to be inserted.arrow_forward1. Modify the code of ElemSort.java (discussed in last class) and incorporate the merge sort code into it. You can take help from the code given in the slides. Call the mergeSort method and let your program sort your hundred element arrays. Run your code, take a screenshot and upload.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
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