home *** CD-ROM | disk | FTP | other *** search
/ Amiga MA Magazine 1998 #6 / amigamamagazinepolishissue1998.iso / coders / asmkurs / 020+asm.txt next >
Text File  |  1980-01-10  |  30KB  |  884 lines

  1. Optimizations for the 68020+
  2.  
  3. by Erik H. Bakke
  4.  
  5. Written  13/10-93
  6.  
  7.  
  8. --- I ------------------------- INTRODUCTION ---------------------- I ---
  9.  
  10.  
  11. 1.1 Introduction
  12.  
  13. The 68020+ (from here on 020) has several new registers and commands that
  14. help speeding up your code.
  15. This text also mentions some concepts new to the 68010 processor.
  16. This text contains information on how to use the new instructions, and
  17. address modes, as well as what modes are available to what instructions,
  18. and how much space they require.
  19. However, the timing diagrms for the different instructions are not
  20. included (I don't know them).
  21.  
  22. 1.2 Index
  23.  
  24.     Chapter I-----------------Introduction-------------------
  25.         1.1   Introduction
  26.         1.2   Index
  27.     Chapter II------------New Addressing Modes---------------
  28.         2.1   Extended Address Register Indirect with Index mode
  29.         2.2   Memory Indirect modes
  30.     Chapter III---------------Improvements-------------------
  31.         3.1   General Improvements
  32.         3.2   The CMP2 instruction
  33.         3.3   Improved Multiply/Divide instructions
  34.         3.4   The CHK2 instruction
  35.         3.5   The EXTB instruction
  36.     Chapter IV--------------New Instructions-----------------
  37.         4.1   The BitField instructions
  38.               1...Single operand
  39.               2...Double operand
  40.         4.2   The RTD instruction
  41.         4.3   The BCD instructions
  42.               1...PACK
  43.               2...UNPK
  44.         4.4   The MC68040 Block Move instruction (MOVE16)
  45.         4.5   The 68010 BKPT instruction
  46.         4.6   The 68020 Module instructions
  47.         4.7   The CAS/CAS2 instructions
  48.         4.8   The CoProcessor interface instructions
  49.               1...User state
  50.               2...Supervisor state
  51.         4.9   Conditional TRAP instruction
  52.     Chapter V-------------Addressing mode tables-------------
  53.         5.1   Allowed Adressing modes
  54.  
  55. --- II --------------------- NEW ADDRESSING MODES ---------------- II ---
  56.  
  57.  
  58. First, some new addressing modes:
  59.  
  60. The 020 supports 18 different addressing modes, where the 68000 only
  61. supports 12.  The 6 new modes expand memory access.
  62.  
  63. - The address register indirect with index now permit the index register
  64.   to be scaled by a factor of 1,2,4 or 8 to allow easy access to byte,
  65.   word, longword and quadword data units.  This, in turn greatly improves
  66.   access to arrays of such data.
  67.  
  68. - The address register and PC indirect with index modes have been
  69.   extended to a more general syntax, allowind 32-bit displacements.
  70.   Any of the components of these modes are optional, giving us some very
  71.   interesting addressing modes, such as DATA register indirect, called
  72.   base displacement.
  73.  
  74. - Another new concept in the 020 is the memory indirect addressing, which
  75.   allows intermediate use of a pointer in memory.  The contents of this
  76.   pointer is then used as the base address for further memory access.  We
  77.   will see examples of how this is used later.
  78.  
  79. 2.1 EXTENDED ADDRESS REGISTER INDIRECT with INDEX mode
  80.  
  81.   The 020 supports a scale factor to be used with the index register.
  82.   This eliminates the need for an additional multiply/rotation instruction
  83.   to compute the correct index value.
  84.  
  85.   Syntax: 1  (d8,An,Rm.Size*Scale)     uses old 8-bit displacement
  86.           2  (bd,An,Rm.Size*Scale)     uses 16 or 32-bit base displacement
  87.  
  88.           3  (d8,PC,Rm.Size*Scale)     uses old 8-bit displacement
  89.           4  (bd,PC,Rm.size*Scale)     uses 16 or 32-bit base displacement
  90.  
  91.  
  92.   1  <ea>=d8+An+(Rm.Size*Scale)
  93.   2  <ea>=bd+An+(Rm.Size*Scale)
  94.  
  95.   3  <ea>=d8+PC+(Rm.Size*Scale)
  96.   4  <ea>=bd+PC+(Rm.Size*Scale)
  97.  
  98.   The addressing mode works just like the old version of it, except that
  99.   you may include the scale factor to multiply the index register by
  100.   1,2,4 or 8.  The old version can be regarded as having a scale factor
  101.   of 1.
  102.  
  103. Example:
  104.  
  105.   "Table" is an array of quadwords (64-bits)
  106.   "Element" (16 bits) is the element number to be looked up. (32-bit)
  107.  
  108.        move.l (Element,pc),d0
  109.        move.l (Table,pc,d0.w*8),d0
  110.  
  111.   This code fetches the 32-bit element as indicated by "Element" from the
  112.   table "Table".
  113.  
  114.  
  115.   Many forms of this addressing mode is legal, as the different elements
  116.   are optional.  Allowed forms may be:
  117.  
  118.        (bd,An,Rm.Size)     Corresponds to the old version
  119.        (bd,Rm.Size*Scale)  Omits the address register from the <ea>
  120.        (bd)                Equivalent to absolute addressing
  121.        (Dm.l)              Data register indirect addressing
  122.        ()                  Just an <ea> of 0
  123.  
  124.   If you choose to omit the PC, you may have to use the notation ZPC
  125.   and/or note the base displacement with .L, depending on your assembler.
  126.  
  127.  
  128. 2.2 MEMORY INDIRECT modes
  129.  
  130.   These modes enables the processor to step on a pointer in memory when
  131.   computing an <ea>.  These modes can be divided in two categories,
  132.   Pre-indexed and Post-indexed.
  133.  
  134.   Syntax: 1  ([bd,An,Rm.Size*Scale],od)        Pre-indexed form
  135.           2  ([bd,An],Rm.Size*Scale,od)        Post-indexed form
  136.  
  137.           3  ([bd,PC,Rm.Size*Scale],od)        Pre-indexed form
  138.           4  ([bd,PC],Rm.Size*Scale,od)        Post-indexed form
  139.  
  140.   1  <ea>=Contents of(bd+An+Rm*Scale) + od
  141.   2  <ea>=Contents of(bd+An) + Rm*Scale+od
  142.  
  143.   3  <ea>=Contents of(bd+PC+Rm*Scale) + od
  144.   4  <ea>=Contents of(bd+An) + Rm*Scale+od
  145.  
  146.   The same rules apllies to these addressing modes as do for the
  147.   previously described modes.
  148.   All elements are optional and may be omitted.
  149.  
  150.   Example:
  151.  
  152.   On Amiga computers, graphics rendering functions need a pointer to a
  153.   rastport.
  154.   To extract this RastPort pointer from a Window sctructure the
  155.   following code would be used:
  156.  
  157.          move.l ([WindowBase,pc],wd_RPort),a2
  158.  
  159.  
  160.  
  161.  
  162.  
  163.  
  164. When getting to grips with these addressing modes, they can greatly improve
  165. the performance of your program, as well as reducing the length of the
  166. code.
  167.  
  168.  
  169.  
  170.  
  171. --- III ---------------------- IMPROVEMENTS --------------------- III ---
  172.  
  173.  
  174. 3.1 General improvements:
  175.  
  176.   The 020 improves the branch instructions to use an 8, 16 or 32-bit
  177.   displacement.
  178.  
  179. 3.2 The CMP2 instruction
  180.  
  181.   The CMP instructions are extended to compare a register against a pair of
  182.   bounds:
  183.            CMP2.Size  <ea>,Rn
  184.  
  185.   The <ea> is a pointer to the bounds.  The bounds are the same size as the
  186.   operation.  The lower bound is stored first, then the upper bound.
  187.   If Rn is outside the bounds, the C flag is set, If Rn is equal to either
  188.   of the bounds, the Z flag is set, and both are cleared if Rn is within
  189.   the bounds.
  190.   -This operation may be used on both unsigned and signed data.
  191.   -If Rn is an address register, byte/word data is sign extended before
  192.    comparison
  193.  
  194.  
  195. 3.3 Improved Multiply/Divide instructions
  196.  
  197.   The 020 greatly improves the multiplication/division instructions.
  198.   Now, you have these possibilities:
  199.  
  200. 3.3.1 MULU/MULS instructions
  201.  
  202.             Instruction         Precision
  203.   Syntax:
  204.          1  MULU.W <ea>,Dn      16b*16b=>32b    (68000 instruction)
  205.          2  MULU.L <ea>,Dl      32b*32b=>32b
  206.          3  MULU.L <ea>,Dh:Dl   32b*32b=>64b
  207.  
  208.          The syntax and precision of the MULS instruction are identical
  209.          to those of the MULU instructions.
  210.  
  211. 3.3.1.1 MULU.W <ea>,Dn
  212.  
  213.   This instruction multiplies the 16-bit value indicated by <ea> with
  214.   the 16-bit contents of Dn, and stores the result as a 32-bit value
  215.   in Dn.  This is the basic MULU instruction that is found on the
  216.   68000 processor.
  217.  
  218. 3.3.1.2 MULU.L <ea>,Dl
  219.  
  220.   This instruction multiplies the 32-bit value indicated by <ea> with
  221.   the 32-bit contents of Dl.  This produces a 64-bit result of which
  222.   the low 32 bits are discarded.  The high 32 bits are then stored in
  223.   Dl.
  224.  
  225. 3.3.2.3 MULU.L <ea>,Dh:Dl
  226.  
  227.   This instruction multiplies the 32-bit value indicated by <ea> with
  228.   the 32-bit contents of Dl.  This produces a 64-bit result.  The high
  229.   32 bits are stored in Dh, and the low 32 bits are stored in Dl.
  230.  
  231. 3.3.2 DIVU/DIVS
  232.  
  233.             Instruction         Precision
  234.   Syntax:
  235.          1  DIVU.W  <ea>,Dn     32b/16b=>16r:16q   (68000 instruction)
  236.          2  DIVU.L  <ea>,Dq     32b/32b=>32q
  237.          3  DIVU.L  <ea>,Dr:Dq  64b/32b=>32r:32q
  238.          4  DIVUL.L <ea>,Dr:Dq  32b/32b=>32r:32q
  239.          
  240.          The syntax and precision of the DIVS instruction are identical
  241.          to those of the DIVU instructions
  242.          
  243. 3.3.2.1 DIVU.W <ea>,Dn
  244.  
  245.   This instruction divides the 32-bit contents of Dn with the 16-bit
  246.   value indicated by <ea>, and stores the quotient is stored in the
  247.   lowest word of Dn, and the remainder is stored in the highest.
  248.   This is the basic DIVU instruction that is found on the 68000
  249.   processor
  250.   
  251. 3.3.2.2 DIVU.L <ea>,Dq
  252.  
  253.   This instruction divides the 32-bit contents of Dq with the 32-bit
  254.   value indicated by <ea>, and stores the quotient in Dq.  The remainder
  255.   is discarded.
  256.  
  257. 3.3.2.3 DIVU.L <ea>,Dr:Dq
  258.  
  259.   This instruction divides the 64-bit contents of Dr(MSLW):Dq(LSLW)
  260.   with the 32-bit value indicated by <ea> and stores the quotien in
  261.   Dq, and the remainder in Dr.
  262.  
  263. 3.3.2.4 DIVUL.L <ea>,Dr:Dq
  264.  
  265.   This instruction divides the 32-bit contents of Dq with the 32-bit
  266.   value indicated by <ea>, and stores the quotient in Dq, and the remainder
  267.   in Dr.
  268.  
  269. 3.4 The CHK2 instruction
  270.  
  271.   The 020 extends the CHK instruction to check a value against a pair
  272.   of bounds.  See the description of CMP2 for information about these
  273.   bounds.  If the value is outside the specified bounds, a CHK
  274.   exception is taken.
  275.  
  276. 3.5 The EXTB instruction
  277.  
  278.   The 020 allows the direct sign extension from a byte to a longword.
  279.   
  280.   Syntax:
  281.          EXTB.L Dn    Extend byte to long
  282.   
  283.   Example:
  284.   
  285.   The following code:
  286.   
  287.       ext.w    d0
  288.       ext.l    d0
  289.   
  290.   can be replaced with:
  291.   
  292.       extb.l   d0
  293.       
  294.  
  295.  
  296. --- IV ---------------------- NEW INSTRUCTIONS ------------------- IV ---
  297.  
  298.  
  299.  
  300. 4.1 Bit Field Instructions:
  301.  
  302.   The 020 is not confined to addressing data at byte, word or longword
  303.   boundaries, the new bit-field instructions allows access to data at
  304.   any arbitrarily bit position in a data register or memory.  The length
  305.   of the data may be from 1 up to 32 bits.  These instructions have a
  306.   different bit numbering than the ordinary instructions.  The bits are
  307.   numbered from the leftmost digit towards the right.
  308.   To indicate a bit-field, the following syntax is used:  {offset:width}
  309.   The "offset" is the number of bits to skip
  310.   The "width" is the number of bits included in the bit-field
  311.  
  312.   The following bit-field is described as {13:12}
  313.  
  314.   31      23      15      7      0    Ordinary bit numbering
  315.   |       |       |       |      |
  316.   -------------XXXXXXXXXXXX-------    Bit field
  317.   |       |       |       |      |
  318.   0       8       16      24     31   Bit field numbering
  319.  
  320.   A bit field may also stretch across boundaries in memory, f. eks.:
  321.  
  322.   31      23      15      7      031      23      15
  323.   |       |       |       |      ||       |       |
  324.   --------------------------XXXXXXXXXXXXXXXXX--------
  325.   |       |       |       |       |       |       |
  326.   0       8       16      24      32      40      48
  327.  
  328.   This bit-field would have been described as {26:17}
  329.   In addition, the offset may be negative when used in memory.
  330.  
  331.   The control of bit-field is supported by 8 instructions, 4 single-
  332.   operand instructions (BFTST,BFCLR,BFSET, and BFCHG), and 4 double-
  333.   operand instructions. (BFFFO,BFEXTU,BFEXTS, and BFINS)
  334.  
  335.  
  336. 4.1.1 Single operand Bit-field instructions
  337.  
  338.   These instructions can be viewed as extensions of the corresponding
  339.   bit instructions (BTST,BCLR,BSET, and BCHG)
  340.  
  341.   Syntax:
  342.          1  BFTST <ea>{offset:width}   Test bit-field
  343.          2  BFCLR <ea>{offset:width}   Test bit-field and clear it
  344.          3  BFSET <ea>{offset:width}   Test bit-field and set it
  345.          4  BFCHG <ea>{offset:width}   Test bit-field and invert it
  346.  
  347.   Each of these instructions first tests the bit-field and sets the
  348.   condition codes accordingly, then perform the action on the data
  349.   (SET,CLR or CHG).
  350.   Condition codes:
  351.          
  352.          N  Set if the most significant digit was 1
  353.          Z  Set if all bits are 0
  354.          C  Cleared
  355.          V  Cleared
  356.          X  Not affected
  357.  
  358.   Only data register direct and control addressing modes are allowed
  359.   for the operand.
  360.   The offset may be either a value from 0-31 or contained as a 32-bit
  361.   signed value in a data register.
  362.   The width may be either a value from 1-32 or contained in the lower
  363.   5 bits of a data register.
  364.  
  365. 4.1.2 Double operand Bit-field instructions
  366.  
  367.   These instruction provides more control over bit-fields, such as
  368.   inserting, extracting and searching
  369.  
  370.   Syntax:
  371.          1  BFEXTU <ea>{offset:width},Dn  Extract a bit-field
  372.          2  BFEXTS <ea>{offset:width},Dn  Extract and sign extend
  373.          3  BFINS  Dn,<ea>{offset:width}  Inserts a bitfield
  374.          4  BFFFO  <ea>{offset:width},Dn  Find First 1 in a BF.
  375.  
  376.   Condition codes:
  377.  
  378.          N  Set if the most significant bit in the BF is set
  379.          Z  Set if all bits in the BF are 0
  380.          C  Cleared
  381.          V  Cleared
  382.          X  Not affected
  383.  
  384.   The offset may be either a value of 0-31 or contained as a 32-bit
  385.   signed value in a data register.
  386.   The width may be either a value of 1-32 or contained in the lower
  387.   5 bits of a data register.
  388.  
  389. 4.1.2.1 BFEXTU instruction
  390.  
  391.   This instruction extracts a bit-field from the source operand,
  392.   right-justifies it, and places it in the destination register.
  393.  
  394. 4.1.2.2 BFEXTS instruction
  395.  
  396.   This instruction works just like the BFEXTU (4.1.2.1) instruction,
  397.   but sign extends the bit-field to 32-bits before storing it in
  398.   the destination register.
  399.  
  400. 4.1.2.3 BFINS instruction
  401.  
  402.   This instruction extracts the <width> lower bits of the source
  403.   register, and inserts it into the destination bit-field.
  404.  
  405. 4.1.2.4 BFFFO instruction
  406.  
  407.   The bit offset of the most significant 1 in the bit-field is
  408.   stored in the data register.  If no 1 is found in the bit-field,
  409.   the sum of the offset and width is stored in the destination.
  410.  
  411.  
  412.  
  413. The Bit-field instructions can be used for handling floating point
  414. numbers in software.
  415.  
  416.  
  417.  
  418. 4.2 The RTD instruction (68010 and up)
  419.  
  420.   This instruction extends the operation of the RTS instruction.
  421.   It pops the PC off the stack, then a 16-bit displacement is added
  422.   to the SP.  This makes it possible to clear parameters pushed on
  423.   to the stack by a calling program.
  424.  
  425.   Syntax:
  426.            RTD  #displacement
  427.  
  428.   Example:
  429.  
  430.      A subroutine is called with parameters on the stack.
  431.      The size of these parameters equals <ParamSize>
  432.      The subroutine allocates some stack space for local data.
  433.      The size of this local data equals <LocalSize>
  434.  
  435.   SubRoutine:
  436.  
  437.          link     a5,#-LocalSize    ;Allocate local data space
  438.          movem.l  d0-a6,-(sp)       ;Save registers
  439.          .
  440.          .                          ;Do whatever...
  441.          .
  442.          movem.l  (sp)+,d0-a6       ;Restore registers
  443.          unlk     a5                ;Deallocate local data space
  444.          rtd      #ParamSize        ;Deallocate parameter space
  445.                                     ; and return to caller
  446.  
  447.  
  448.   Without this instruction, the stack cleanup would look like this:
  449.  
  450.          movem.l  (sp)+,d0-a6
  451.          unlk     a5
  452.          move.l   (sp),(ParamSize,sp)
  453.          lea      (ParamSize,sp),sp
  454.          rts
  455.  
  456.  
  457. 4.3 The BCD instructions
  458.  
  459.   The 68000 has some instructions for the manipulating of BCD coded data
  460.   (ABCD,NBCD,SBCD).  The 020 extends this command set to include
  461.   instructions for packing/unpacking of such data, the PACK and UNPK
  462.   instructions.
  463.  
  464. 4.3.1 The PACK instruction
  465.  
  466.   This instruction packs data to a format usable by the other BCD
  467.   instructions.  When used in memory, the instruction fetches 2 bytes of
  468.   data, adds a displacement, and concatenates bits 11-8 and 3-0 into
  469.   a single byte.  When used on a data register, the displacement and the
  470.   contents of the data register is added, then bits 11-8 and 3-0 are
  471.   contatenated to form a byte.
  472.   
  473.   This instruction is useful for encoding a decimal number stored as a
  474.   string of ascii characters into a usable BCD code.
  475.  
  476.   Syntax:
  477.          1  PACK -(An),-(Am),#displacement
  478.          2  PACK Dn,Dm,#displacement
  479.          
  480.          
  481.   Example:
  482.  
  483.   We want to encode the ascii string "76" ($3736) to BCD.
  484.   Recall that the numeric characters have ascii codes $30-$39.
  485.   "Data" is a pointer to the string we wish to convert.
  486.   
  487.       move.l (Data,pc),a0
  488.       move.w (a0),d0
  489.       pack   d0,d1,#$0000
  490.   
  491.   Register d1 now contains the hex value $76.
  492.   If we'd wished to, we could have added the BCD 12 to the number in the
  493.   same instruction, like this:
  494.   
  495.       pack   d0,d1,#$0102
  496.   
  497.   Register d1 now contains the hex value $88
  498.  
  499.  
  500. 4.3.2 The UNPK instruction
  501.  
  502.   This instruction unpacks a BCD coded number to a less compact version.
  503.   When used in memory, this instruction copies the 2 nibbles of the source
  504.   byte to the low nibble of two separate bytes, the two bytes are
  505.   concatenated into a word, and a displacement is added to the word.
  506.   When used on a data register, the nibbles are copied from the LSB or the
  507.   source register, and the unpacked word is placed in the LSW of the
  508.   destination register.
  509.  
  510.   Syntax:
  511.          1  UNPK -(An),-(An),#displacement
  512.          2  UNPK Dn,Dm,#displacement  
  513.   
  514.   Example:
  515.   
  516.   We want to unpack the BCD number $76 to a printable ascii string.
  517.   The numberical characters start at ascii $30, so we must add this
  518.   value to both bytes.  The displacement is then $3030.
  519.   "Data" is a pointer to the string we wish to fill.
  520.   Register d0 is preloaded with $76
  521.   
  522.       move.l (Data,pc),a0
  523.       unpk   d0,d1,#$3030
  524.       move.w d0,(a0)
  525.  
  526. 4.4 The MC68040 Block move instruction (MOVE16)
  527.  
  528.   This instruction uses the burst mode for rapid movement of a
  529.   block of data.  The instruction can be used for fast block copy,
  530.   memory initialization and co-processor communication.
  531.   
  532.   This instruction aligns all addresses to 16-byte boundaries by masking
  533.   off the lower 4 bits of the addresses.  A line of 16 bytes is copied
  534.   from the source to the destination address.
  535.   
  536.   Syntax:
  537.          1  MOVE16  (Ax)+,(Ay)+
  538.          2  MOVE16  xxx.L,(An)
  539.          3  MOVE16  xxx.L,(An)+
  540.          4  MOVE16  (An),xxx.L
  541.          5  MOVE16  (An)+,xxx.L
  542.   
  543.   For the Amiga computers, some precautions must be taken when using this
  544.   instruction in Chip Memory.  Fast Memory works fine, though.
  545.   
  546.   Example:
  547.   
  548.   We want to copy an area of 128 bytes from "A" to "B"
  549.   
  550.       lea     (A,pc),a0
  551.       lea     (B,pc),a1
  552.       moveq   #7,d0
  553.   Loop:
  554.       move16  (a0)+,(a1)+
  555.       dbf     d0,Loop
  556.   
  557.  
  558. 4.5 The 68010 BKPT instruction
  559.  
  560.   This instruction is used for hardware testing, and executes differently
  561.   on the various members of the 68000 family, and is not described here.
  562.  
  563. 4.6 The 68020 Module instructions
  564.  
  565.   These instructions, (CALLM and RTM) appear only on the 68020 processor,
  566.   and the use of them is beyond the scope of this text.
  567.  
  568. 4.7 The CAS/CAS2 instructions
  569.  
  570.   These instructrions are provided for maintaining and protecting critical
  571.   data in a multiprocessor environment.  Multiprocessing is beyond the
  572.   scope of this text, but I'll explain these instructions anyway
  573.   
  574.   Suppose two different processes write to the same memory, and have access
  575.   to a shared variable.  This variable may be anything, such as a pointer
  576.   to a list.  Process 1 retrieves this variable in d7, and copies it to d0
  577.   as a backup pointer.  It then operates upon the pointer in d7.
  578.   Before Process 1 is finished with the operation, it is put to sleep, and
  579.   another process is made ready to run.  This process alters the contents
  580.   of our variable.  Later, our process is allowed to run again.
  581.   Before it can update the variable, it must test if someone else has
  582.   altered the variable in memory.  This is done by comparing the backup
  583.   pointer in d0 with the data in memory.
  584.   -If the values are equal, the variable has not been altered by anybody,
  585.    and the new value can safely be written to the variable.
  586.   -However, if the values are not equal, the process should reload the new
  587.    value of the variable, and rerun it's operation.
  588.   
  589.   The other process should protect itself in the same way as our process
  590.   did.
  591.   As a final point, the comparison and rewriting must be protected, so
  592.   that the other process doesn't alter the variable between the comparison
  593.   and rewriting.  This is done by using an indivisible RMW cycle (RMW=
  594.   Read-Modify-Write)
  595.   
  596. 4.7.1 The CAS instruction
  597.  
  598.   The instruction CAS implements this comparison between global data and
  599.   a register, as well as a data transfer using this RMW cycle.
  600.   
  601.   Syntax:
  602.          CAS.Size  Dc,Du,<ea>
  603.         
  604.   The <ea> is compared to the contents of register Dc.  If they are equal,
  605.   the contents of Du is written to <ea>.  If they are not equal, the
  606.   contents of <ea> is copied to Dc.  The Z bit reflects the result of the
  607.   comparison.
  608.   
  609. 4.7.2 The CAS2 instruction
  610.  
  611.   The CAS2 instruction works like the CAS instruction except that it
  612.   performs comparisons and updates on two data values.
  613.   
  614.   Syntax:
  615.          CAS2.Size  Dc1:Dc2,Du1:Du2,(Rn1):(Rn2)
  616.   
  617.   Rn may be any data or address register.
  618.   Only if the contents of Dc1 equals (Rn1) and the contents of Dc2
  619.   equals (Rn2) will the contents of Du1 be written to (Rn1) and
  620.   Du2 be written to (Rn2).  This instruction is well suited to
  621.   protect multi-linked lists in a multi-processor environment.
  622.  
  623.  
  624.   WARNING:
  625.   Like the TAS instruction, the CAS/CAS2 instructions should NOT be
  626.   used on an Amiga, as they are not supported by the hardware.
  627.   The indivisable RMW cycle conflicts with the Amiga's bus system.
  628.  
  629.  
  630. 4.8 The CoProcessor interface instructions.
  631.  
  632.   These instructions are outside the scope of this text, see the
  633.   "MC68020 CoProcessor support instructions" text by this author
  634.   for information about how to program using these instructions.
  635.   However, here is a list of the instructions:
  636.   
  637. 4.8.1 User state coprocessor instructions
  638.  
  639.      cpBcc     Branch on Coprocessor Condition
  640.      cpDBcc    Test coprocessor Condition, Decrement and Branch
  641.      cpGEN     Coprocessor general function
  642.      cpScc     Set on Coprocessor Condition
  643.      cpTRAPcc  Trap on Coprocessor Condition
  644.  
  645. 4.8.2 Supervisor state coprocessor instructions
  646.  
  647.      cpRESTORE Coprocessor Restore Functions
  648.      cpSAVE    Coprocessor save Function
  649.  
  650. 4.9 Conditional TRAP instruction
  651.  
  652.   The 020 allows conditional traps.  If the specified condition is true,
  653.   a TRAPcc exception (exception 7) will be taken.
  654.   
  655.   Syntax:
  656.          TRAPcc  #Data
  657.   
  658.   The <cc> may be any of the <cc>'s that are supported by the ordinary
  659.   conditional branch instructions.
  660.  
  661.  
  662.  
  663. --- V ---------------------ADDRESSING MODE TABLES------------------- V ---
  664.  
  665.  
  666. 5.1 Allowed Adressing modes
  667.  
  668.   CMP2  Compare Register Against Bounds
  669.   
  670.       Syntax:   CMP2 <ea>,Rn
  671.       Size:     Byte/Word/Long
  672.       Length:   4 bytes+<ea> data
  673.       Modes:    (An)
  674.                 (d16,An)
  675.                 (d8,An,Xn)
  676.                 (bd,An,Xn)
  677.                 $xxx.W
  678.                 $xxx.L
  679.                 (d16,PC)
  680.                 (d8,PC,Xn)
  681.                 (bd,PC,Xn)
  682.                 ([bd,An,Xn],od)
  683.                 ([bd,An],Xn,od)
  684.                 ([bd,PC,Xn],od)
  685.                 ([bd,PC],Xn,od)
  686.   -----------------------------------
  687.   MULU/MULS  Multiply (Un)signed
  688.   
  689.       Syntax:   MULU/S.W <ea>,Dn    16b*16b=>32b
  690.                 MULU/S.L <ea>,Dl    32b*32b=>32b
  691.                 MULU/S.L <ea>,Dh:Dl 32b*32B=>64b
  692.       Size:     Word/Long
  693.       Length:   2 bytes+<ea> data  (word)
  694.                 4 bytes+<ea> data  (long)
  695.       Modes: (both)
  696.                 Dn
  697.                 (An)
  698.                 (An)+
  699.                 -(An)
  700.                 (d16,An)
  701.                 (d8,An,Xn)
  702.                 $xxx.W
  703.                 $xxx.L
  704.                 #<data>
  705.                 (d16,PC)
  706.                 (d8,PC,Xn)
  707.                 (bd,An,Xn)
  708.                 ([bd,An,Xn],od)
  709.                 ([bd,An],Xn,od)
  710.                 (bd,PC,Xn)
  711.                 ([bd,PC,Xn],od)
  712.                 ([bd,PC],Xn,od)
  713.   -----------------------------------
  714.   DIVU(L)/DIVS(L)  Divide (Un)signed
  715.   
  716.       Syntax:   DIVU.W  <ea>,Dn     32b/16b=>16r:16q
  717.                 DIVU.L  <ea>,Dq     32b/32b=>32q
  718.                 DIVU.L  <ea>,Dr:Dq  64b/32b=>32r:32q
  719.                 DIVUL.L <ea>,Dr:Dq  32b/32b=>32r:32q
  720.       Size:     Word/Long
  721.       Length:   2 bytes+<ea> data (word)
  722.                 4 bytes+<ea> data (long)
  723.       Modes: (both)
  724.                 Dn
  725.                 (An)
  726.                 (An)+
  727.                 -(An)
  728.                 (d16,An)
  729.                 (d8,An,Xn)
  730.                 $xxx.W
  731.                 $xxx.L
  732.                 #<data>
  733.                 (d16,PC)
  734.                 (d8,PC,Xn)
  735.                 (bd,An,Xn)
  736.                 ([bd,An,Xn],od)
  737.                 ([bd,An],Xn,od)
  738.                 (bd,PC,Xn)
  739.                 ([bd,PC,Xn],od)
  740.                 ([bd,PC],Xn,od)
  741.   -----------------------------------
  742.   CHK2  Check Register Against Bounds
  743.   
  744.       Syntax:   CHK2 <ea>,Rn
  745.       Size:     Byte/Word/Long
  746.       Length:   4 bytes+<ea> data
  747.       Modes:    (An)
  748.                 (d16,An)
  749.                 (d8,An,Xn)
  750.                 (bd,An,Xn)
  751.                 $xxx.W
  752.                 $xxx.L
  753.                 (d16,PC)
  754.                 (d8,PC,Xn)
  755.                 (bd,PC,Xn)
  756.                 ([bd,An,Xn],od)
  757.                 ([bd,An],Xn,od)
  758.                 ([bd,PC,Xm],od)
  759.                 ([bd,PC],Xn,od)
  760.   -----------------------------------
  761.   EXTB  Extend Byte to long
  762.   
  763.       Syntax:   EXTB.L Dn
  764.       Size:     Word/Long
  765.       Length:   2 bytes
  766.       Modes:    Dn
  767.   -----------------------------------
  768.   BFxxx BitField instructions
  769.   
  770.       Syntax:   BFTST   <ea>{offset:width}    BF Test
  771.                 BFSET   <ea>{offset:width}    BF test and Set
  772.                 BFCLR   <ea>{offset:width}    BF test and clear
  773.                 BFCHG   <ea>{offset:width}    BF test and Change
  774.                 BFEXTS  <ea>{offset:width},Dn BF Extract Signed
  775.                 BFEXTU  <ea>{offset:width},Dn BF Extract Unsigned
  776.                 BFFFO   <ea>{offset:width},Dn BF Find First One
  777.                 BFINS   Dn,<ea>{offset:width} BF Insert
  778.                 
  779.                 Both offset and width may be specified as data registers
  780.       Size:     The BF instructions are unsized
  781.       Length:   4 bytes+<ea> data
  782.       Modes:    Dn
  783.                 (An)
  784.                 (d16,An)
  785.                 (d8,An,Xn)
  786.                 (db,An,Xn)
  787.                 ([bd,An,Xn],od)
  788.                 ([bd,An],Xn,od)
  789.                 ([bd,PC,Xn],od)
  790.                 ([bd,PC],Xn,od)
  791.                 $xxx.W
  792.                 $xxx.L
  793.                 (d16,PC)
  794.                 (d8,PC,Xn)
  795.                 (bd,PC,Xn)
  796.                 ([bd,PC,Xn],od)
  797.                 ([bd,PC],Xn,od)
  798.   -----------------------------------
  799.   RTD  Return and Deallocate
  800.   
  801.       Syntax:   RTD #displacement
  802.       Size:     Unsized
  803.       Length:   4 bytes
  804.       Modes:    #<data>
  805.   -----------------------------------
  806.   PACK  Pack BCD data
  807.   
  808.       Syntax:   PACK -(Ax),-(Ay),#displacement
  809.                 PACK Dx,Dy,#displacement
  810.       Size:     Unsized
  811.       Length:   4 bytes
  812.       Modes:    See syntax
  813.   -----------------------------------
  814.   UNPK  Unpack BCD data
  815.   
  816.       Syntax:   UNPK -(Ax),-(Ay),#displacement
  817.                 UNPK Dx,Dy,#displacement
  818.       Size:     Unsized
  819.       Length:   4 bytes
  820.       Modes:    See sntax
  821.   -----------------------------------
  822.   MOVE16  Move 16 bytes block
  823.   
  824.       Syntax:   MOVE16 (Ax)+,(Ay)+
  825.                 MOVE16 $xxx.L,(An)
  826.                 MOVE16 $xxx.L,(An)+
  827.                 MOVE16 (An),$xxx.L
  828.                 MOVE16 (An)+,$xxx.L
  829.       Size:     1 line (16 bytes)
  830.       Length:   4 bytes   (Ax)+,(Ay)+
  831.                 6 bytes   The rest
  832.       Modes:    See syntax
  833.   -----------------------------------
  834.   CAS/CAS2  Compare And Swap with operand
  835.   
  836.       Syntax:  CAS  Dc,Du,<ea>
  837.                CAS2 Dc1:Dc2,Du1:Du2,(Rn1):(Rn2)
  838.       Size:    Byte/Word/Long (CAS)
  839.                Word/Long      (CAS2)
  840.       Length:  4 bytes+<ea> data (CAS)
  841.                6 bytes+<ea> data (CAS2)
  842.       Modes: (CAS)
  843.                (An)
  844.                (An)+
  845.                -(An)
  846.                (d16,An)
  847.                (d8,An,Xn)
  848.                (bd,An,Xn)
  849.                ([bd,An,Xn],od)
  850.                ([bd,An],Xn,od)
  851.                $xxx.W
  852.                $xxx.L
  853.   -----------------------------------
  854.   TRAPcc  Trap on Condition
  855.   
  856.       Syntax:  TRAPcc
  857.                TRAPcc.W #<data>
  858.                TRAPcc.L #<data>
  859.       Size:    Unsized/Word/Long
  860.       Length:  2 bytes (Unsized)
  861.                4 bytes (Word)
  862.                6 bytes (Long)
  863.       Modes:   #<data>
  864.   -----------------------------------
  865.  
  866. ***********************************************************************************************
  867. *                  The text in this document is written by Erik H. Bakke                      *
  868. *                           © 1993 Erik H. Bakke/Bakke SoftDev                                *
  869. * This document may be freely redistributed as long as it remains unchanged and together with *
  870. *                               the FPU programming document                                  *
  871. ***********************************************************************************************
  872. *Permission is granted to Michael Glew to incorporate it in his Asp68k project, and eventually*
  873. *                       editing it to fit in the Asp68k environment                           *
  874. *Permission is granted to include this document in the HowToCode archive as long as it remains*
  875. *                                          unchanged.                                         *
  876. ***********************************************************************************************
  877. *  For error corrections, comments etc., the author can be reached at                         *
  878. *                                 e-mail:  db36@hp825.bih.no                                  *
  879. *                                 phone:   +47-5630-5537 (13:00-21:00 GMT)                    *
  880. *                                 post:    Erik H. Bakke                                      *
  881. *                                          Bjørnen                                            *
  882. *                                          N-5227 SØRE NESET                                  *
  883. *                                          Norway                                             *
  884. ***********************************************************************************************