Section 05 Part 02 – The JMP Instruction

 

 “Living at risk is jumping off the cliff and building your wings on the way down.” ~Ray Bradbury

 

 

 

Introduction

 

JMP – JuMP unconditionally

 

The destination operand is moved into the PC, the 68k will continue reading at the location of the destination operand.

 

 

 

Simple Examples

 

OK, so, here is a list of instructions:

 

          move.w    d0,d1

          add.w     d1,d1

          add.w     d1,d0

          jmp       SkipCode

          add.w     d2,d3

          asr.w     #$04,d0

 

SkipCode:

          move.w    d0,d2

 

These are just random instructions, but right in the middle you’ll see the new JMP instruction:

 

          jmp       SkipCode

 

This instruction will make the 68k jump right over a whole load of instructions to “SkipCode”.  Further down the list of instructions you’ll notice “SkipCode:”, this is what we call a “lable” (or label for those of you reading in US English), and this is where the JMP instruction will make the 68k jump to.

 

So imagine for a moment, the processor is reading these instructions:

 

 

The next instruction is “jmp SkipCode”, what happens now, is the 68k will jump directly over the “add.w d2,d3” and “asr.w #$04,d0” and land at “SkipCode:”, there it’ll continue with “move.w d0,d2”.

 

Here’s a diagram to help simplify it:

 

 

You can jump almost anywhere using this instruction, including backwards.

 

 

 

Complex Examples

 

The way it works is address of “SkipCode” is put into the PC (Program Counter), which causes the 68k to read directly at that new address.

 

Here are the instructions in memory to give you a clearer idea:

 

Offset

0

1

2

3

4

5

6

7

8

9

A

B

C

D

E

F

00244200

32

00

D2

41

D0

41

4E

F9

00

24

42

10

D6

42

E8

40

00244210

34

00

00

00

00

00

00

00

00

00

00

00

00

00

00

00

00244220

00

00

00

00

00

00

00

00

00

00

00

00

00

00

00

00

00244230

00

00

00

00

00

00

00

00

00

00

00

00

00

00

00

00

etc

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Notice the jmp SkipCode instruction at offset 244206.  4EF9 is the instruction (JMP) and 00244210 is the offset to jump to.

 

For 00244210, the 00 on the far left is ignored, while the 244210 is put into the PC.  The 68k will then read the PC, and go to offset 00244210, which you can see contains “3400” (move.w d0,d2).

 

It is pretty simple, but remember; the PC is 24-bit, meaning that if the JMP instruction has F2049800 as the jump location, the F2 is ignored.  Only the 049800 is read, and the 68k will proceed to offset 00049800.  This basically means that the 68k’s memory range is actually from 00000000 to 00FFFFFF.  That’s 16 Mega-Bytes of offset memory the 68k can theoretically access.

 

There are also various addressing modes used with this instruction, but we’ll come back to them later on.

 

 

 

Previous Part

Main Page

Next Part