Laboratory Assignment 3 - Nested Looping in Assembly Language | EEL 3801, Lab Reports of Computer Architecture and Organization

Material Type: Lab; Class: Computer Organization; Subject: Engineering: Electrical; University: University of Central Florida; Term: Unknown 1989;

Typology: Lab Reports

Pre 2010

Uploaded on 11/08/2009

koofers-user-5df
koofers-user-5df 🇺🇸

10 documents

1 / 1

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Laboratory Manual
EEL 3801
Lab #3
Laboratory Assignment #3
EEL 3801 Introduction to Computer Engineering
Topic: Nested looping in assembly language.
Turn in: .LST file and screen output.
Bubble Sort
Write a program using a bubble sort algorithm to sort a string in ascending order stored in the
data segment. Print out the string on the screen before and after the sort. Use a string of at least
20 characters in length and the starting string should not be in ascending order.
The implementation of the bubble sort consists of a simple double loop. The first iteration of the
inner for loop moves through the string from bottom to top, comparing adjacent characters. If the
lower indexed character's value is higher than its higher-indexed neighbor, then the two values
are swapped. Once the smallest value is encountered, this process will cause it to "bubble" up to
the top of the array. The second iteration of the inner for loop repeats this process. Since the
smallest value reached the top of the array on the first pass, there is no need to compare the top
two elements on the second pass. Likewise, each succeeding pass through the array compares
adjacent elements, looking at one less value than the preceding pass.
The bubble sort algorithm is similar to the following:
For i = 0 to string_length - 2
for j = string_length - 2 to i
if string[j] > string[j + 1] then
swap string[j] with string[j + 1];
Output:
1. Output the initial string to the screen.
2. Output the final string to the screen.
3. Output the number of passes required to sort the string.
TURN IN: .LST File and screen Output.
1

Partial preview of the text

Download Laboratory Assignment 3 - Nested Looping in Assembly Language | EEL 3801 and more Lab Reports Computer Architecture and Organization in PDF only on Docsity!

Laboratory Manual EEL 3801 Lab # Laboratory Assignment # EEL 3801 Introduction to Computer Engineering Topic: Nested looping in assembly language. Turn in: .LST file and screen output. Bubble S ort Write a program using a bubble sort algorithm to sort a string in ascending order stored in the data segment. Print out the string on the screen before and after the sort. Use a string of at least 20 characters in length and the starting string should not be in ascending order. The implementation of the bubble sort consists of a simple double loop. The first iteration of the inner for loop moves through the string from bottom to top, comparing adjacent characters. If the lower indexed character's value is higher than its higher-indexed neighbor, then the two values are swapped. Once the smallest value is encountered, this process will cause it to "bubble" up to the top of the array. The second iteration of the inner for loop repeats this process. Since the smallest value reached the top of the array on the first pass, there is no need to compare the top two elements on the second pass. Likewise, each succeeding pass through the array compares adjacent elements, looking at one less value than the preceding pass. The bubble sort algorithm is similar to the following: For i = 0 to string_length - 2 for j = string_length - 2 to i if string[j] > string[j + 1] then swap string[j] with string[j + 1]; Output:

  1. Output the initial string to the screen.
  2. Output the final string to the screen.
  3. Output the number of passes required to sort the string. TURN IN: .LST File and screen Output. 1