[Label] Opcode Operand(s) [Comment] Example: Loop: move.b d0,d1 The rest of line is comment |
|
|
Example:
123456789 <----------------- column number * This whole line is a comment * This line will cause a problem - because * did not start on column 1
(Because we will be labeling instructions like a madman when we write programs in assembler...)
Assemble it and look at the assembler listing file a.lst
You should see the following:
1 000000 * Demonstrate the effect of DS directive 2 000000 * Assemble with: as255 instr 3 000000 * Look at the output file a.lst 4 001000 ORG $1000 5 001000 1200 move.b d0, d1 6 001002 1200 L1: move.b d0, d1 7 001004 1200 move.b d0, d1 8 001006 A: ds.b 10 9 001010 1200 move.b d0, d1 10 001012 1200 L2: move.b d0, d1 11 001014 1200 move.b d0, d1 12 001016 B: ds.w 10 13 00102A 1200 move.b d0, d1 14 00102C 1200 L3: move.b d0, d1 15 00102E 1200 move.b d0, d1 16 001030 C: ds.l 10 17 001058 1200 move.b d0, d1 18 00105A 1200 L4: move.b d0, d1 19 00105C 1200 move.b d0, d1 20 00105E end SYMBOL TABLE ************ A 001006 B 001016 C 001030 L1 001002 L2 001012 L3 00102C L4 00105A |
Notice that:
|
ADD D0, D1 - operands are D0 and D1 (D0 + D1) - The second operand doubles as destination i.e., the result of the operation is stored in D1
So there is always a way to express any construct found in any High Level Language in assembler language
Instruction | Size | # | Dn | An | ... ------------------+------+----+----+----+----------- ..... | | | | | move <ea>,<ea> | BWL | *X | * | *X | Size = BWL instruction can use sizes B, W and L So you may use: move.b .. , .. move.w .. , .. move.l .. , .. The other columns list the "addressing modes" # represents a constant as operand Dn represents a data register as operand An represents an address register as operand ... <ea> is the "effective address" The marking in the columns give you information about whether certain type of operands may be used for <ea> * means allowed, unless restricted by other comments X means not allowed in destination So: * under Dn means: data registers can be used both in sourceand in destination *X under # means: constants can be used in source but not in destination (make sense, you can't change a value of a constant...) *X under An means: address registers can be used in source but not in destination (recall that we must use movea for address registers !) i.e.: movea ..., An