|
lea (MarkeyJester’s).l,a0 lea (Motorola).l,a1 move.l #$00068000,d0 add.l #Beginner’s,d0 move.l #Tutorial,d1 move.l d0,(a0)+ move.l d1,(a1)+
|
|
(MarkeyJester’s Motorola 68000 Beginner’s Tutorial) |
Introduction
Hello. I’m MarkeyJester, and for several years, I have been programming in 68k assembly. I have made quite a few Sonic The Hedgehog ROM modifications (a.k.a. hacks), have made a few proto games, and I’m currently in the process of programming a full game from ground up, for the SEGA Mega Drive system.
I had
trouble learning the language to begin with, and found that a lot of 68k
assembly tutorials didn’t really help.
In fact, hardly any of them explained it from a beginner’s point of
view, and were extremely vague. There
was only one tutorial I found that really pointed me in the right direction,
and it was a guide by SonicRetro member redhotsonic, though his tutorial has a few holes in places
which makes it sort of impractical.
So,
this tutorial here is an attempt at teaching 68k assembly at an extreme
beginner’s level, to help steer away from all of those vague guides out
there. If you have any questions to ask,
or any advice or feedback to share, then feel free to contact me by email at markeyjester “at” gmail
“dot” com.
Please
note, I have been getting a lot of emails regarding the simulator BSVC, and a lot of the questions
related to problems with using macros correctly. I’m afraid I don’t work with BSVC or EASy68k, and these questions are very
hardware specific and actually have nothing to do with 68k itself. So chances are, I
cannot help you in that regard. So
please keep that in mind, and maybe check out manuals/documents that may have
came with the hardware/simulator.
Good luck.
Contents
|
Section 01 – Getting Started |
||
|
|
|
|
|
|
This
section shows the basics of 68k assembly programming. |
|
|
|
|
|
|
|
Part
01 |
|
|
|
Part
02 |
|
|
|
Part
03 |
|
|
|
Part
04 |
|
|
|
Part
05 |
|
|
|
Part
06 |
|
|
|
Part
07 |
|
|
|
|
|
|
Section
02 – Basic Instructions |
||
|
|
|
|
|
|
In
this section, we look at some basic instructions that are relatively simple
to use. |
|
|
|
|
|
|
|
Part
01 |
|
|
|
Part
02 |
|
|
|
Part
03 |
|
|
|
Part
04 |
|
|
|
Part
05 |
|
|
|
Part
06 |
|
|
|
|
|
|
Section
03 – Binary Instructions |
||
|
|
|
|
|
|
This
section deals with binary manipulation (bit specific instructions). |
|
|
|
|
|
|
|
Part
01 |
|
|
|
Part
02 |
|
|
|
Part
03 |
|
|
|
Part
04 |
|
|
|
Part
05 |
|
|
|
Part
06 |
|
|
|
|
|
|
Section
04 – Positive and Negative Instructions |
||
|
|
|
|
|
|
This
section looks at instructions that work with positive and negative. We also look at other similar instructions
too. |
|
|
|
|
|
|
|
Part
01 |
|
|
|
Part
02 |
|
|
|
Part
03 |
|
|
|
Part
04 |
|
|
|
Part
05 |
|
|
|
Part
06 |
|
|
|
Part
07 |
|
|
|
Part
08 |
|
|
|
Part
09 |
|
|
|
Part
10 |
|
|
|
|
|
|
Section
05 – Program Flow Change |
||
|
|
|
|
|
|
Here,
we take a look at instructions that cause the 68k to jump to different
locations to read different instructions. |
|
|
|
|
|
|
|
Part
01 |
|
|
|
Part
02 |
|
|
|
Part
03 |
|
|
|
Part
04 |
|
|
|
Part
05 |
|
|
|
Part
06 |
|
|
|
|
|
|
Section
06 – Conditional Branches |
||
|
|
|
|
|
|
In
this section, we look at instructions that change the PC of the 68k, but this
time, based on certain conditions. |
|
|
|
|
|
|
|
Part
01 |
|
|
|
Part
02 |
|
|
|
Part
03 |
|
|
|
Part
04 |
|
|
|
Part
05 |
|
|
|
Part
06 |
|
|
|
Part
07 |
|
|
|
Part
08 |
|
|
|
|
|
|
Section
07 – Conditional Instructions & Others |
||
|
|
|
|
|
|
This
section covers other instructions which function based on certain conditions. And other miscellaneous instructions... |
|
|
|
|
|
|
|
Part
01 |
|
|
|
Part
02 |
|
|
|
Part
03 |
|
|
|
Part
04 |
|
Cycle times
|
Description
- NEW |
|
|
|
All
instructions will take a certain amount of CPU time to process,
they are usually measured in “Cycles”, or “states”. So, you’ll want to know the speed of each
instruction, with different source and destination operands. Here,
I have collected and compiled together the cycle times a 68k CPU from a model
While
I’m certain these cycle times are accurate, the shift based instructions (lsl, lsr, asl, asr, rol, ror, roxl and roxr) might not be
accurate. The numbers you’ll see, are exactly how they came out on hardware, I couldn’t
find an explanation for this, but have left it here for your viewing
pleasure. Please
follow this link to an index page of instruction cycle times. |
Updates
|
2017
September 16 |
|
|
|
Once
again, it’s been a while, I’ve finally removed those stupid “NEW” tags, since they’re
technically not new d= This
update isn’t anything to do with the tutorial site, I still haven’t touched
it, and probably won’t for a long while.
But what I have done, is
compiled a list of cycle times for all instructions I possibly could. These were collected from hardware with the
highest accuracy I could muster given the technology I have available to
me. Look for “Cycle Times” just below the “Contents” menu. I’ve
been getting into lofi hip hop lately, so maybe you’ll enjoy it too~
|
|
Click here for previous "older" updates |
|
Minor Fixes Thanks To...
|
|
Tim
Hansson, Stuart Patton, Mathieu Stempell, Anthony Vanover, Paul Krigovsky, Andre
Tampubolon, Daniel Kang, Robert, Krzysztof Lasocki, Matt Cole, Fran
Jednobrkovic, Gus Lund, and Tomasz Rózanski. If
you find an error or mistake somewhere, be sure to email me, and I’ll fix it
almost immediately. |
Personal
68k Project(s)
|
Mega Drive Operating
System (MD-OS) |
|
|
|
|
|
|
|
|
A multi-threaded operating system for the Mega Drive. |
|
|
|
|
|
|
|
|
The chaos Layer |
||
|
|
||
|
|
|
|
|
This was a platform game I
was working on for the |
||
|
|
||
|
|
||
|
|
|
|
|
I did of course, release
what I had of this game so far, it's majorly incomplete, but it is what it
is. You can download it here, you will need either a Mega
Drive/Genesis emulator program to play this ROM, or a flash cart device and
an actual Mega Drive/Genesis. |
||
|
|
||
Special
thanks to http://www.quotegarden.com/ and http://www.brainyquote.com/ for the quotes used in this
tutorial, to redhotsonic for inspiration and ideas
drawn from his guide, and to Jorge, andlabs and FraGag, for their help, opinions,
overviews and corrections.
A visitor counter (Because why
not!).