Motorola Axiom CMD11E1 Guía de usuario Pagina 50

  • Descarga
  • Añadir a mis manuales
  • Imprimir
  • Pagina
    / 101
  • Tabla de contenidos
  • MARCADORES
  • Valorado. / 5. Basado en revisión del cliente
Vista de pagina 49
50 CHAPTER 4. PROGRAMS
5. Compiler keeps track of the life and scope of the variable so that the variable
is available only when it is in the scope of the instruction (the simplest case
is the distinction between global and local variables.
In assembly code, you are pretty much on your own. First of all, variables are
known by their address. Some variables require more than one location. In this
case, you allocate consecutive memory locations for the variable, and the address
of the variable is the first of these locations. It is your responsibility to make
sure that (a) you set aside adequate memory for the variable, and (b) you do not
assign the same location for more than one variable. The most common errors
that programmers make is not keeping this in mind. For example, the programmer
may set the address of a two byte variable as $3120 and the address of another
variable as $3121. It is a bad idea for you to manually assign addresses
to variables. Let the assembler do it for you. However, if you have to manually
assign an address to a variable, EQUate a label to the variable as
TOTAL EQU $3800 *variable to keep track of the total
The above instruction defines a variable called TOTAL that is stored in locations
starting from $3800. Note you have no idea how many bytes are needed for the
variable and therein lies the potential bug!
4.3.1 How the assembler works
Inside the assembler is a variable called the location counter, also known as the
dot in the unix community. When the assmbler starts, the location counter is
initialized to zero. As the assembler reads your program, the location counter
changes in response to your code. For example, the ORG command sets the location
counter to the value after the ORG instruction. Thus, if you want to change the
location counter to $00EB, you would write
ORG $00EB
The assembler keeps a copy of the HC11 memory internally, and the location
counter is used to address the memory. Here, briefly, is how the assembler works:
1. Read the instruction. If the instruction has a label, and it is not an EQU
instruction, then equate the label to the location counter. If the instruction
is an EQU instruction, the label is EQUated to value after the mnemonic.
2. If the instruction is a valid HC11 instruction, generate the code for the
instruction. The code is stored in consecutive memory locations starting
from the address given by the location counter. The location counter is
incremented by the amount of memory needed to store code.
Vista de pagina 49
1 2 ... 45 46 47 48 49 50 51 52 53 54 55 ... 100 101

Comentarios a estos manuales

Sin comentarios