Category:68000 Assembly: Difference between revisions

From Rosetta Code
Content added Content deleted
Line 46: Line 46:


==Citations==
==Citations==
#[[https://www.chibiakumas.com/68000/ | ChibiAkumas Motorola 68000 Tutorial]]
#[[https://www.chibiakumas.com/68000/ ChibiAkumas Motorola 68000 Tutorial]]
#[[http://www.easy68k.com/paulrsm/doc/trick68k.htm | 68000 Tricks and Traps]]
#[[http://www.easy68k.com/paulrsm/doc/trick68k.htm 68000 Tricks and Traps]]


{{merge language | M680x0 }}
{{merge language | M680x0 }}

Revision as of 11:36, 26 August 2021

This page is a stub. It needs more information! You can help Rosetta Code by filling it in!
Language
68000 Assembly
This programming language may be used to instruct a computer to perform a task.
See Also:


Listed below are all of the tasks on Rosetta Code which have been solved using 68000 Assembly.

68000 assembly is the assembly language used for the Motorola 68000, or commonly known as the 68K. It should not be confused with the 6800 (which predates it). The Motorola 68000 is a big-endian processor with full 32-bit capabilities (despite most systems that use it being considered 16-bit.) It was used in many computers such as the Amiga or the Canon Cat, as well as game consoles such as the Sega Genesis and Neo Geo.


Architecture Overview

Data Registers

There are eight 32-bit data registers on the 68000, numbered D0-D7. As the name implies, these are designed to hold data. Similar to the ARM processor, each one is identical in terms of which commands it can use. A command that can be used for D0 can be used for any other D-register.

<lang 68000devpac>MOVE.B #$FF,D0 ;move the hexadecimal value 0xFF into the bottom byte of D0. ADD.W #$8000,D4 ;add hexadecimal 0x8000 to the value stored in D4.</lang>

Address Registers

There are eight of these as well, numbered A0-A7. A7 is reserved as the stack pointer, and is commonly referenced as SP in assemblers. The others are free to use for any purpose. Although these registers are 32-bit, the 68000's address space is 24-bit (ranges from 0x000000 to 0xFFFFFF), so the leftmost byte is ignored. You can do simple math involving these registers but more complicated commands like multiply or divide can only be used with data registers. Address registers are used to contain addresses and extract the values stored within.

<lang 68000devpac>MOVEA.L #$200000,A2 ;usually these are loaded from a label.

The hex dump of address $200000
44 55 66 77

MOVE.L #$00000000,D0 MOVE.B (A2),D0 ;load the byte stored at $200000 into D0. D0 = #$00000044 MOVE.W (A2),D0 ;load the word stored at $200000 into D0. D0 = #$00004455 MOVE.L (A2),D0 ;load the long stored at $200000 into D0. D0 = #$44556677</lang>

Length

The 68000 can work with 8-bit, 16-bit, or 32-bit values. Some commands only work with specific lengths but most work with all three. To specify which length you are using, the command ends in a different suffix:

  • .B for byte length (8 bit)
  • .W for word length (16 bit)
  • .L for long length (32 bit)

If you don't specify a length with your command, it usually defaults to word length, but ultimately it depends on the command you are using. (Some commands cannot be used at word length.)

Bytes and words moved into a register are always stored on the right-hand side. For example: <lang 68000devpac>MOVE.L #$FFFFFFFF,D7 MOVE.B #$00,D7 ;D7 contains #$FFFFFF00 MOVE.W #$2222,D7 ;D7 contains #$FFFF2222</lang>

As you can see, the rest of the register is unchanged. (On the ARM, it would turn to zeroes.) This is very important to remember. If your code is doing something unexpected it might be due to the "old" value of the register corrupting another function.

If the given constant is smaller than the length provided, the value is padded to the left with zeroes. <lang 68000devpac>MOVE.W #$FF,D3 ;D3 = #$xxxx00FF, where x is the previous value of D3. MOVE.L #0,D3 ;D3 = #$00000000</lang>

Loading immediate values into address registers is different. You can only move words or longer into address registers, and if you move a word, the value is sign-extended. This means that if the top nibble of the word is 8 or greater, the value gets padded to the left with Fs, and is padded with zeroes if the top nibble is 7 or less. It's best to always move longs into address registers. That way you know what you're getting.

<lang 68000devpac>MOVEA.W #$8000,A4 ;A4 = #$FFFF8000. Remember the top byte is ignored so this is the same as #$00FF8000. MOVEA.W #$7FFF,A3 ;A3 = #$00007FFF</lang>

Citations

  1. [ChibiAkumas Motorola 68000 Tutorial]
  2. [68000 Tricks and Traps]


It has been suggested that this language be merged with M680x0 . See that page's talk page

Subcategories

This category has the following 2 subcategories, out of 2 total.

Pages in category "68000 Assembly"

The following 106 pages are in this category, out of 106 total.