Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Lab One: PowerPC Instruction Set and CodeWarrior - CSE4903 - Prof. Zhijie Shi, Lab Reports of Microprocessors

A lab exercise for cse4903 students, focusing on the powerpc architecture, its registers, and instruction set. Students will learn to code and debug programs using metrowerks codewarrior, and complete tasks such as implementing bubble sort algorithm, clearing an array, and depositing constants into an array using embedded instructions. Students are encouraged to optimize their code for performance and document their design, implementation, and results.

Typology: Lab Reports

2009/2010

Uploaded on 02/24/2010

koofers-user-xe1
koofers-user-xe1 🇺🇸

10 documents

1 / 2

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
CSE4903
1/2
Lab One: Introduction to PowerPC Instruction Set,
MPC875 and CodeWarrior
In this lab you will start exploring the PowerPC architecture, its registers and instruction set.
You will learn how to code and debug programs in Metrowerks Codewarrior, an integrated
software development environment for many embedded, handheld, and desktop platforms. You
will also get familiar with the laboratory report requirements.
1 Introductory PowerPC Exercises
In this exercise you will use PowerPC instructions to accomplish several basic tasks. Before you
start to write your own program, you may want to get familiar with the tools. A sample project
lab1.zip can be downloaded from the course website. Follow the instructions in the manual
to compile and run the sample code first. Then, you can add your own code into the sample code
to complete the following tasks.
1. Implement the bubble sort algorithm with C language to sort an array of unsigned
integers into descending order. The interface of the function will look like:
void my_bubblesort(unsigned int *p, int n);
The function will sort the n unsigned integer stored in p in descending order.
2. Define an array BUF of eight (8) unsigned integers. Implement a function with embedded
instructions to set the array to 0. For example, your code may look like:
void clear_array(unsigned int *p, int n) {
asm {
}
}
You can then call clear_array(BUF, 8) to set BUF to 0.
3. Implement a function and use embedded assembly code to deposit the following 32-bit
words into BUF. Do not assume these values are stored somewhere in the memory. (Hint:
each constant requires two instructions.)
0x01234567, 0x89ABCDEF, 0x55555555, 0xAAAAAAAA,
0xFEDCBA98, 0x76543210, 0xD409ACAB, 0X3C7A9BC0.
pf2

Partial preview of the text

Download Lab One: PowerPC Instruction Set and CodeWarrior - CSE4903 - Prof. Zhijie Shi and more Lab Reports Microprocessors in PDF only on Docsity!

CSE

Lab One: Introduction to PowerPC Instruction Set,

MPC875 and CodeWarrior

In this lab you will start exploring the PowerPC architecture, its registers and instruction set. You will learn how to code and debug programs in Metrowerks Codewarrior, an integrated software development environment for many embedded, handheld, and desktop platforms. You will also get familiar with the laboratory report requirements.

1 Introductory PowerPC Exercises

In this exercise you will use PowerPC instructions to accomplish several basic tasks. Before you start to write your own program, you may want to get familiar with the tools. A sample project lab1.zip can be downloaded from the course website. Follow the instructions in the manual to compile and run the sample code first. Then, you can add your own code into the sample code to complete the following tasks.

  1. Implement the bubble sort algorithm with C language to sort an array of unsigned integers into descending order. The interface of the function will look like:

void my_bubblesort(unsigned int *p, int n);

The function will sort the n unsigned integer stored in p in descending order.

  1. Define an array BUF of eight (8) unsigned integers. Implement a function with embedded instructions to set the array to 0. For example, your code may look like:

void clear_array(unsigned int *p, int n) { asm {

} }

You can then call clear_array(BUF, 8) to set BUF to 0.

  1. Implement a function and use embedded assembly code to deposit the following 32-bit words into BUF. Do not assume these values are stored somewhere in the memory. (Hint: each constant requires two instructions.) 0x01234567, 0x89ABCDEF, 0x55555555, 0xAAAAAAAA, 0xFEDCBA98, 0x76543210, 0xD409ACAB, 0X3C7A9BC0.

CSE

  1. Consider the words in BUF as unsigned 32-bit words. Compute the sum of the eight words with embedded instructions. (Hint: you may need two registers to store the sum during the computation and store the result in an array.)
  2. Implement the bubble sort with embedded instructions.

You are free to use any instructions to accomplish the above tasks, but awkward choices of instructions will result in point deduction. You should try your best to optimize the code for performance.

Document your design, implementation, and results carefully. You may consider these tasks as several steps in a big task. So you can have only one objectives section, in which you describe all the tasks you have done (instead of having several individual objectives sections).

2 Deliverables

Write a report adhering to the lab requirements. The report should include your design rationale (e.g. why you choose these instructions and how they achieve the goals) and results. Since you do not need many instructions to finish these tasks, you can include important sections of your code in the report.