Quick Sort Algorithm - Computer Organization - Homework, Exercises of Computer Architecture and Organization

These HOMEWOR NOTES are very easy to understand and very helpful to built a concept about the foundation of computers ORGANIZATION and Database Design.The key points in these slide are:Partial Combinational Logic, Hardwired Control Unit, Memory Write, Automobile Assembly Process, Completions of Automobiles, Fetch-Execute Cycle, Stages for Instruction Pipelined, Decode Instruction, Semantic Gap

Typology: Exercises

2012/2013

Uploaded on 04/27/2013

arundhati
arundhati 🇮🇳

4.5

(23)

88 documents

1 / 2

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Homework #5 Computer Organization
Translate the following quick sort algorithm to ARM assembly language. (YOU ARE TO USE THE ARM
CALLING CONVENTIONS WHEN IMPLEMENTING THE QUICK SORT, PARTITION, AND
SWAP SUBPROGRAMS!!!)
Use the following template for your program.
AREA QUICK_SORT_PROGRAM, CODE, READONLY
; Quick sort program
ENTRY
MAIN ADR sp, STACK_START
ADR a1, SCORES
MOV a2, #0
LDR a3, LENGTH
SUB a3, a3, #1
BL QUICK_SORT
STOP B STOP
END_MAIN
QUICK_SORT
; Add your code here
END_QUICK_SORT
PARTITION
; Add your code here
END_PARTITION
SWAP
; Add your code here
END_SWAP
AREA QUICK_SORT_PROGRAM, DATA, READWRITE
SCORES DCD 20, 30, 10, 40, 50, 60, 30, 25, 10, 5
LENGTH DCD 10
STACK_END SPACE 0x00000FF
ALIGN
STACK_START DCD 0
DUMMY DCD 0x12345678
END
Docsity.com
pf2

Partial preview of the text

Download Quick Sort Algorithm - Computer Organization - Homework and more Exercises Computer Architecture and Organization in PDF only on Docsity!

Homework #5 Computer Organization

Translate the following quick sort algorithm to ARM assembly language. (YOU ARE TO USE THE ARM

CALLING CONVENTIONS WHEN IMPLEMENTING THE QUICK SORT, PARTITION, AND SWAP SUBPROGRAMS!!!)

Use the following template for your program.

AREA QUICK_SORT_PROGRAM, CODE, READONLY ; Quick sort program ENTRY MAIN ADR sp, STACK_START ADR a1, SCORES MOV a2, # LDR a3, LENGTH SUB a3, a3, # BL QUICK_SORT

STOP B STOP

END_MAIN

QUICK_SORT

; Add your code here END_QUICK_SORT

PARTITION

; Add your code here END_PARTITION

SWAP

; Add your code here END_SWAP

AREA QUICK_SORT_PROGRAM, DATA, READWRITE SCORES DCD 20, 30, 10, 40, 50, 60, 30, 25, 10, 5 LENGTH DCD 10

STACK_END SPACE 0x00000FF ALIGN STACK_START DCD 0 DUMMY DCD 0x

END

Docsity.com

The quick sort algorithm is below:

quickSort( start address of integer array,

function partition( start address of integer array,

integer low, high)

integer start, end ) returns an integer

local variable

local variables

integer pivotPosition

begin if (low < high) then pivotPosition = partition(array, low, high) quickSort(array, low, pivotPosition-1) quickSort(array, pivotPosition+1, high) end if end quickSort

main( ) begin quickSort(scores, 0, length-1) end main

swap( address of integer operand1, address of integer operand2) local variable integer temp begin temp = operand operand1 = operand operand2 = temp end swap

(swap should exchange the values at the addresses passed it)

integer pivotValue, pivotPosition, mid, scan

mid = (start + end) / 2 swap(array[start], array[mid]) <<< send addresses pivotPosition = start pivotValue = array[start] for scan = start + 1 to end do if (array[scan] < pivotValue) then pivotPosition = pivotPosition + 1 swap(array[pivotPosition], array[scan]) end if end for swap(array[start], array[pivotPosition]) return pivotPosition end partition

TURN IN :

 a print-out of your ARM quick sort program, e.g., hw5.s. Print the file from inside of the uVision4 IDE.  a window capture of the uVision4 simulator after running your assembly language program, so it shows the above array values sorted. You can capture this window by (1) right-clicking anywhere in the window to make it the "currently active" window, (2) while holding down the key, press the key to capture the window the Window's clipboard, and (3) open some word processor (Word, Open Office, etc.) and paste the image into the document. Add your name to this document before printing it.

Docsity.com