Exercise5 - 0306-250 Assembly Language Programming Fall 2009 Laboratory Exercise Five Circular FIFO Queue Operations This exercise investigates

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 0306-250 Assembly Language Programming Fall 2009 Laboratory Exercise Five: Circular FIFO Queue Operations This exercise investigates circular FIFO queue operations using the HSC12. It requires polled serial I/O with the Freescale HCS12 MCU Application Module using the HCS12 Asynchronous Serial Communications Interface (SCI) along with the character and string I/O subroutines developed in the previous exercise. The objective of this exercise is to write subroutines to enqueue each character received from terminal input and to dequeue characters from a queue to terminal output. An assembly language program is created to test these subroutines, and it is executed on the HSC12 module. Prelab Work Following the specifications below and the notes you have taken in lecture, write subroutines for circular FIFO queue operations. (Use the queue management record structure in the class notes—including the field order and names.) You must write the subroutines so that the no registers other than CCR have changed values after return (RTS). (Exception: Dequeue uses B for an output parameter, so B’s value may be different after Dequeue.) · Dequeue: If the queue (whose queue record structure’s address is in X) is not empty, dequeues a single character from the queue, returns it in B, and reports dequeue success by returning with the CCR C cleared, (i.e., 0); otherwise, only reports dequeue failure by returning with the CCR C bit set, (i.e., 1). · Enqueue: If the queue (whose queue record structure’s address is in X) is not full, enqueues the single character from B to the queue and reports enqueue success by returning with the CCR C cleared; otherwise, only reports enqueue failure by returning with the CCR C bit set. Page 1 of 3 0306-250 20091 Lab Exercise Five: Circular FIFO Queue Operations Page 2 of 3 Program Specification You need to write a program to test your code from prelab. Below is the sequence of operations the program must perform. 1. Initialize the queue record structure for a queue buffer of 25 characters, (i.e., bytes). 2. Initialize the HCS12 SCI for polled serial I/O using a format of eight data bits, no parity, and one stop bit—as in Lab Exercise Four. 3. Using the properly documented PutString subroutine from Lab Exercise Four, output the character string below to the terminal screen followed by a carriage return character ($0D) and a line feed character ($0A) to advance the cursor to the beginning of the next line, and then output “>” as a prompt, as shown below. Type up to 78 characters, and then press the Enter key. > 4. Using the properly documented GetChar subroutine from Lab Exercise Four, accept characters typed on the terminal keyboard until the carriage return character is received. For each of up to the first 78 characters entered, echo the character to the terminal screen, increment it, and call Enqueue to put it in the queue. For any character beyond the first 78 and before the carriage return, accept the character but do not echo, do not increment, and do not call Enqueue. After each call to Enqueue, check to see if the operation was successful, and keep a running count of the number characters that failed to be enqueued. After the carriage return character is received, output a carriage return character and a line feed character to move the cursor to the beginning of the next line, and then output “<” as a marker, as shown below. Type up to 78 characters, and then press the Enter key. >Up to the first 78 characters typed by the user are here. < 5. Store the total number of characters that failed to enqueue (counted in step 4) to a variable in RAM. 6. Until the queue is empty, call Dequeue and output the dequeued character to the terminal screen using the properly documented PutChar subroutine from Lab Exercise Four. On the terminal screen, the dequeued characters should appear immediately after the “<” output marker character. 7. After the last character dequeued is printed on the terminal screen, move the cursor to the beginning of the next line. The program must use the subroutines from prelab work for queue operations. The subroutines must comply with the prelab specifications. Also, make sure each subroutine is properly documented (i.e., has a comment header block that documents these aspects): · Description of subroutine functionality, · Subroutines called list, · Input parameter list, · Output parameter list, and · Register modification list. 0306-250 20091 Lab Exercise Five: Circular FIFO Queue Operations Page 3 of 3 Lab Procedure 1. Create a new CodeWarrior directory (folder) and project on your X: drive for this exercise. 2. Write a properly commented and properly formatted HCS12 assembly language program according to the preceding specification. 3. Assemble the program in CodeWarrior compiler to create a listing file. 4. Link the program in CodeWarrior to create a linker map file. 5. Test your program. Make sure to test these input cases (i.e., after the prompt from specification 2), which must be demonstrated to the instructor. Input 1: No characters—enter key immediately after the prompt. Input 2: Between 1 and 25 characters. Input 3: Between 26 and 78 characters. Input 4: More than 78 characters. 6. Examine the HCS12 memory location containing the count of Enqueue failures after each input test case above, and record its value. 7. Examine the HCS12 memory map produced for your program, and list the exact memory range, (i.e., the starting address and the address of the last byte), for these components: a) Executable code, b) Constants in ROM (e.g., prompt string of specification 3), and c) RAM used: i. Queue record structure, ii. Queue buffer, and iii. Variable holding count of Enqueue failures. 8. Print the terminal screen output, your listing file, linker map file, and grading sheet, and then demonstrate steps 5-7 for your lab instructor, who will sign them. Report Write a report consisting of the following sections. · Abstract · Procedure · Results · Conclusion Your writing should follow the rules of professional technical writing and should meet the specifications in “Laboratory and Report Guidelines” on the course reference material web page. Staple your cover page, report, listing file, map file, terminal output, and grading sheet (in that order), and submit them at the beginning of the next lab session. Late reports are penalized 20% per day late, where “day late” is calculated by rounding submitted time to the nearest greater or equal integer number of days late. ...
View Full Document

This note was uploaded on 05/06/2010 for the course EECC 0306-250 taught by Professor Roymelton during the Fall '10 term at RIT.

Ask a homework question - tutors are online