Difference between revisions of "Motorola 68000"

From SizeCoding
Jump to: navigation, search
 
(35 intermediate revisions by 6 users not shown)
Line 5: Line 5:
  
 
=== The Motorola 68k processor  ===
 
=== The Motorola 68k processor  ===
The Motorola 68k processor...  
+
The Motorola 68k processor is a 16-bit Big-Endian format processor, using 32-bit register and addresses.
  
Note:  Assigment direction is source,dest instead of dest,source !!!
+
This means that instruction sizes on average are either 2 or 4 bytes each, and 6 bytes for longword / 32-bit instructions.
  
=== Registers ===
+
Note: The assigment direction is source,dest instead of dest,source !!!
To be added.
 
  
== Atari ST ==
+
==== Registers ====
The Atari ST systems consists of the M68k system with custom hardware for graphics and sound.
 
  
=== Setting up ===
+
* D0..D7 - 8 x 32 bit General Purpose Registers
Setting up your development platform for the Atari ST systems is quite easy, first get the following tools:
 
  
* Assembler: VASM - This assembler is able to assemble directly to a TOS image
+
* A0..A6 - 7 x 32 bit Address Registers
* Emulator(s): -. Make sure to use the original TOS 1.62 Image for best compatibility.
 
  
=== Compiling to a TOS image ===
+
* A7 - 32-bit Stack-Address Register
Vasm -Ftos source.s -o source.tos
 
  
=== Video diplay ===
+
==== Instructions timing ====
Video display on the Atari 8bit systems use the TIA chip, it has the following video modes:
+
The number of cycles for each instruction is different depending of processor model in M68K family.
 +
: http://oldwww.nvg.ntnu.no/amiga/MC680x0_Sections/mc68000timing.HTML
  
To be added soon.
+
== Size considerations ==
 +
Here are some general rule of thumbs when it comes to size consideration when programming the M68000
  
 +
* Moving/Calculating Register from/to registers - 2 bytes
 +
* Moving/Calculating with byte or word values - 4 bytes
 +
* Moving/Calculating with long values - 6 bytes
  
=== Setting a palette ===
+
Shorter variants:
Here is some code that will help you setup a palette
+
* moveq #value, reg : 2 bytes - Moves a values -128...127 to a register
 +
* addq #value, reg : 2 bytes - Adds a values 0..8 to a register
 +
* subq #value, reg : 2 bytes - Subtracts a values 0..8 from a register
  
<syntaxhighlight lang="">
 
pea palette(pc)
 
move.w #6,-(sp)
 
trap #14
 
  
; Palette data
+
== Generic 68K sinus table generator ==
palette:
+
Here is a fairly generic 68k sinus table generator (16 bytes on Atari ST) as well as a 10-byte zigzag generator.
dc.w $000,$100,$200,$311,$422,$533,$644,$755
+
* [https://demozoo.org/productions/310191/ Singen68k]
dc.w $575,$464,$353,$242,$131,$020,$010,$000
 
</syntaxhighlight>
 
  
=== Getting something on screen ===
+
== Resources ==
Here is a bit of code to get you started:
+
* [http://www.beycan.net/eklenen/M68000_Instruction_Set.pdf M68000 Instruction Set]
 +
* [http://www.easy68k.com/ EASy68K Editor/Assembler/Simulator for the 68000]
 +
* [http://www.easy68k.com/paulrsm/index.html Various Motorola 68k resources]
  
;-----------------------
+
== Motorola M68K Platforms ==
; Line-A Initialization
+
*'''[[Atari ST]]''' - Atari ST Sizecoding information
;-----------------------
+
*'''[[Atari Jaguar]]''' - Atari Jaguar Sizecoding information
; After calling this function, data register D0 and address register A0 point to a table ; with the starting address of the Line A variables.
+
*'''[[Commodore Amiga]]''' - Commodore Amiga Sizecoding information
; Address register A1 points to a table with the starting addresses for the three system ; font headers,
+
*'''[[Spectrum QL]]''' - Spectrum QL information
; and address register A2 points to a table that specifies the starting addresses of the; 15 Line A opcodes. There's no parameter required for this function, so all you have
 
; to do is call the word opcode label that you specified for the $A000 (Initialize)
 
; function.
 
dc.w $A000
 
movem.l (a0),a1-a4 ; A3=INTIN, A4=PTSIN
 
 
 
;---------
 
; For X&Y
 
;---------
 
frameloop:
 
move.w #200-1,d7 ; y
 
yLoop:
 
move.w #320-1,d6 ; x
 
xLoop:
 
 
 
; Putpixel
 
put_pixel:
 
move.b d6,d0 ; d0=x
 
eor d7,d0 ; d0=x^y
 
lsr.b #2,d0 ; d0>>=4
 
and #42,d0 ; d0&42
 
 
move.w d0,(a3) ; a3=color(d0)
 
movem.w d6/d7,(a4) ; a4=x,y`
 
 
dc.w $A001 ; put pixel command
 
 
 
dbra d6,xLoop ; decrease and branch
 
    dbra d7,yLoop
 
 
 
; Wait loop
 
bra frameloop ; .s *
 
 
 
 
 
=== Sound ===
 
The Atari ST systems use the YM8192 chip to generate sound.
 
To be added soon.
 
 
 
=== Make some noise ===
 
To be added soon.
 

Latest revision as of 12:51, 8 April 2024

Introduction

Wanting to start sizecoding on a Motorola 68k platform in this day and age can be tough.

So here is a bit of help to get you started:

The Motorola 68k processor

The Motorola 68k processor is a 16-bit Big-Endian format processor, using 32-bit register and addresses.

This means that instruction sizes on average are either 2 or 4 bytes each, and 6 bytes for longword / 32-bit instructions.

Note: The assigment direction is source,dest instead of dest,source !!!

Registers

  • D0..D7 - 8 x 32 bit General Purpose Registers
  • A0..A6 - 7 x 32 bit Address Registers
  • A7 - 32-bit Stack-Address Register

Instructions timing

The number of cycles for each instruction is different depending of processor model in M68K family.

http://oldwww.nvg.ntnu.no/amiga/MC680x0_Sections/mc68000timing.HTML

Size considerations

Here are some general rule of thumbs when it comes to size consideration when programming the M68000

  • Moving/Calculating Register from/to registers - 2 bytes
  • Moving/Calculating with byte or word values - 4 bytes
  • Moving/Calculating with long values - 6 bytes

Shorter variants:

  • moveq #value, reg : 2 bytes - Moves a values -128...127 to a register
  • addq #value, reg : 2 bytes - Adds a values 0..8 to a register
  • subq #value, reg : 2 bytes - Subtracts a values 0..8 from a register


Generic 68K sinus table generator

Here is a fairly generic 68k sinus table generator (16 bytes on Atari ST) as well as a 10-byte zigzag generator.

Resources

Motorola M68K Platforms