CprE 211
Getting Started
Expected time in class: 30 minutes
Be sure you have carefully read the notes on the add assembly program so that you are familiar with the assembly language instructions in this program. It will be very difficult for you to benefit from this activity if you have not studied the program in advance.
Your lab instructor will single-step through this program using the CodeWarrior debugger as a class activity at the start of the lab. You may watch the instructor’s demonstration, or you may follow along with your own debugging session.
You will tabulate what you observe as the program executes.
Observing the Assembly Program
Your instructor (and you, if you choose) will follow these steps:
1. Use the instructions from Lab 1, Section 4 – Assembly Language, to start a new project that uses assembly code.
· Add the Lab6_add.asm file to your project. Delete the existing MainSource.asm file. (Or cut-and-paste the new code into the existing file.)
2. From the debugger, step into the function JumpAsm( ) and proceed step by step. Proceed until bl StartAsm (which transfers control to the assembly function we added in the other file). Continue stepping, and watch the control flow enter into the assembly code.
3. Open a Register window.
4. Now you are ready to step through each assembly instruction in the program and observe what happens in the Register and Memory windows. What does each instruction do? Fill in the table. Note: when stopped at an instruction, the instruction has not yet executed (status is before the current instruction); stepping causes the current instruction to execute (status is after the current instruction).
5. After you execute the first two instructions, R2 has the value of the label DataSeg. Open a Memory window at the DataSeg address – it should display the contents of memory starting at DataSeg, including the values $11 and $22 in the first two words of memory.
|
Instruction |
BEFORE |
AFTER |
Notes |
|
lis r2, DataSeg@h |
PC: |
PC: |
|
|
ori r2, r2, DataSeg@l |
PC: |
PC: |
|
|
lwz
r31,0(r2) |
PC: |
PC: |
|
|
lwz
r30,4(r2) |
PC: |
PC: |
|
|
add
r30, r30, r31 |
PC: |
PC: |
|
|
stw
r30, 8(r2) |
PC: |
PC: |
|
|
blr |
PC: |
PC: |
|