Page 114 - Introduction to Microcontrollers Architecture, Programming, and Interfacing of The Motorola 68HC12
P. 114

4.1 Introductory Example and Assembler Printout                      91

                                Table 4.2. Addressing Modes























          Notes: 1: Prefix "<" or postfix .B forces Page 0. 2t Prefix ">"
          or postfix .W forces Direct. 3: Can substitute Y, SP, or PC for X.
          4: Can substitute Y or SP for X. 5: Can substitute B or D for A
        address or label ALPHA, the addressing modes in Table 4.2 can now all use symbolic
        addresses in place of numbers in the previous examples.
            The assembler understands the use of addition, multiplication, and the like, using
        symbolic addresses in expressions. If ALPHA is location 100 and the operand field
        contains ALPHA+1, the assembler will put in the value 101. In simplest terms, an
        expression is just the usual algebraic combination of labels, numbers, and C language
        operations +, -, *, /, %, «, », &, I , ~, !, <, >, <=, >=. !=, ==. Pascal operators = and
        o are also recognized. Parenthesis are allowed, and precedence and evaluation are exactly
        as they are in C. Some examples of expressions are:
             JUMP          JUMP* ( 8 -I- TAB)        ( (RATE-2 ) * 17 ) -TEMP

        Comment Field
        In the comment field, the programmer can insert short comments stating the purpose of
        each instruction. The comment must begin with a semicolon (;). In other assemblers, the
        comments begin one or more blanks after the operand field and are printed in the
        assembler listing but are otherwise ignored by the assembler.

            In summary, writing an assembly-language program is a lot easier than writing
        machine code by hand. You can use symbolic addresses, letting the assembler determine
        where to put them and letting the assembler make sure that the instructions have the
        right operand values. You do have to conform to the rales of the language, however, and
        you have to spell the mnemonics exactly the way the assembler wants to recognize
        them. Although it would be nice to be able to just talk to the computer and tell it what
        you want it to do using conversational English, an assembler can barely understand the
        mnemonics for the instructions if you write them correctly and carefully. Nevertheless,
        writing assembly-language programs is easier than writing hexadecimal machine code.
   109   110   111   112   113   114   115   116   117   118   119