Section 05 Part 01 – The PC (Program Counter)

 

 “The opposite for courage is not cowardice, it is conformity. Even a dead fish can go with the flow” ~Jim Hightower

 

 

 

Introduction

 

There are instructions that change the location of where the 68k is reading its instructions.  To allow the 68k to do this, they use the PC and SP, so let’s take a look.

 

 

 

The PC (Program Counter)

 

The PC (Program Counter) is another 68k register; it is designed to hold the current location of where the 68k is currently reading.  Now, all of the instructions you have learnt so far, have to exist somewhere in memory, for example:

 

          move.w    #$0F20,d0

          add.l     d1,d0

          lsr.w     #$02,d0

          move.w    d0,$00200000

 

I’ve colour coded each instruction differently for this example.  These instructions have to exist in memory somewhere for the 68k to be able to read them, so we’ll pretend they’re in memory at offset 00001000:

 

Offset

0

1

2

3

4

5

6

7

8

9

A

B

C

D

E

F

00001000

30

3C

0F

20

D0

81

E4

48

33

C0

00

20

00

00

00

00

00001010

00

00

00

00

00

00

00

00

00

00

00

00

00

00

00

00

00001020

00

00

00

00

00

00

00

00

00

00

00

00

00

00

00

00

00001030

00

00

00

00

00

00

00

00

00

00

00

00

00

00

00

00

etc

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

As I said before, the 68k reads instructions in binary, but you can probably see the similarities, like the move instruction, where the 303C is the move.w and d0, and you can see after it the 0F20.

 

The PC is 24-bit, meaning it’ll only hold the end three bytes of the offset.

 

In our example above, the PC will start with 001000.

 

 

As you can see, the PC is the main control over where the 68k reads.  In this section, we’ll be looking at jump and branch instructions that can change the PC, and allow you to change where the 68k reads its instructions from.

 

 

 

Previous Part

Main Page

Next Part