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

120                   Chapter 5 Advanced Assemblers, Linkers, and Down loaders


            The cross-assembler is a special kind of assembler. A true assembler is a program
        that runs on a computer that generates machine code for that same computer, it is
        common for a microcontroller to be too limited to be able to assemble code for itself,
        particularly for a microcontroller that is used in a laboratory for a university course. Such
        microcontrollers may not have enough memory, or a disk capable of holding the
        assembler program or the assembly language to be input to this program, or a printer
        capable of printing the listing. It is common to have a PC available with such user-
        friendly characteristics as Windows, large hard disks, and editors with which the user is
        already familiar. Such a computer, called the host computer, assembles programs for the
        microcontroller, which is called the target machine. The cross-assembler is written to
        run on the host machine and output target machine code.
            The powerful host machine can handle the assembly-language program. An editor is
        a program on the host that helps you write the program. Editors can be used to write any
        kind of (ASCII) character data. The cross-assembler is used to generate the machine code
        for the target machine. The host machine's printer is used to print the listing, and the
        host machine's disk is used to hold the (ASCII) assembly-language program, the
        program listing, and the machine code output that is to be put into the target machine.
            If your personal computer has a cross-assembler, it will usually also have a
        downloader. The downloader is a program running on the personal computer that takes
        the object code of the cross-assembler from the personal computer's disk or its primary
        memory and writes it into the target microcontroller's memory. A monitor program in
        the microcontroller receives data from the downloader; it generally does not need to be
        loaded because it is stored once and for all time in the microcontroller's ROM.
            In a microcontroller in which it is desired to maximize the available RAM, one
        might have a small program, called a bootstrap, whose only purpose is to load the
        downloader into its RAM. After the program is put in by the loader, the memory space
        occupied by the downloader could be used by the program for data storage. The bootstrap,
        now occupying only a small amount of memory space, is generally in ROM.
            It is also possible to connect host computers in a laboratory by means of a high-
        speed link to implement a local area network. The computers in this network are called
        servers. A printer attached to this network, with a computer to support it, is a print
        server. A computer that you experiment with is called a workstation. With each
        workstation connected to the print server, each can print a listing when it needs to do so,
        provided that the printer is not already in use. One printer can serve about a dozen
        workstations. This is economical and efficient. The downloader in a workstation sends
        the code generated by a cross-assembler to a target microcontroller. This kind of
        distributed processing, using local area networks, is one way to use a cross-assembler.
            The program's machine code will be broken up into several records, to constrain
        the record's length within a suitable size. For each record, the downloader provides a
        starting address for the first byte and the number of bytes, as shown in Figure 5.1.
            A byte called the checksum is usually included with each block, as indicated in
        Figure 5,1. This byte is formed by adding up all the bytes used to describe that particular
        block, ignoring carries. After loading, the checksum is computed and compared with the
        one supplied by the assembler. If any pattern of single errors in the columns has
        occurred, the two checksums will always be different, and an error message can be
        generated by the monitor.
   138   139   140   141   142   143   144   145   146   147   148