Pl INSTRUC.DOC

From Atari Wiki
Revision as of 11:50, 17 December 2023 by Olivier.jan (talk | contribs)
Jump to navigation Jump to search
                         -------------------------
                           CHAPTER  FOUR

                         THE 68000 INSTRUCTIONS

                         -------------------------



                     *** THE 68000 INSTRUCTIONS ***
                     ---------------------------------

- Here is a chapter that is entirely dedicated to the different
  68000 assembler instructions.

- Now that you know how to access data in memory thanks to addressing
  modes, we will look at the instructions that allow to modify, move...
  in other words to manipulate the data.

- For each instruction, I will give you:

  .The syntax for the instruction and its operands.
  .Its effects, its purpose.
  .The addressing modes allowed for the operands.
  .The effect of the instruction on the registers and notably on
   the CCR.
  .And of course some examples of use...

- New concepts will appear in the explanations concerning
  instructions, they will be detailed, explained and commented.



                           --------------------

                    *** THE 68000 INSTRUCTIONS ***
                    ---------------------------------


MOVE       source,destination   :(.B),[.W],(.L)

All three operation sizes are allowed for this instruction, with [.W] being the default size. The 'source' operand is copied (and remains unchanged) to (in) the 'destination' operand. The allowed addressing modes for the source operand are:
dn (data registers) an (address registers) BBBB BB #BBB (an) (an)+ -(an) d(an) d(an,rn) d(pc) d(pc,rn) The allowed addressing modes for the destination operand are:
dn an BBBB BB (an) (an)+ -(an) d(an) d(an,rn) Only the N and Z Bits of the CCR are affected. Example of use:
Move.l #1456701,d0 The L-M equal to 1256701 is placed in the data register d0. MOVEQ #D,dn
The source operand is an immediate, signed data contained in an octet (-128<= D <128). The destination operand is a data register. The source data, signed and contained in an octet, is copied into a data register with SIGN EXTENSION of the register: Meaning that the data is placed in the least significant byte of the Dn register and the MSB is extended (copied) up to the 31st bit of the register, so that the data register is fully affected by the 'data loading' and the sign of the data is preserved. The source operand therefore allows the addressing mode:
#BBB ( -128<= BBB <128 ) The destination operand is a data register.
Only the N and Z Bits of the CCR are affected by this instruction. --- Example:
MOVEQ #%01100101,d0 The octet 01100101 is placed in d0: d0= : 00000000000000000000000001100101 Bit nr 31 . . . MSB (0) <---------------MSB (0) There has been sign extension of d0 (here MSB=0 because 01100101>0) NB: Moveq is distinguished from Move by greater speed, but -- remember the conditions of use of Moveq! MOVEA source,an  :(.W),(.L)
The Movea instruction complements the Move instruction as it accepts an Address Register for the destination operand. On most assemblers, the syntax MOVE source,an is accepted and automatically translated to MOVEA source,an. If the source operand uses the .W operation size, there is sign extension of the address register an. The .B size is not allowed for MOVEA. The allowed addressing modes for the source operand are:
dn an BBBB BB #BBB (an) (an)+ -(an) d(an) d(an,rn) d(pc) d(pc,rn) The destination operand is an address register
The MOVEA instruction does not affect the CCR. --- Example of use:
MOVEA.L #etiq,a5 The address register a5 is loaded with the address pointed to by the label 'etiq'. LEA source,an  : [.L]
This instruction reads: 'Load Effective Address' Only the .L operation size is possible, and is the default. It allows for placing the address pointed to by the source operand into an address register. The source operand allows the addressing modes:
BBBB BB (an) d(an) d(an,rn) d(pc) d(pc,rn) The destination operand is an address register
------------------ The LEA instruction does not influence the CCR. --- Example of use:
LEA etiq,a2 The address pointed to by the label 'etiq' is placed in the address register a2. In fact, this can also be done with MOVE.L #etiq,a2, but it is less fast. CLR destination  :(.B),[.W],(.L)
This instruction reads: 'CLeaR destination' And allows for setting all bits of the destination operand to 0. All three operation sizes are possible. The allowed addressing modes for the destination operand are:
dn BBBB BB (an) (an)+ -(an) d(an) d(an,rn) The Z bit of the CCR is set to 1, the N, V, C bits to 0. --- Example of use:
CLR.W D0 The 16 bits of the least significant word of d0 are set to 0. NEG destination  : (.B),[.W],(.L)
Allows for performing the NEGation of the destination operand. All three operation sizes are possible. The destination operand is subtracted from 0, which has the effect of changing the sign of the operand: Bits that were active are turned off and bits that were off are activated. The destination operand allows the following addressing modes:
dn BBBB BB (an) (an)+ -(an) d(an) d(an,rn) All Bits of the CCR are affected by the NEGation depending on the result obtained. --- Example of use:
MOVE #%1010101010101010,d0 NEG.W d0 The word %0101010101010101 is obtained in d0.