Skip to main content
? Dieu of Hemoroids

68000 MACHINE LANGUAGE COURSE PART I by Mark van de Boer

Originally  published in ST NEWS Volume 1 Issue  6,  launched  on 
November 15th 1986.

As  the  title  already says this is the first  part  of  an 68000 
assembly language programming course.  This course is intended for 
people  who  already have a little experience with programming  in 
assembly  language  on microprocessors like the 6502 (6510  is  in 
fact the same) and the 68xx (like 6800,  6801, 6805, 6809) series. 
In   this  course  these  two  microprocessor-families   will   be 
referenced by their most famous members, the 6502 and the 6809. At 
this  time it is not exactly known how many articles  this  course 
will have. I think it will be about six articles long.
Now  I will describe some features of the 68000.  The 68000  is  a 
sixteen-bit  microprocessor.  This means that an opcode is  always 
sixteen bits (On the 6502 and 6809 an opcode is 8 bits,  therefore 
they are called 8-bit microprocessors).  The databus of the  68000 
is  16 bits wide,  this means that 16 bits can be  transferred  at 
once  by the 68000 (The 6502 and 6809 both have a databus that  is 
eight  bits wide,  so they can transfer 8 bits at  once).

Another  important feature of the 68000 is its impressive  set  of 
registers.  First there are the eight data registers, numbered D0-
D7. They are 32 bits wide and can be used for operations on 8-bit, 
16-bit and 32-bit quantities.  Data registers can be compared with 
the  A-register  (Accumulator)  on  the  6502  and   6809,   their 
function  same,  but  the use of the data registers is  much  more 
convenient.   Second,  there  are  the  eight  address  registers, 
numbered from A0-A7.  They are 32 bits wide as well and their only 
use  is  in  addressing memory.  However,  the upper  8  bits  are 
ignored  by  the  68000 since its address bus is  'only'  24  bits 
wide,  meaning  that the 68000 can address up to 16  megabytes  of 
memory.  Register  A7  has a special function;  it is  called  the 
system  stackpointer.  This  means  that  if  you  execute  a  JSR 
instruction,  some data will be saved on the address contained  in 
this  register.  By the way,  you can use every  address  register 
very  easily as a stackpointer.  The third class consists  of  one 
register, the PC (program counter). This register always  contains
the address of the instruction  to  be  executed next.  Of course,
the upper eight bits of the PC are also ignored. The  fourth class
consists of one 16 bit register, the status register, called SR.

This register is built up like this:

-------------------------------------------------------------
| T |   | S |   | I0| I1| I2|   |   |   | X | N | Z | V | C |
-------------------------------------------------------------
    system-byte             |          user-byte

The  upper 8 bits are called the system byte.  This byte  contains 
information that is important to the system.  Normally you can not 
change this byte if you run an application.  Bit 15 is called  the 
trace-bit.  If  this  bit is set,  every time after  executing  an 
instruction  the 68000 will generate an exception (This is  called 
an interrupt on the 6502 and 6809). This is especially useful when 
debugging programs. Bit 13 is called the supervisor bit. When this 
bit  is  set the 68000 is in supervisor mode;  when  this  bit  is 
cleared,  however,  the 68000 is in user mode.  When executing  in 
supervisor  mode,  the 68000 can execute the so called  privileged 
instructions,  which are not available in user mode.  For example, 
it is illegal trying to change the upper 8 bits of the SR when  in 
user  mode.  Bits 8,  9 and 10 are called the interrupt  mask.  In 
total they can contain eight different values ranging from zero to 
seven.  For  instance,  if  bits  8 and 10 are set and  bit  9  is 
cleared,  the  value of the interrupt mask is 5.  This means  that 
only interrupts with a level of 5 and higher are recognized by the
68000  and  interrupts  with a level lower  than  5  are  ignored. 
Interrupts of level 7 can be considered as non maskable interrupts
(compare this to the NMI  on the 6502 and 6809).  The lower 8 bits
are   called  the  conditioncode  register,   CCR  (this  can   be 
compared to the CC of the 6502 and 6809). The CCR contains 5 bits,
which contain useful data.  Bit 0 is the carry-flag (C),  bit 1 is 
the overflow-flag (V),  bit 2 is the zero-flag (Z),  bit 3 is  the 
negative-flag  (N).  The  meanings of these bits are  exactly  the 
same as on the 6502 and 6809.  Then there is bit 4 which is called 
the extend-flag (X).  It is nearly exactly the same as the  carry-
flag,  but  is not affected by every instruction that affects  the 
carry-flag. This feature of the extend-flag  is  especially useful
when  using  multiple precision  arithmetic,  e.g.  adding  64-bit 
numbers.
Another  feature of the 68000 is its ability to access three  data 
formats: byte (8 bits), word (16 bits) and longword (32 bits). You 
can  indicate  this  with a suffix  in  the  mnemonic  field.  The 
suffixes are .b for byte,  .w for word and .l for  longword.  E.g. 
asr.b d0  ,   asr.w   d0    , asr.l   d0. These instructions shift 
data register d0 one place to the right.
I  think  this is enough new stuff for today.  Next  time  I  will 
explain  the  addressing  modes of the  68000.  If  you  have  any 
comments  or  questions  on this  article,  please  write  to  the 
correspondence address and I'll take your notes into account.

A good Motorola MC 68000 book is:
The Motorola 68000 programming guide,  which unfortunately is  not 
available in the stores.
Further there are a number of books on the 68000.  I would like to 
mention the book written by Lance Leventhal & Gerry Kane,  which I 
think gives good value for its money.  Another good book is  Steve 
Williams' "Programming the 68000".

Disclaimer
The text of the articles is identical to the originals like they appeared in old ST NEWS issues. Please take into consideration that the author(s) was (were) a lot younger and less responsible back then. So bad jokes, bad English, youthful arrogance, insults, bravura, over-crediting and tastelessness should be taken with at least a grain of salt. Any contact and/or payment information, as well as deadlines/release dates of any kind should be regarded as outdated. Due to the fact that these pages are not actually contained in an Atari executable here, references to scroll texts, featured demo screens and hidden articles may also be irrelevant.