02.08.2013 Views

Introduction To CodeWarrior™ – Simulating The - Freescale ...

Introduction To CodeWarrior™ – Simulating The - Freescale ...

Introduction To CodeWarrior™ – Simulating The - Freescale ...

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

2. Click the Green Start/Continue Arrow or click Run > Start/Continue. <strong>The</strong> program should run to your breakpoint and stop.<br />

(Note: A breakpoint stops the program before it executes that statement.)<br />

3. Now, step through your program one assembly language statement at a time by clicking on the single-step button or pressing<br />

F11 until you reach the nop instruction<br />

at the beginning of the program again.<br />

(We will see what the LDS instruction is<br />

all about later.)<br />

4. At each step inspect the Register window to see what is happening to the registers. Try to predict what will happen at each<br />

step BEFORE<br />

you click on the step button.<br />

Stimulate 3.<br />

1. Under what circumstances does it make sense to run and debug your programs in the simulator?<br />

2. When would you want to run and debug your programs using the hardware debugger?<br />

Skill Exercise 1<br />

1. Double click on each of the register boxes in the Register window and enter a value of zero for each register. You won't be<br />

able to change the CCR.<br />

2. Press the Reset Target button (or type control-R) to return the program to the initial reset state.<br />

3. Single-step through the program and complete a table showing<br />

the result of each instruction. <strong>The</strong> CCR (Condition Code<br />

Register) bits NZVC a re shown bold w hen th e bit is set.<br />

Instruction D A B IX IY PC SP NZVC<br />

Reset state 00 00 00 00 00 00 00 00 C000 FFFE 00 00<br />

lds<br />

#__SEG_END_SSTACK<br />

nop<br />

ldx #ConstData<br />

ldab #$02<br />

ldaa 0,x<br />

staa VarData<br />

ldaa 2,x<br />

staa VarData+1<br />

inx<br />

decb<br />

bne loop<br />

ldaa 0,x<br />

staa VarData<br />

ldaa 2,x<br />

staa VarData+1<br />

inx<br />

decb<br />

bne loop<br />

<strong>Freescale</strong> Semiconductor LABS12CINTRO03S, Rev 1 7

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!