Sei sulla pagina 1di 10

Some notes on Debugger Window Removing all the other lines and using only the program will

cause the system to begin at $FFFF and PC is therefore pointing to $0000 (see in figure below PC = 0 in the Register window, circle in red).

HCS12 register set

To start execution at $2000, where program is located. Double-click on the PC box and enter 2000.

Note:

IP (Instruction Pointer) also changes to 2000. IP = PC Current values of CCR: S = 1, X = 1, I = 1, the rest are 0 as they are grey. Index X register content = CBCB Index Y register content = CBCB
Page 1 of 10

Accumulator D has CBCB; accumulator A has CB; accumulator B has CB Stack pointer is pointing to CBC9.

At the bottom, there is a memory window. Address is 80. Content is uu.

Start address of

CPU frequency. CPU frequency = crystal frequency/2

Number of CPU cycles have gone by (used for determine amount of time gone by)

Considering only line with address C0.this is how we read the address for 1 line.
Start Address C0 C1 C2 C3 C4 C5 C6 C7 C8 C9 CA CB CC CD CE CF

Page 2 of 10

Scrolling down to address 2000, we can see the machine code of the program as well as the values in the dc.w lines.

Code in hexadecimal.

Values in the dc.w lines. NOP rts Address 2015. Content is $00.

Note: dc.w causes 2 bytes to be used. * means current location (which is 201F)

To change content of certain location in the memory (for ports, identify their addresses from the memory map or hardware manual),

click on the location using the left mouse button to select it see the highlighted in blue

then right click your mouse and a menu will pop-up. Select Fill from the menu.

Page 3 of 10

Fill

a window will pop-up to allow you to fill in the address or location you wish to fill up with certain hexadecimal value. The address for the location selected is $2023.

Fill up the start (from) Address and to Address (can be address of Port) as well as the desired value in hex. Click OK result is as shown. Content changed from uu to FF.

Page 4 of 10

Pressing the single step button leads to changes indicated in red circles:

Note:

Instruction being executed is ldaa #100; which leads to content of accumulator A = $64 = 100. CPU cycles = 1; meaning ldaa #100 only takes up 1 cycle Line or instruction highlighted in both the Source and Assembly window is the next instruction to be executed. This next instruction has an address of $2002, which is the PC and IP contentmeaning PC always point to the next instruction to be executed. The difference in addresses for ldaa #100 and ldaa $50 $2002 - $2000 = 2 (bytes) this means ldaa #100 takes up 2 bytes.

Compare each line of the assembly code and the machine codeyou will find interesting things.you can check your machine code or object code here.

Page 5 of 10

Program ends at address $(200C 1). Program begins at address $2000. size of program = $200B - $2000 = 12

For 07 18; 07 is for BSR 18 is for Rel (relative address) Destination = $2021; PC = $2009

This is where the sub-routine is or begins. RTS indicates the end of the sub-routine.

Page 6 of 10

Checking for time taken to run the program.observe the CPU Cycles. Here 91 cycles have gone by meaning ((
)

After single steppingwe know the number of cycles or amount of time, which have gone by.

Alternative method select the Clock Frequency from the HCS12 FCS menu.

Page 7 of 10

A window indicating the Oscillator frequency (crystal frequency) and Display in status bar will appear, see next page. If True Time (in ms) is selected, the time take will appear.

The oscillator frequency can be adjusted based on the actual crystal to be used (for example, in the final year project, the 8MHz crystal might be used for faster operation).

Time taken to execute the code so far.

Page 8 of 10

Some more tricks. Trick 1: Position your cursor to the Assembly window and right click your mouse. You will get the following.

Then, select Address to get the following window, where you may display the desired start address or the address where your program begins.

Trick 2: If you choose Display and select all Code, Symbolic, Address, Absolute Addressyoull have all the answer for listing the object code

Page 9 of 10

Address

Respective object code

Page 10 of 10

Potrebbero piacerti anche