Types of Operands

Types of Operands
12.2 TYPES OF OPERANDS
Machine instructions operate on data. The most important general categories of
data are
    • Addresses
    • Numbers
    • Characters
    • Logical data
We shall see, in discussing addressing modes in Chapter 13, that addresses
are, in fact, a form of data. In many cases, some calculation must be performed on
the operand reference in an instruction to determine the main or virtual memory
address. In this context, addresses can be considered to be unsigned integers.
Other common data types are numbers, characters, and logical data, and each
of these is briefly examined in this section. Beyond that, some machines define specialized data types or data structures. For example, there may be machine operations that operate directly on a list or a string of characters.


Numbers


       All machine languages include numeric data types. Even in nonnumeric data processing, there is a need for numbers to act as counters, field widths, and so forth.
An important distinction between numbers used in ordinary mathematics and numbers stored in a computer is that the latter are limited. This is true in two senses.
First, there is a limit to the magnitude of numbers representable on a machine and
second, in the case of floating-point numbers, a limit to their precision. Thus, the
programmer is faced with understanding the consequences of rounding, overflow,
and underflow.
Three types of numerical data are common in computers:
   • Binary integer or binary fixed point
   • Binary floating point
   • Decimal
We examined the first two in some detail in Chapter 10. It remains to say a few
words about decimal numbers.
    Although all internal computer operations are binary in nature, the human
users of the system deal with decimal numbers. Thus, there is a necessity to convert
from decimal to binary on input and from binary to decimal on output. For applications in which there is a great deal of I/O and comparatively little, comparatively
simple computation, it is preferable to store and operate on the numbers in decimal
form. The most common representation for this purpose is packed decimal.


With packed decimal, each decimal digit is represented by a 4-bit code, in the
obvious way, with two digits stored per byte. Thus, 0 = 000, 1 = 0001, c, 8 = 1000,
and 9 = 1001. Note that this is a rather inefficient code because only 10 of 16 possible 4-bit values are used. To form numbers, 4-bit codes are strung together, usually in multiples of 8 bits. Thus, the code for 246 is 0000 0010 0100 0110. This code
is clearly less compact than a straight binary representation, but it avoids the conversion overhead. Negative numbers can be represented by including a 4-bit sign
digit at either the left or right end of a string of packed decimal digits. Standard sign
values are 1100 for positive (+) and 1101 for negative (-).
Many machines provide arithmetic instructions for performing operations
directly on packed decimal numbers. The algorithms are quite similar to those
described in Section 9.3 but must take into account the decimal carry operation.


Characters


    A common form of data is text or character strings. While textual data are most
convenient for human beings, they cannot, in character form, be easily stored or
transmitted by data processing and communications systems. Such systems are
designed for binary data. Thus, a number of codes have been devised by which characters are represented by a sequence of bits. Perhaps the earliest common example
of this is the Morse code. Today, the most commonly used character code in the
International Reference Alphabet (IRA), referred to in the United States as the
American Standard Code for Information Interchange (ASCII; see Appendix F).
Each character in this code is represented by a unique 7-bit pattern; thus, 128 different characters can be represented. This is a larger number than is necessary to
represent printable characters, and some of the patterns represent control characters. Some of these control characters have to do with controlling the printing
of characters on a page. Others are concerned with communications procedures.
IRA-encoded characters are almost always stored and transmitted using 8 bits per
character. The eighth bit may be set to 0 or used as a parity bit for error detection.
In the latter case, the bit is set such that the total number of binary 1s in each octet
is always odd (odd parity) or always even (even parity).
    Note in Table F.1 (Appendix F) that for the IRA bit pattern 011XXXX, the
digits 0 through 9 are represented by their binary equivalents, 0000 through 1001, in
the rightmost 4 bits. This is the same code as packed decimal. This facilitates conversion between 7-bit IRA and 4-bit packed decimal representation.
    Another code used to encode characters is the Extended Binary Coded
Decimal Interchange Code (EBCDIC). EBCDIC is used on IBM mainframes. It
is an 8-bit code. As with IRA, EBCDIC is compatible with packed decimal. In
the case of EBCDIC, the codes 11110000 through 11111001 represent the digits
0 through 9.


Logical Data
      

       Normally, each word or other addressable unit (byte, halfword, and so on) is treated
as a single unit of data. It is sometimes useful, however, to consider an n-bit unit as
consisting of n 1-bit items of data, each item having the value 0 or 1. When data are
viewed this way, they are considered to be logical data.


      There are two advantages to the bit-oriented view. First, we may sometimes wish
to store an array of Boolean or binary data items, in which each item can take on only
the values 1 (true) and 0 (false). With logical data, memory can be used most efficiently
for this storage. Second, there are occasions when we wish to manipulate the bits of a
data item. For example, if floating-point operations are implemented in software, we
need to be able to shift significant bits in some operations. Another example: To convert from IRA to packed decimal, we need to extract the rightmost 4 bits of each byte.
    Note that, in the preceding examples, the same data are treated sometimes as
logical and other times as numerical or text. The “type” of a unit of data is determined by the operation being performed on it. While this is not normally the case in
high-level languages, it is almost always the case with machine language

Machine Instruction Characteristic

The operation of the processor is determined by the instructions it executes,
referred to as machine instructions or computer instructions. The collection of different instructions that the processor can execute is referred to as the processor’s
instruction set.
Elements of a Machine Instruction
Each instruction must contain the information required by the processor for execution. Figure 12.1, which repeats Figure 3.6, shows the steps involved in instruction
execution and, by implication, defines the elements of a machine instruction. These
elements are as follows:
• Operation code: Specifies the operation to be performed (e.g., ADD, I/O).
The operation is specified by a binary code, known as the operation code, or
opcode.
• Source operand reference: The operation may involve one or more source
operands, that is, operands that are inputs for the operation.

Figure 12.1 Instruction Cycle State Diagram

• Result operand reference: The operation may produce a result.
• Next instruction reference: This tells the processor where to fetch the next
instruction after the execution of this instruction is complete.
The address of the next instruction to be fetched could be either a real address
or a virtual address, depending on the architecture. Generally, the distinction is
transparent to the instruction set architecture. In most cases, the next instruction to
be fetched immediately follows the current instruction. In those cases, there is no
explicit reference to the next instruction. When an explicit reference is needed, then
the main memory or virtual memory address must be supplied. The form in which
that address is supplied is discussed in Chapter 13.
Source and result operands can be in one of four areas:
• Main or virtual memory: As with next instruction references, the main or virtual memory address must be supplied.
• Processor register: With rare exceptions, a processor contains one or more
registers that may be referenced by machine instructions. If only one register
exists, reference to it may be implicit. If more than one register exists, then
each register is assigned a unique name or number, and the instruction must
contain the number of the desired register.
• Immediate: The value of the operand is contained in a field in the instruction
being executed.
• I/O device: The instruction must specify the I/O module and device for the
operation. If memory-mapped I/O is used, this is just another main or virtual
memory address.


Instruction Representation


Within the computer, each instruction is represented by a sequence of bits. The
instruction is divided into fields, corresponding to the constituent elements of the


Figure 12.2 A Simple Instruction Format
instruction. A simple example of an instruction format is shown in Figure 12.2. As
another example, the IAS instruction format is shown in Figure 2.2. With most
instruction sets, more than one format is used. During instruction execution, an
instruction is read into an instruction register (IR) in the processor. The processor
must be able to extract the data from the various instruction fields to perform the
required operation.
It is difficult for both the programmer and the reader of textbooks to deal with
binary representations of machine instructions. Thus, it has become common practice to use a symbolic representation of machine instructions. An example of this
was used for the IAS instruction set, in Table 2.1.
Opcodes are represented by abbreviations, called mnemonics, that indicate
the operation. Common examples include
ADD Add
SUB Subtract
MUL Multiply
DIV Divide
LOAD Load data from memory
STOR Store data to memory
Operands are also represented symbolically. For example, the instruction
ADD R, Y
may mean add the value contained in data location Y to the contents of register R.
In this example, Y refers to the address of a location in memory, and R refers to a
particular register. Note that the operation is performed on the contents of a location, not on its address.
Thus, it is possible to write a machine-language program in symbolic form.
Each symbolic opcode has a fixed binary representation, and the programmer specifies the location of each symbolic operand. For example, the programmer might
begin with a list of definitions:
X = 513
Y = 514
and so on. A simple program would accept this symbolic input, convert opcodes and
operand references to binary form, and construct binary machine instructions.
Machine-language programmers are rare to the point of nonexistence. Most programs today are written in a high-level language or, failing that, assembly language,
which is discussed in Appendix B. However, symbolic machine language remains a
useful tool for describing machine instructions, and we will use it for that purpose.



Instruction Types

Consider a high-level language instruction that could be expressed in a language
such as BASIC or FORTRAN. For example,
X = X + Y
This statement instructs the computer to add the value stored in Y to the value
stored in X and put the result in X. How might this be accomplished with machine
instructions? Let us assume that the variables X and Y correspond to locations 513
and 514. If we assume a simple set of machine instructions, this operation could be
accomplished with three instructions:
      1. Load a register with the contents of memory location 513. 

      2. Add the contents of memory location 514 to the register.
      3. Store the contents of the register in memory location 513.
As can be seen, the single BASIC instruction may require three machine
instructions. This is typical of the relationship between a high-level language and
a machine language. A high-level language expresses operations in a concise algebraic form, using variables. A machine language expresses operations in a basic
form involving the movement of data to or from registers.
With this simple example to guide us, let us consider the types of instructions
that must be included in a practical computer. A computer should have a set of
instructions that allows the user to formulate any data processing task. Another way
to view it is to consider the capabilities of a high-level programming language. Any
program written in a high-level language must be translated into machine language
to be executed. Thus, the set of machine instructions must be sufficient to express
any of the instructions from a high-level language. With this in mind we can categorize instruction types as follows:
    • Data processing: Arithmetic and logic instructions
    • Data storage: Movement of data into or out of register and or memory
                                 locations
    • Data movement: I/O instructions
    • Control: Test and branch instructions
Arithmetic instructions provide computational capabilities for processing
numeric data. Logic (Boolean) instructions operate on the bits of a word as bits
rather than as numbers; thus, they provide capabilities for processing any other type
of data the user may wish to employ. These operations are performed primarily on
data in processor registers. Therefore, there must be memory instructions for moving data between memory and the registers. I/O instructions are needed to transfer
programs and data into memory and the results of computations back out to the
user. Test instructions are used to test the value of a data word or the status of
a computation. Branch instructions are then used to branch to a different set of
instructions depending on the decision made.
We will examine the various types of instructions in greater detail later in this
chapter.'

Number of Addresses

      One of the traditional ways of describing processor architecture is in terms of the
number of addresses contained in each instruction. This dimension has become less
significant with the increasing complexity of processor design. Nevertheless, it is
useful at this point to draw and analyze this distinction.
     What is the maximum number of addresses one might need in an instruction? Evidently, arithmetic and logic instructions will require the most operands.
Virtually all arithmetic and logic operations are either unary (one source operand)
or binary (two source operands). Thus, we would need a maximum of two addresses
to reference source operands. The result of an operation must be stored, suggesting
a third address, which defines a destination operand. Finally, after completion of an
instruction, the next instruction must be fetched, and its address is needed.
     This line of reasoning suggests that an instruction could plausibly be required
to contain four address references: two source operands, one destination operand,
and the address of the next instruction. In most architectures, most instructions have
one, two, or three operand addresses, with the address of the next instruction being
implicit (obtained from the program counter). Most architectures also have a few
special-purpose instructions with more operands. For example, the load and store
multiple instructions of the ARM architecture, described in Chapter 13, designate
up to 17 register operands in a single instruction.
     Figure 12.3 compares typical one-, two-, and three-address instructions that
could be used to compute Y = (A - B)>[C + (D * E)]. With three addresses,
each instruction specifies two source operand locations and a destination operand
location. Because we choose not to alter the value of any of the operand locations,
a temporary location, T, is used to store some intermediate results. Note that there
are four instructions and that the original expression had five operands


      Three-address instruction formats are not common because they require a
relatively long instruction format to hold the three address references. With twoaddress instructions, and for binary operations, one address must do double duty as
both an operand and a result. Thus, the instruction SUB Y, B carries out the calculation Y - B and stores the result in Y. The two-address format reduces the space
requirement but also introduces some awkwardness. To avoid altering the value of
an operand, a MOVE instruction is used to move one of the values to a result or
temporary location before performing the operation. Our sample program expands
to six instructions.
      Simpler yet is the one-address instruction. For this to work, a second address
must be implicit. This was common in earlier machines, with the implied address
being a processor register known as the accumulator (AC). The accumulator contains one of the operands and is used to store the result. In our example, eight
instructions are needed to accomplish the task.
      It is, in fact, possible to make do with zero addresses for some instructions.
Zero-address instructions are applicable to a special memory organization called
a stack. A stack is a last-in-first-out set of locations. The stack is in a known location and, often, at least the top two elements are in processor registers. Thus,
zero-address instructions would reference the top two stack elements. Stacks are
described in Appendix O. Their use is explored further later in this chapter and in
Chapter 13.
     Table 12.1 summarizes the interpretations to be placed on instructions with
zero, one, two, or three addresses. In each case in the table, it is assumed that the
address of the next instruction is implicit, and that one operation with two source
operands and one result operand is to be performed.
      The number of addresses per instruction is a basic design decision. Fewer
addresses per instruction result in instructions that are more primitive, requiring a
less complex processor. It also results in instructions of shorter length. On the other
hand, programs contain more total instructions, which in general results in longer
execution times and longer, more complex programs. Also, there is an important
threshold between one-address and multiple-address instructions. With one-address
instructions, the programmer generally has available only one general-purpose register, the accumulator. With multiple-address instructions, it is common to have
multiple general-purpose registers. This allows some operations to be performer.

      solely on registers. Because register references are faster than memory references,
this speeds up execution. For reasons of flexibility and ability to use multiple registers, most contemporary machines employ a mixture of two- and three-address
instructions.
The design trade-offs involved in choosing the number of addresses per instruction are complicated by other factors. There is the issue of whether an address references a memory location or a register. Because there are fewer registers, fewer bits
are needed for a register reference. Also, as we shall see in Chapter 13, a machine
may offer a variety of addressing modes, and the specification of mode takes one or
more bits. The result is that most processor designs involve a variety of instruction
formats.

Instruction Set Design
      
      One of the most interesting, and most analyzed, aspects of computer design is
instruction set design. The design of an instruction set is very complex because it
affects so many aspects of the computer system. The instruction set defines many
of the functions performed by the processor and thus has a significant effect on the
implementation of the processor. The instruction set is the programmer’s means of
controlling the processor. Thus, programmer requirements must be considered in
designing the instruction set.
It may surprise you to know that some of the most fundamental issues relating to the design of instruction sets remain in dispute. Indeed, in recent years, the
level of disagreement concerning these fundamentals has actually grown. The most
important of these fundamental design issues include the following:
      • Operation repertoire: How many and which operations to provide, and how
                                                  complex operations should be
      • Data types: The various types of data upon which operations are performed
      • Instruction format: Instruction length (in bits), number of addresses, size of
                                             various fields, and so on
      • Registers: Number of processor registers that can be referenced by instructions, and their use
      • Addressing: The mode or modes by which the address of an operand is
                                specified
   These issues are highly interrelated and must be considered together in designing an instruction set. This book, of course, must consider them in some sequence,
but an attempt is made to show the interrelationships.
   Because of the importance of this topic, much of Part Three is devoted to
instruction set design. Following this overview section, this chapter examines data
types and operation repertoire. Chapter 13 examines addressing modes (which
includes a consideration of registers) and instruction formats. Chapter 15 examines
the reduced instruction set computer (RISC). RISC architecture calls into question many of the instruction set design decisions traditionally made in commercial
computers.

3 Hal Baik dan 3 Hal Buruk Tentang Tekhnologi Nuklir

3 Hal Baik dan 3 Hal Buruk  Tentang Tekhnologi Nuklir

Teknologi nuklir adalah teknologi yang melibatkan reaksi dari inti atom (inti=nuclei). Teknologi nuklir dapat ditemukan pada bebagai aplikasi, dari yang sederhana seperti detektor asap hingga sesuatu yang besar seperti reaktor nuklir.

Sumber : Wikipedia


3 Hal Baik Tekhnologi Nuklir




1.Mengurangi angka kematian


Berdasarkan penelitian Nasa pada tahun 2013, tekhnologi nuklir berdampak positif buat lingkungan. Secara bertahap, mampu mengatasi 1,8 juta kepunahan ekosistem antara tahun 1976 dan 2009. Meskipun kita tambahkan dengan jumlah korban Chernobyl dan Fukushima, tekhnologi nuklir lebih mengurangi angka kematian. Gimana menurut agan?


2.Mengurangi Jumlah CO2 (Gas Karbondioksida) Berlebihan Diudara


Tekhnologi nuklir bisa dibilang cara yang tepat buat menyelamatkan lingkungan hidup, dari pada sumber daya alam utama saat ini yang kita pakai. Sejak tahun 1976, sekitar 64 gigaton emisi belum pernah dibersihkan. Sedangkan pada abad 21, diperkirakan akan bertambah antara 80-240 gigaton emisi. Tekhnologi Nuklir bisa jadi satu-satunya cara buat mengatasi perubahan cuaca dan mencegah bencana yang dibuat manusia itu sendiri seperti sekarang (Global Warming).

3.Tekhnologi paling baru dan bisa dikembangkan


Kalau kita dengar bahwa Tekhnologi Nuklir sangat berbahaya dan nggak layak dikembangkan, itu salah kaprah. Faktanya, semua kecelakaan itu karena reaktor-reaktor tersebut yang usang, inovasinya nggak pernah diperbarui/dikembangkan sejak 1970an karena phobia (ketakutan) akan masa lalu. Buat saat ini, sudah ada model reaktor bernama "Thorium" yang bisa memecahkan masalah tersebut, dan susah buat dikonversi menjadi senjata. Kita berharap aja, dimasa mendatang akan ada tekhnologi yang lebih canggih buat memecahkan masalahnya. *Keputusan ada ditangan manusia itu sendiri. ez ... 

3 Hal Buruk Tekhnologi Nuklir


1.Pengalihan menjadi senjata

Tekhnologi Nuklir menjadi cara yang hebat (menakutkan) sekaligus memusnahkan, untuk perang antar dunia. Contoh aja, agustus 1945 dua kota besar (Horishima dan Nagasaki) lenyap . Atau kita liat aja seperti sekarang negara Korea Utara yang tertutup, dengan kondisi politiknya yang ngga menentu dan memegang senjata larangan. Dari data yang ada, sedikitnya udah 40 negara yang pegang senjata jenis ini. 


2.Dampak Limbah dan Polusinya
Menggunakan nuklir ngga cuma menghasilkan radioaktif tapi juga menghasilkan elemen/zat beracun yang ekstrim seperti Plutonium.  . Ada dua pilihan, diolah menjadi sumber baru atau dijadikan senjata. Satu miligramnya bisa membunuhmu kek rokok gan , sedang dalam hanya jumlah beberapa kilo akan menjadi bom atom. Seperti pisau bermata dua, akan sangat fatal jika jatuh ditangan orang yang salah dan dijadikan senjata seperti orang yang berbasis militer kolot seperti sekarang. 


3.Kecelakaan dan Bencana Alam



Lebih dari 60 tahunan, sudah ada 7 kecelakaan besar pada reaktor atau saat berurusan dengan limbahnya. 3 diantaranya berdampak buruk buat lingkungan dengan kandungan radioaktifnya. Diawali dengan bencanaKyshtym di Russia (1957), disusul Chernobyl di Ukraina (1986), dan terakhir ini Fukushima di Jepang (2011).