assembly68000

Instruction Definitions "Documentation" confusion


Im reading the documentation or whatever the term is for the instruction definitions and I'm confused as to what a lot of it means.

"Operation: source destination -> destination" what does that mean. What does that tell me?

"Assembler Syntax: ADD , Dn ADD Dn, " Does that mean I can put the destination in either place? That ADD D0,#33 would do the same thing as ADD #33,D0?


Solution

  • This information is taken from the "M68000 Family Programmer's Reference Manual". I assume that you're using this manual, or other documentation that contains a subset of it. In that document, the reference for ADD is on pages 4-4 through 4-6, and the Instruction Summary starts on page 3-1.


    For the first question about:

    Operation:
     Source + Destination → Destination
    

    That's telling you the operation that's being done. The value in the source and is added to the current value in the destination, and that sum is stored in the destination.


    For the second question, this concerns the two types of instructions that exist for ADD:

    Assembler Syntax:
     ADD <ea>, Dn
     ADD Dn, <ea>
    

    What you say is incorrect, this is not telling you that you can write it either way, and it have the same effect. This is specifying what types of parameters can be given to the instruction.

    Specifically, while one argument can be any (sensible) effective address, at least one of the two arguments (either the source or the destination) must be a data register.


    One apparent point of confusion you have is on identifying the source vs. the destination. It's important to read the Instruction Summary (Section 3.1 of the PRM) to understand how assembly instructions are written.

    Importantly, that section has a table describing the various symbols used in instructions. It also states the following:

    In the operand syntax statements of the instruction definitions, the operand on the right is the destination operand.

    So, writing ADD #33, D0 means that the number 33 is added to the value in register D0, and then the result of that addition is stored back in register D0.


    With the two options for writing the instruction, either the source or the destination must be a data register, with the other being an effective address. That effective address could be an address register, the value in memory pointed-to by an address register (possibly pre-decremented, post-incremented, offset, etc.), an integer value, etc.

    For example, you might add the value in D3 to the value stored at the address held in A2 (represented as (A2)). In that case, the processor will read the memory at the address in A2, add the value in D3 to that, and then store it back at that same address. This would be written as ADD D3, (A2).

    However, not all effective address types are sensible in all places. For example, the ADD D0, #33 you give isn't a valid assembly instruction, since an immediate value isn't a valid destination. You can't store a value in the number 33.

    You can see that the effective address destination operation tables for ADD have several entries that are shown as invalid, compared to the equivalent source effective address tables.