Hardware Reference
In-Depth Information
conditional jump instruction). There is a limit to the distance that the processor can branch
(or jump) conditionally. The branch distance (referred to as branch offset ) is from 2128 byte
to 127 bytes for most 8-bit and 16-bit microcontrollers because they use 8 bits to specify
branch offset. In other situations, the programmer wants to force the processor to execute the
instruction in any location within the available memory space. A jump instruction is used for
this purpose. The target of jump may be specified in 16 bits, 32 bits, or 64 bits depending on
the width of the program counter.
It is easy to figure out that writing programs in machine instructions is extremely
difficult. Over the years, assembly language and high-level languages such as FORTRAN,
COBOL, BASIC, C, C11, JAVA, and so on have been invented. Assembly language uses a
mnemonic symbol to represent each machine instruction. The result is that each machine
instruction is represented by an assembly instruction . The programmer can see the assembly
instruction and figure out what operation is going to be performed quickly for most instruc-
tions. The assembly language makes programming much easier than in machine language.
However, assembly language is still at a very low level. It is not very productive to write large
and complicated programs in assembly language. Moreover, it needs a translator, called an
assembler, to translate assembly instructions into machine instructions so that they can be
executed by the computer.
High-level language is at a much higher level. Therefore, one statement written in high-
level language may be translated into tens or even hundreds of machine instructions. A program
written in high-level language also needs a translator to translate it into machine instructions
so that it can be executed by the computer. The translator of a high-level programming lan-
guage is called a compiler . The translation from high-level language to machine language is
often not optimal. Therefore, there are some applications that require very tight performance
controls that are still written in assembly language. It is not unusual to find large programming
projects that are written in both assembly and high-level languages.
Programs written in assembly language or high-level languages are referred to as source
code whereas the outputs of assembler and compiler are called object code .
R EGISTERS
A register is a storage location inside the CPU. It is used to hold data and/or a memory
address during the execution of an instruction. Because the register is very close to the CPU,
it can provide fast access to operands for program execution. The number of registers varies
greatly from processor to processor.
A processor may add a special register called an accumulator and include it as one of the
operands for most instructions. The Intel 8051 variants, the Microchip PIC18, and the Freescale
HCS12 microcontroller use this approach. Using the dedicated accumulator as one of the oper-
ands can shorten the instruction length. Other processors, for example, Atmel AVR and Micro-
chip PIC32, may include many general-purpose data registers (16 or 32) in the CPU and allow
any data register to be used as any operand of most instructions with two or three operands.
This provides great freedom to the compiler during the program translation process. A proces-
sor designed using this approach is considered to be orthogonal .
1.3.2 Microprocessor
The earlier processors may be implemented in one or multiple printed circuit boards. With
the advancement of integrated circuit technology, a complete processor can be implemented in
one integrated circuit (an integrated circuit is often called a chip ). A microprocessor is a proces-
sor implemented in a single integrated circuit.
 
Search WWH ::




Custom Search