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

88                               Chapter 4 Assembly Language Programming


            An assembler is a program someone else has written that will help us write our
        own programs. We describe this program by how it handles a line of input data. The
        assembler is given a sequence of ASCII characters. (Table 4.1 is the table of ASCII
        characters.) The sequence of characters, from one carriage return to the next, is a line of
        assembly-language code or an assembly-language statement. For example,
                           ( space) LDAA ( space) #$ 10 (carriage return)     (I)

         would be stored as source code in memory for the assembler as:
























        The assembler outputs the machine code for each line of assembly-language code. For
        example, for line (1), the assembler would output the bytes $86 and $10, the opcode byte
         and immediate operand of (1), and their locations. The machine code output by the
         assembler for an assembly-language program is frequently called the object code. The
         assembler also outputs a listing of the program, which prints each assembly-language
         statement and the hexadecimal machine code that it generates. The assembler listing also
         indicates any errors that it can detect (assembly errors). This listing of errors is a great
        benefit, because the assembler program tells you exactly what is wrong, and you do not
        have to run the program to detect these errors one at a time as you do with more subtle
         bugs. If you input an assembly-language program to an assembler, the assembler will
        output the hexadecimal machine code, or object code, that you would have generated by
        hand. An assembler is a great tool to help you write your programs, and you will use it
        most of the time from now on.
            In this chapter you will look at an example to see how an assembly-language
        program and assembler listing are organized. Then you will look at assembler directives,
        which provide the assembler with information about the data structure and the location of
        the instruction sequence but do not generate instructions for the computer in machine
        code. You will see some examples that show the power of these directives. The main
        discussion will focus on the standard Motorola assembler in their MCUez freeware.
            At the end of this chapter, you should be prepared to write programs on the order of
         100 assembly-language lines. You should be able to use an assembler to translate any
   106   107   108   109   110   111   112   113   114   115   116