
68000 Tricks and Traps – Some assembly language programming guidelines (1986) - rocky1138
http://www.easy68k.com/paulrsm/doc/trick68k.htm
======
AnimalMuppet
Note: 1986

Ah, what wonderful chips the 68000 series were, at least for the era. So many
registers, such a nice clean architecture. Good times.

~~~
Symmetry
The idea of having separate data and address registers is a really interesting
one. I've heard that the only pain point was not being able to take the
difference between two addresses quickly.

~~~
ajross
Not the _only_ pain point. It made register assignment harder for the
compiler.

Fundamentally you load from memory in generated code by adding two numbers
together (e.g. the struct address and field offset, array address and
index...). Motorola figured that you could just pick one number from each of
two sets and thus save two bits (i.e. the source registers could be encoded
with 3 bits instead of 4) in the encoding for the instruction.

As far as CISC tricks go, it wasn't too bad. But it's aged poorly: no one
would design a ISA like that today, while Intel's elaborate addressing modes
introduced with the 386 are producing code size and cache efficiency benefits
to this very day.

~~~
puzzle
Didn't the 68020 add even more addressing modes, plus scaling? Comparing the
68000 to the 386 doesn't seem too fair.

~~~
mikepavone
Addressing modes on the 68020 are kind of crazy. In addition to some
relatively straightforward improvements (scaling for the indexed mode, options
for larger displacements on both the displacement mode and indexed mode) they
also added something called "memory indirect" modes. These allowed you to
dereference a pointer in memory in a single operation. In these modes you have
a base register, a base displacement, an index register (with scale) and an
outer displacement. The index register could be applied either to the base
value or to the fetched "outer" value.

~~~
ajross
For clarity: I mentioned the 386 addressing modes because fundamentally the
ModRM encoding was designed to address the same code generation problem:
efficiently encoding one instruction to compute base-plus-offset (-plus-
immediate too) in addressing memory. This avoids having to compute an address
first for what is one of the most common operations in application code. As it
happened, Intel's trick was the better idea. Motorola's original register
design was fine but not as good, the '020 madness didn't survive contact with
the RISC pipeline.

~~~
mikepavone
With the exception of index scaling (which as already mentioned, was added in
the 68020) ModR/M and SIB is a strict subset of the 68000 addressing modes. I
don't see what this has to do with the address register/data register split
though. The 386 only had 8 GPRs and only 7 of those could be used as a base or
index register. The reason for the address/data split is to allow 16 registers
without needing 4-bit register fields.

Apart from the overly complex memory indirect modes, I'm having a hard time
seeing how the 386 ModR/M and SIB setup is superior to what was in the 68020.
Twice as many registers (though with usage restrictions), PC-relative
addressing and a cleaner encoding. Those first two things have been fixed in
x86-64 (and with generally fewer usage restrictions), but at the cost of
making the encoding even worse.

------
znpy
Easy68k. I have hated that program with passion during the computer
architecture course.

Didn't know how and why, but various conditional jumps used to plain fail.
Conditions were met, but the jmp/je/jne/jz would not be executed.

That being said... The m68k... I was saddened to discover thst coldfire mcus
had been discontinued, it would have been nice to play with an m68k-based
board.

~~~
Gracana
If you're looking for a nice CISC architecture to replace m68k, I recommend
the Renesas RX family. There's a lot of options, availability is good, and the
ISA is assembly-pogrammer-friendly.

[https://www.renesas.com/en-
us/doc/products/mpumcu/doc/rx_fam...](https://www.renesas.com/en-
us/doc/products/mpumcu/doc/rx_family/r01us0032ej0120_rxsm.pdf)

~~~
Taniwha
Yes it totally time for an assemply language pogrom

------
freedomben
This tickles my nostalgia from the days of TI Calculator ASM hacking

~~~
alxmdev
Indeed! I started with C by following the TIGCC TI-89 tutorials from
[http://www.technoplaza.net/](http://www.technoplaza.net/) long ago, and since
I got an Arduboy I've been itching to dive back into calc stuff and try some
small assembly gamedev. So many little projects worth doing and so little
time!

------
rangibaby
> Trick and Traps

MAP08 name inspiration? It's old enough

------
TheRealPomax
I feel cheated, there were way fewer than 68000 tricks and traps in this
article.

