Pl INSTRUC.DOC: Difference between revisions

From Atari Wiki
Jump to navigation Jump to search
mNo edit summary
mNo edit summary
Line 502: Line 502:
   
 
a0 is incremented by 2 units.
 
a0 is incremented by 2 units.
  +
  +
  +
SUB dn,destination :(.B),[.W],(.L)
  +
------------------------
  +
or
  +
  +
SUB source,dn :(.B),[.W],(.L)
  +
------------------------
  +
  +
Subtracts the source operand FROM the destination operand (the source
  +
operand is therefore unchanged and the result is found in the destination
  +
operand! )
  +
  +
All three operation sizes are accepted.
  +
  +
The allowed addressing modes for the source operand if SUB
  +
is written: SUB.x source,dn are: ------
  +
----------------
  +
dn
  +
an
  +
BBBB
  +
BB
  +
#BBB
  +
(an)
  +
(an)+
  +
-(an)
  +
d(an)
  +
d(an,rn)
  +
d(pc)
  +
d(pc,rn)
  +
  +
If the source operand is an address register, the .B size is
  +
not allowed; if the size is .W, there is sign EXTension of an.
  +
  +
  +
The allowed addressing modes for the destination operand if SUB
  +
is written SUB.x dn,destination are: -----------
  +
---------------------
  +
  +
dn
  +
BBBB
  +
BB
  +
(an)
  +
(an)+
  +
-(an)
  +
d(an)
  +
d(an,rn)
  +
  +
  +
All Bits of the CCR may react to the SUB operation depending on
  +
the result obtained.
  +
  +
Example of use:
  +
----------------------
  +
SUB.B d0,d1
  +
  +
The least significant byte of the data register d0 is subtracted from
  +
the least significant byte of d1, the result is in d1:
  +
d0=d0, d1=d1-d0
  +
  +
  +
SUBI #BBB,destination :(.B),[.W],(.L)
  +
-------------------------
  +
  +
SUBI reads: 'SUBtract Immediate'
  +
  +
All three operation sizes are allowed.
  +
  +
The immediate data source is subtracted from the destination operand.
  +
------
  +
The addressing modes allowed for the destination operand are:
  +
-----------
  +
  +
dn
  +
BBBB
  +
BB
  +
(an)
  +
(an)+
  +
-(an)
  +
d(an)
  +
d(an,rn)
  +
  +
All 5 codes of the CCR are affected by SUBI
  +
---
  +
Example of use:
  +
----------------------
  +
SUBI.W #12,(a0)
  +
  +
The word 12 is subtracted from the word pointed to by the address register a0.
  +
  +
  +
SUBQ #BBB,destination :(.B),[.L],(.L)
  +
-------------------------
  +
  +
The unsigned immediate data #BBB is subtracted FROM the destination
  +
operand.
  +
  +
It is mandatory that 1<= #BBB <=8
  +
  +
The destination operand allows the addressing modes:
  +
-----------
  +
dn
  +
an
  +
BBBB
  +
BB
  +
(an)
  +
(an)+
  +
-(an)
  +
d(an)
  +
d(an,rn)
  +
  +
If the destination operand is an address register an, the .B size
  +
is forbidden; if the .W size is used, there will be sign EXTension
  +
of an to an L-M.
  +
  +
All 5 Bits of the CCR are modified by SUBQ depending on the result.
  +
---
  +
  +
Example of use:
  +
----------------------
  +
SUBQ.W #3,d0
  +
  +
Subtracts the word 3 from the least significant word of d0.
  +
  +
Note: SUBQ is faster than SUBI, which explains the name
  +
of the instruction: SUBtract Quick
  +
Be aware that 1<= #BBB <=8
  +
  +
  +
SUBA source,an :(.W),(.L)
  +
--------------------
  +
  +
This instruction reads: 'SUBtract Address'
  +
  +
It complements SUB as here the destination operand is an address
  +
register. ----------- --------
  +
---------
  +
Only .W and .L sizes are allowed.
  +
  +
SUBA subtracts the source operand from the address register an.
  +
  +
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 CCR is not modified by SUBA
  +
---
  +
  +
Example of use:
  +
----------------------
  +
SUBA.L #2,a0
  +
  +
a0 is decremented by 2 units (similar to .W, -(a0) ).

Revision as of 11:56, 17 December 2023

                         -------------------------
                           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. EXT dn  : [.W],(.L)
Allows for sign EXTension of the destination operand. The .B size is not allowed. In the case of EXT.W dn: The MSB (bit no. 7) of the data register is extended up to bit no. 15 In the case of EXT.L dn: The MSB (bit no. 15) of the data register is extended up to bit no. 31 This allows for extending the content of the data register into a WORD or into an L-M while preserving the sign of the register. The destination operand can only be a data register.
The N and Z Bits of the CCR are set according to the result of the operation. --- Example of use:
MOVE.W #%0001011001010010,d5 EXT.L d5 The MSB (here 0) will be copied from bit no. 16 to bit no. 31, so d5 will contain an L-M: %00000000000000000001011001010010, not just a WORD. EXG rn,rm
EXG allows for swapping the contents of two dn or an registers. The .L size is the default The source operand is a data or address register
The destination operand is a data or address register
The CCR is not affected by EXG --- Example of use:
MOVE.L #$FF,d0 MOVE.L #$A2,d1 EXG d1,d0 D0 will contain the L-M $A2 and d1 the L-M $FF. SWAP dn
Swaps the two WORDS of the L-M contained in the data register dn The destination operand must be a data register.
The N and Z Bits of the CCR are affected according to the result obtained. --- Example of use:
MOVE.L #%11111111111111110000000000000000,d3 SWAP d3 D3 will contain the L-M: %00000000000000001111111111111111 Note that the sign of the dn register is not preserved and can be changed! ADD dn,destination  :(.B),[.W],(.L)
or ADD source,dn  :(.B),[.W],(.L)
Adds the source operand INTO the destination operand (the source operand is therefore unchanged and the result is found in the destination operand! ) All three operation sizes are accepted. The allowed addressing modes for the source operand when ADD is written: ADD.x source,dn are: ------ ---------------- dn an BBBB BB #BBB (an) (an)+ -(an) d(an) d(an,rn) d(pc) d(pc,rn) If the source operand is an address register, the .B size is not allowed; if the size is .W, there is sign EXTension of an. The allowed addressing modes for the destination operand when ADD is written ADD.x dn,destination are: ----------- --------------------- dn BBBB BB (an) (an)+ -(an) d(an) d(an,rn) All Bits of the CCR may react to the ADD operation depending on the result obtained. Example of use:
ADD.B d0,d1 The least significant byte of the data register d0 is added to the least significant byte of d1, the result is in d1: d0=d0, d1=d1+d0 ADDI #BBB,destination  :(.B),[.W],(.L)
ADDI reads: 'ADD Immediate' All three operation sizes are allowed. The immediate data source is added to the destination operand.
The addressing modes allowed for the destination operand are:
dn BBBB BB (an) (an)+ -(an) d(an) d(an,rn) All 5 codes of the CCR are affected by ADDI --- Example of use:
ADDI.W #12,(a0) The word 12 is added to the word pointed to by the address register a0. ADDQ #BBB,destination  :(.B),[.L],(.L)
The unsigned immediate data #BBB is added INTO the destination operand. It is mandatory that 1<= #BBB <=8 The destination operand allows the addressing modes: dn an BBBB BB (an) (an)+ -(an) d(an) d(an,rn) If the destination operand is an address register an, the .B size is forbidden; if the .W size is used, there will be sign EXTension of an to an L-M. All 5 Bits of the CCR are modified by ADDQ depending on the result. --- Example of use:
ADDQ.W #3,d0 Adds the word 3 to the least significant word of d0. Note: ADDQ is faster than ADDI, which explains the name of the instruction: ADD Quick Be aware that 1<= #BBB <=8 ADDA source,an  :(.W),(.L)
This instruction reads: 'ADD Address' It complements ADD as here the destination operand is an address register. ----------- --------
Only .W and .L sizes are allowed. ADDA adds the source operand to the address register an. 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 CCR is not modified by ADDA --- Example of use:
ADDA.L #2,a0 a0 is incremented by 2 units. SUB dn,destination  :(.B),[.W],(.L)
or SUB source,dn  :(.B),[.W],(.L)
Subtracts the source operand FROM the destination operand (the source operand is therefore unchanged and the result is found in the destination operand! ) All three operation sizes are accepted. The allowed addressing modes for the source operand if SUB is written: SUB.x source,dn are: ------ ---------------- dn an BBBB BB #BBB (an) (an)+ -(an) d(an) d(an,rn) d(pc) d(pc,rn) If the source operand is an address register, the .B size is not allowed; if the size is .W, there is sign EXTension of an. The allowed addressing modes for the destination operand if SUB is written SUB.x dn,destination are: ----------- --------------------- dn BBBB BB (an) (an)+ -(an) d(an) d(an,rn) All Bits of the CCR may react to the SUB operation depending on the result obtained. Example of use:
SUB.B d0,d1 The least significant byte of the data register d0 is subtracted from the least significant byte of d1, the result is in d1: d0=d0, d1=d1-d0 SUBI #BBB,destination  :(.B),[.W],(.L)
SUBI reads: 'SUBtract Immediate' All three operation sizes are allowed. The immediate data source is subtracted from the destination operand.
The addressing modes allowed for the destination operand are:
dn BBBB BB (an) (an)+ -(an) d(an) d(an,rn) All 5 codes of the CCR are affected by SUBI --- Example of use:
SUBI.W #12,(a0) The word 12 is subtracted from the word pointed to by the address register a0. SUBQ #BBB,destination  :(.B),[.L],(.L)
The unsigned immediate data #BBB is subtracted FROM the destination operand. It is mandatory that 1<= #BBB <=8 The destination operand allows the addressing modes:
dn an BBBB BB (an) (an)+ -(an) d(an) d(an,rn) If the destination operand is an address register an, the .B size is forbidden; if the .W size is used, there will be sign EXTension of an to an L-M. All 5 Bits of the CCR are modified by SUBQ depending on the result. --- Example of use:
SUBQ.W #3,d0 Subtracts the word 3 from the least significant word of d0. Note: SUBQ is faster than SUBI, which explains the name of the instruction: SUBtract Quick Be aware that 1<= #BBB <=8 SUBA source,an  :(.W),(.L)
This instruction reads: 'SUBtract Address' It complements SUB as here the destination operand is an address register. ----------- --------
Only .W and .L sizes are allowed. SUBA subtracts the source operand from the address register an. 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 CCR is not modified by SUBA --- Example of use:
SUBA.L #2,a0 a0 is decremented by 2 units (similar to .W, -(a0) ).