Classification of Instructions
The actual instructions provided by any processor
can be broadly classified into the following groups:
• Data movement instructions: These allow
the processor move data between registers and between memory and registers
(e.g. 8086 mov, push, pop instructions). A ‘move’
instruction and its variants is among the most frequently used instructions in
an instruction set.
• Transfer of control instructions: These
are concerned with branching for loops and conditional control structures as
well as for handling subprograms (e.g.
8086 je, jg, jmp, call,ret instructions). These are
also commonly used instructions.
• Arithmetic/logical instructions: These
carry out the usual arithmetic and logical operations (e.g.
8086 cmp, add, sub, inc, and, or, xor instructions).
Surprisingly, these are not frequently used instructions, and when used, it is
often in conjunction with a conditional jump instruction rather than for
general arithmetic purposes. Note that we have included thecmp instruction
with the arithmetic/logical instructions because it actually behaves like
a sub instruction except it does not modify its destination register.
• Input/output instructions: These are
used for carrying out I/O (e.g. 8086 in, out instructions) but a
very common form of I/O called memory mapped I/O uses ‘move’ instructions for
I/O.
• Miscellaneous instructions (e.g.
8086 int, sti, cti, hlt, nop) for handling interrupts and such
activities. The hlt instruction halts the processor and
the nop instruction does nothing at all! These instructions are again
not that frequently used relative to data movement and transfer of control
instructions. The int instruction could also be classified as a
transfer of control instruction and interrupts are described in more detail
below.
This is not the only way to classify instructions.
For example, the arithmetic/logical instructions mentioned above may be
classified as operate instructions. Operate instructions also include
instructions that move data between registers and manipulate
stacks. Memory-access instructions refer to those that transfer data
between registers and memory.
Fixed and Variable length Instructions
Instructions are translated to machine code. In some
architectures all machine code instructions are the same length i.e. fixed
length. In other architectures, different instructions may be translated
into variable lengths in machine code.
This is the situation with 8086 instructions which
range from one byte to a maximum of 6 bytes in length. Such instructions are
calledvariable length instructions and are commonly used
on CISC machines.
The advantage of using such instructions, is that
each instruction can use exactly the amount of space it requires, so that
variable length instructions reduce the amount of memory space required for a
program.
On the other hand, it is possible to have fixed
length instructions, where as the name suggests, each instruction has the
same length. Fixed length instructions are commonly used
with RISC processors such as the PowerPC and Alpha processors.
Since each instruction occupies the same amount of
space, every instruction must be long enough to specify a memory operand, even
if the instruction does not use one. Hence, memory space is wasted by this form
of instruction. The advantage of fixed length instructions, it is argued, is
that they make the job of fetching and decoding instructions easier and more
efficient, which means that they can be executed in less time than the
corresponding variable length instructions.
Thus the comparison between fixed and variable
length instructions comes down to the classic computing trade off of
memory usage versus execution time.
In general, computer
programs that execute very quickly tend to use larger amounts of storage, while
programs to carry out the same tasks, that do not use so much storage, tend to
take longer to execute.
No comments:
Post a Comment