Hardware Reference
In-Depth Information
5.9 SUMMARY
The instruction set architecture level is what most people think of as ''machine
language'' although on CISC machines it is generally built on a lower layer of
microcode. At this level the machine has a byte- or word-oriented memory con-
sisting of some number of megabytes or gigabytes, and instructions such as MOVE ,
ADD , and BEQ .
Most modern computers have a memory that is organized as a sequence of
bytes, with 4 or 8 bytes grouped together into words. There are normally also be-
tween 8 and 32 registers present, each one containing one word. On some ma-
chines (e.g., Core i7), references to words in memory do not have to be aligned on
natural boundaries in memory, while on others (e.g., OMAP4430 ARM), they must
be. But even if words do not have to be aligned, performance is better if they are.
Instructions generally have one, two, or three operands, which are addressed
using immediate, direct, register, indexed, or other addressing modes. Some ma-
chines have a large number of complex addressing modes. In many cases, compil-
ers are unable to use them in a effective way, so they are unused. Instructions are
generally available for moving data, dyadic and monadic operations, including
arithmetic and Boolean operations, branches, procedure calls, and loops, and
sometimes for I/O. Typical instructions move a word from memory to a register
(or vice versa), add, subtract, multiply, or divide two registers or a register and a
memory word, or compare two items in registers or memory. It is not unusual for a
computer to have well over 200 instructions in its repertoire. CISC machines often
have many more.
Control flow at level 2 is achieved using a variety of primitives, including
branches, procedure calls, coroutine calls, traps, and interrupts. Branches are used
to terminate one instruction sequence and begin a new one at a (possibly distant)
location in memory. Procedures are used as an abstraction mechanism, to allow a
part of the program to be isolated as a unit and called from multiple places.
Abstraction using procedures in one form or another is the basis of all modern pro-
gramming. Without procedures or the equivalent, it would be impossible to write
any modern software. Coroutines allow two threads of control to work simultan-
eously. Traps are used to signal exceptional situations, such as arithmetic over-
flow. Interrupts allow I/O to take place in parallel with the main computation, with
the CPU getting a signal as soon as the I/O has been completed.
The Towers of Hanoi is a fun little problem with a nice recursive solution that
we examined. Iterative solutions to it have been found, but they are far more com-
plicated and less elegant than the recursive one we studied.
Last, the IA-64 architecture uses the EPIC model of computing to make it easy
for programs to exploit parallelism. It uses instruction groups, predication, and
speculative LOAD s to gain speed. All in all, it may represent a significant advance
over the Core i7, but it puts much of the burden of parallelization on the compiler.
Still, doing work at compile time is always better than doing it at run time.
 
 
Search WWH ::




Custom Search