1.
Discuss
data operations in ARM Process.
ANS:
Ø Data Operations
Arithmetic
and logical operations in C are performed in variables. Variables are
implemented as memory locations. Therefore, to be able to write instructions to
perform C expressions and assignments, we must consider both arithmetic and
logical instructions as well as instructions for reading and writing memory.
Let us
consider sample fragment of C code with data declarations and several
assignment statements. The variables a, b, c, x, y, and z all become data
locations in memory. In most cases data are kept relatively separate from
instructions in the program’s memory image.
In the
ARM processor, arithmetic and logical operations cannot be performed directly
on memory locations. While some processors allow such operations to directly
reference main memory, ARM is load-store architecture. Data operands must first
be loaded into the CPU and then stored back to main memory to save the results.
Figure 2.8 shows the registers in the basic ARM programming model. ARM has 16
general-purpose registers, r0 through r15. Except for r15, they are identical.
Any operation that can be done on one of them can be done on the other one
also. The r15 register has the same capabilities as the other registers, but it
is also used as the program counter. The program counter should of course not
be overwritten for use in data operations. However, giving the PC the
properties of a general-purpose register allows the program counter value to be
used as an operand in computations, which can make certain programming tasks
easier.
The other
important basic register in the programming model is the current program status
register (CPSR). This register is set automatically during every arithmetic,
logical, or shifting operation. The top four bits of the CPSR hold the
following useful information about the results of that arithmetic/logical
operation:
ü The
negative (N) bit is set when the result is negative in two’s-complement
arithmetic.
ü The zero
(Z) bit is set when every bit of the result is zero.
ü The
carry (C) bit is set when there is a carry out of the operation.
ü The
overflow (V) bit is set when an arithmetic operation results in an overflow.
No comments:
Post a Comment