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

5



                   Advanced Assemblers,


                     Linkers, and Loaders











         This chapter discusses the advanced assembler and the linker, which are tools needed to
         assemble large programs; it is written for the reader who intends to write a lot of
         assembly-language programs or large assembly-language programs. Whereas the last
         chapter gave sufficient detail for the reader to understand the assembler output of a C
         compiler and to embed a limited amount of assembly language code in a C procedure,
         this chapter provides additional tools and greater depth to enable you to write large
         assembly-language programs using a relocatable, conditional, or macro assembler, and to
        join together separately assembled programs using a linker program.
            This chapter is optional. Current economics leads to writing programs in a high-
         level language like C or C++ rather than in assembly language. Most programmers will
         not need to write a lot of programs in assembly language nor to write large programs in
        assembly language. Such readers can skip this chapter without losing any background
         needed for the rest of this book.
            The first section introduces the complementary ideas of cross assembler and
        downloader. The next section describes the pair of ideas of relocatable assembler and
         linker program. Section 5.3 discusses how conditional assembly is used. The next
         section shows the power of macros in assembly-language programs. A final section
        recommends good documentation standards for programs written in assembly language.
            Upon completion of this chapter, the reader should understand the tools needed for
        writing a large number of assembly-language programs or large assembly-language
        programs. He or she should have little difficulty writing assembly-language programs in
        the order of a couple of hundred lines long.


        5.1 Cross Assemblers and Downloaders

        In this section we introduce a close cousin of the assembler, the cross-assembler, which,
        like the assembler, converts sequences of (ASCII) characters into machine instructions.
        For the most part, this section's material is descriptive, almost philosophical, rather than
        precise and practical. It is important general knowledge, and it is included here because
        the reader should understand what he or she is doing when using a personal computer to
        assemble a program for a microcontroller.

                                           119
   137   138   139   140   141   142   143   144   145   146   147