Programming Assignment4 - University of Wisconsin

University of Wisconsin - Platteville
Department of Computer Science and Software Engineering
CS 3230 – Computer Architecture and Operating Systems
Assignment 4
Circular Queue in Assembly
INTRODUCTION:
A Queue is a type of data structure that implements the FIFO (First-In-First- Out)
ADT (Abstract Data Type). In queue, data elements are added at one end, called the
Rear and removed from another end, called the Front of the list. That is, Rear
represents the location in which the data element is to be inserted and Front
represents the location from which the data element is to be removed.
The queue has two types namely, linear and circular. In the linear queue, once the
queue is full, even though few elements from the front are deleted and some occupied
space is relieved, it is not possible to add anymore new elements, as the rear has
already reached the Queue’s rear most position. This represents the main drawback
of the linear queue, see Figure 1.
Rear = 6 and Front = 3. The queue is full and so can’t add any new item to the queue
1
2
30
40
20
60
3
4
5
6
Figure 1. Linear Queue
The solution for the above drawback is the circular queue, where the queue is not
linear but circular, see Figure 2.
Figure 2. Circular Queue
For instance, Figure 3 shows the insertion and deletion in the circular queue with
maximum size of 5.
OBJECTIVES:
You are to implement a Circular Queue ADT. Given a queue, each node is defined
by a struct as:
struct Node
{
char Movie_Title [10];
// null terminated character array
int Movie_Price;
}
You must implement the following methods for the Circular Queue (a separate
subprogram for each method):
 IsEmpty ( CircularQueue * Movies )
A subprogram that receives a Circular Queue via the stack (i.e. the
Queue‘s pointer is passed to the subprogram) and then returns true if
the queue contains no items; otherwise returns false.
Figure 3. Insertion and Deletion in Circular Queue
 IsFull ( CircularQueue * Movies )
A subprogram that receives a Circular Queue via the stack (i.e. the
Queue‘s pointer is passed to the subprogram) and then returns true if
the queue is full; otherwise returns false.
 Enqueue ( CircularQueue * Movies )
A subprogram that receives a Circular Queue via the stack (i.e. the
Queue‘s pointer is passed to the subprogram) and then reads a new
movie information and creates a new node that is added to the Rear of
the queue Movies. If the received queue is full, then the subprogram
must throw an error message and exit.

Dequeue ( CircularQueue * Movies )
A subprogram that receives a Circular Queue via the stack (i.e. the
Queue‘s pointer is passed to the subprogram) and then removes the
movie that is at the Front of the queue Movies and prints its contents. If
the received queue is empty, then the subprogram must throw an error
message and exit.
 Clear ( CircularQueue * Movies )
A subprogram that receives a Circular Queue via the stack (i.e. the
Queue‘s pointer is passed to the subprogram) and then removes all of
the items from the received queue.
 Display ( CircularQueue * Movies )
A subprogram that receives a Circular Queue via the stack (i.e. the
Queue‘s pointer is passed to the subprogram) and then prints all of the
items in the received queue, one per line.
 Export ( CircularQueue * Movies)
A subprogram that receives a Circular Queues via the stack (i.e. the
Queue‘s pointers are passed to the subprogram) and then writes all of
the items in the received queue, one per line, into an existing text file.
For the consistency, the text file must be named out.txt, and the file
must be in your solution folder.
IMPLEMENTATION NOTES:
1- You are encouraged to use all of the string functions that are
implemented in string2.asm
(http://people.uwplatt.edu/~meqdadio/CS3230/SLIDES/CodeExamples/s
tring2.asm)
2- To test the functionalities of the Circular Queue ADT, set the maximum
size of the queue to 4.
3- The main subprogram must display a menu of choices and let the user
select what she/he prefers to do. The main must keep displaying the menu
until the user selects the exit option.
REQUIREMENTS and SUBMISSION:
 You could work in groups of two for this assignment. As such, you must split
up the work appropriately. Indicate in the code comments who worked on
each code block.
 YOUR PROGRAM MUST BE NAMED fourthhw.asm
 Add a comment at the beginning of your program with group member names.
 Each group should submit only one copy.
 When you are done:
Copy and paste your solution folder to
S:\Courses\CSSE\meqdadio\cs3230\<your_login_name>