Section 01 Part 03 – Instruction Set Out

 

Computer Science is no more about computers than astronomy is about telescopes.” ~Edsger W. Dijkstra.

 

 

 

Introduction

 

The 68k has a set of “instructions” that you can use (i.e. commands).  You can use these instructions to get the 68k to do what you want it to do.  They can be instructions that change numbers, control where the processor reads from or writes to, and many other things.

 

In this part, we’re going to look at the basic set out of an instruction.

 

 

 

Mnemonics

 

In computing, instructions are read by the processor in binary (bits), here’s an example of an instruction:

 

0011 0000 0011 1100 0000 0100 1111 0000

 

Of course, we don’t want to work exclusively with binary, it would simply take too long to memorise and work with.  This is where assembly comes in.

 

We use what are known as “mnemonics”, and they are simply words written in our language to make it easier for us to program.  Here’s the same instruction, but in mnemonic form:

 

          move.w    #$04F0,d0

 

Now, you may notice that I’ve broken the instruction up into different colour coded sections, we have; the command, size, source operand, and destination operand.

 

 

So, let’s take a look at an instruction you’ll find easy to understand:

 

          move.b    #$2C,$0000001E

 

This instruction will move the byte 2C into memory at offset 0000001E.  As you can see, it does exactly what it says on the tin.

 

After the 68k processes that instruction, the byte in memory at offset 0000001E will be 2C:

 

Offset

0

1

2

3

4

5

6

7

8

9

A

B

C

D

E

F

00000000

00

00

00

00

00

00

00

00

00

00

00

00

00

00

00

00

00000010

00

00

00

00

00

00

00

00

00

00

00

00

00

00

2C

00

00000020

00

00

00

00

00

00

00

00

00

00

00

00

00

00

00

00

00000030

00

00

00

00

00

00

00

00

00

00

00

00

00

00

00

00

etc

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

It really is that simple.

 

When you assemble your code, the assembler will convert all of your mnemonics:

 

          move.w    #$04F0,d0

 

Into binary:

 

0011 0000 0011 1100 0000 0100 1111 0000

 

So the 68k can read it.

 

 

 

The # and $ symbols

 

You may have also noticed the # and $ symbols that appear before the 2C and 0000001E, the $ symbol is to tell the assembler that the number is a “hex” number, not “decimal” number, if you had no $ symbol for example:

 

          move.b    #32,$0000001E

 

The assembler will convert 32 (decimal) to 0010 0000 (binary) when it assembles it.  0010 0000 is 20 in hex, so writing 32 is the same as writing $20.  If you wanted to write binary numbers, you can use the % symbol.

 

          move.b    #%00100000,$0000001E

          move.b    #$20,$0000001E

          move.b    #32,$0000001E

 

All of these above are exactly the same, the top is the binary version (%), the middle is hexadecimal ($) and the bottom is decimal.  We’ll be using hex and binary in this tutorial more than decimal to help you get a good feel and understanding of them.

 

The # symbol on the other hand, is to tell the assembler, that the number is an “immediate” value, and not an offset.  So what’s an “immediate” value?   Hold that thought for just one moment, and let us look at an example without the # symbol:

 

          move.b    $00000010,$0000002D

 

This will read the byte held at offset 00000010, and copy it over to offset 0000002D, if the byte at offset 00000010 was 49, then 0000002D will now also be 49:

 

Offset

0

1

2

3

4

5

6

7

8

9

A

B

C

D

E

F

00000000

00

00

00

00

00

00

00

00

00

00

00

00

00

00

00

00

00000010

49

00

00

00

00

00

00

00

00

00

00

00

00

00

00

00

00000020

00

00

00

00

00

00

00

00

00

00

00

00

00

49

00

00

00000030

00

00

00

00

00

00

00

00

00

00

00

00

00

00

00

00

etc

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

And now back to “immediate”, as far as I’m concerned, it’s just a fancy name for “raw number”, the # symbol tells the 68k that the number is not an offset/address.

 

 

 

Previous Part

Main Page

Next Part