Computer architecture and organization pdf free download
Pauline Baker. Level Up! Other Useful Links. Wireless Communications. Basic Lisp Techniques. Computer Fundamentals. In computer terminology, such information is called the operand.
Therefore, any instruction issued by the processor must carry at least two types of information. We explain these classes together with simple examples in the following paragraphs. It should be noted that in presenting these examples, we would use the convention operation, source, destination to express any instruction. In that convention, operation rep- resents the operation to be performed, for example, add, subtract, write, or read. The source operand can be a con- stant, a value stored in a register, or a value stored in the memory.
A three-address instruction takes the form operation add-1, add-2, add In this form, each of add-1, add-2, and add-3 refers to a register or to a memory location. It also indicates that the values to be added are those stored in registers R1 and R2 that the results should be stored in register R3. The instruction adds the contents of memory location A to the contents of memory location B and stores the result in memory location C.
A two-address instruction takes the form operation add-1, add In this form, each of add-1 and add-2 refers to a register or to a memory location. This instruction adds the contents of regis- ter R1 to the contents of register R2 and stores the results in register R2. The original contents of register R2 are lost due to this operation while the original contents of register R1 remain intact.
In this case, the contents of memory location A are added to the contents of memory location B and the result is used to override the original contents of memory location B. A one-address instruction takes the form ADD R1.
In this case the instruction implicitly refers to a register, called the Accumulator Racc , such that the contents of the accumulator is added to the contents of the register R1 and the results are stored back into the accumulator Racc. If a memory location is used instead of a reg- ister then an instruction of the form ADD B is used. In this case, the instruction adds the content of the accumulator Racc to the content of memory location B and stores the result back into the accumulator Racc.
Between the two- and the one-address instruction, there can be a one-and-half address instruction. In this case, the instruction adds the contents of register R1 to the contents of memory location B and stores the result in register R1. Owing to the fact that the instruction uses two types of addressing, that is, a register and a memory location, it is called a one-and-half-address instruction. This is because register addressing needs a smaller number of bits than those needed by memory addressing.
It is interesting to indicate that there exist zero-address instructions. These are the instructions that use stack operation. These are the push and the pop operations. In the stack push operation, the SP value is used to indicate the location called the top of the stack in which the value 5A is to be stored in this case it is location The value stored at this location DD in this case is retrieved popped out and stored in the shown register. Different operations can be performed using the stack structure.
Table 2. The different ways in which operands can be addressed are called the addressing modes. The simplest addressing mode is to include the operand itself in the instruction, that is, no address information is needed.
This is called immediate addressing. A more involved addressing mode is to compute the address of the operand by adding a constant value to the content of a register. This is called indexed addressing. Between these two addressing modes there exist a number of other addressing modes including absolute addressing, direct addressing, and indirect addressing.
A number of different addressing modes are explained below. SP - 52 - 13 SP 39 39 Figure 2. Immediate Mode According to this addressing mode, the value of the operand is immediately avail- able in the instruction itself.
Consider, for example, the case of loading the decimal value into a register Ri. In this instruction, the operation to be per- formed is to load a value into a register. The source operand is immediately given as , and the destination is the register Ri. As can be seen the use of the immediate addressing mode is simple. The use of immediate addressing leads to poor programming practice.
This is because a change in the value of an operand requires a change in every instruction that uses the immediate value of such an operand. Direct Absolute Mode According to this addressing mode, the address of the memory location that holds the operand is included in the instruction. Consider, for example, the case of loading the value of the operand stored in memory location into register Ri.
In this instruc- tion, the source operand is the value stored in the memory location whose address is , and the destination is the register Ri. However, it requires the explicit inclusion of the operand address in the instruction. This is explained below. Indirect Mode In the indirect mode, what is included in the instruction is not the address of the operand, but rather a name of a register or a memory location that holds the effec- tive address of the operand.
In order to indicate the use of indirection in the instruc- tion, it is customary to include the name of the register or the memory location in parentheses. This instruc- tion has the memory location enclosed in parentheses, thus indicating indirec- tion. The meaning of this instruction is to load register Ri with the contents of the memory location whose address is stored at memory address Because indirec- tion can be made through either a register or a memory location, therefore, we can identify two types of indirect addressing.
These are register indirect addressing, if a register is used to hold the address of the operand, and memory indirect addressing, if a memory location is used to hold the address of the operand. The two types are illustrated in Figure 2. Indexed Mode In this addressing mode, the address of the operand is obtained by adding a con- stant to the content of a register, called the index register.
This instruction loads register Ri with the contents of the memory location whose address is the sum of the contents of register Rind and the value X. Index addressing is indicated in the instruction by including the name of the index register in parentheses and using the symbol X to indicate the constant to be added. As can be seen, indexing requires an additional level of complexity over register indirect addressing.
Other Modes The addressing modes presented above represent the most commonly used modes in most processors. These additional addressing modes are more involved as compared to those presented above.
Among these addressing modes the relative, autoincrement, and the autodecrement modes represent the most well-known ones. These are explained below. Relative Mode Recall that in indexed addressing, an index register, Rind , is used. Relative addressing is the same as indexed addressing except that the program counter PC replaces the index register. Autoincrement Mode This addressing mode is similar to the register indirect addressing mode in the sense that the effective address of the operand is the content of a register, call it the autoincrement register, that is included in the instruction.
As before, indirection is indicated by including the autoincrement register in parentheses. This instruction loads register Ri with the operand whose address is the content of register Rauto. After loading the operand into register Ri , the content of register Rauto is incremented, pointing for example to the next item in a list of items.
This instruction decrements the content of the register Rauto and then uses the new content as the effective address of the operand that is to be loaded into register Ri.
The seven addressing modes presented above are summarized in Table 2. In presenting the different addressing modes we have used the load instruction for illustration. However, it should be understood that there are other types of instructions in a given machine.
In the following section we elaborate on the differ- ent types of instructions that typically constitute the instruction set of a given machine. Data Movement Instructions Data movement instructions are used to move data among the different units of the machine. Most notably among these are instructions that are used to move data among the different registers in the CPU.
The effect of the instruc- tion is to override the contents of the destination register Rj without changing the con- tents of the source register Ri. Data movement instructions include those used to move data to from registers from to memory. These instructions are usually referred to as the load and store instructions, respectively.
The content of the memory location is unchanged by executing the LOAD instruction. Arithmetic and Logical Instructions Arithmetic and logical instructions are those used to perform arithmetic and logical manipulation of registers and memory contents.
The second instruction subtracts the contents of the source registers R1 and R2 and stores the result in the destination register R0. These two instructions are expensive to implement and could be substituted by the use of repeated addition or repeated subtraction.
As the names indicate, these instructions per- form, respectively, and, or, shift, compare, and rotate operations on register or memory contents. Sequencing Instructions Control sequencing instructions are used to change the sequence in which instructions are executed. A common characteristic among these instructions is that their execution changes the program counter PC value. The change made in the PC value can be unconditional, for example, in the unconditional branching or the jump instructions.
Consider, for example, the following group of instructions. It should be noted that conditional branch instructions could be used to exe- cute program loops as shown above. The CALL instructions are used to cause execution of the program to transfer to a subroutine. However, with the CALL instruction the incremented value of the PC to point to the next instruction in sequence is pushed onto the stack.
This has the effect of resuming program execution from the point where branching to the subroutine has occurred. This pro- gram segment sums up a number of values, N, and stores the result into memory location SUM.
The values to be added are stored in N consecutive memory locations starting at NUM. Examples of input devices include a keyboard or a mouse. Input devices are interfaced with a computer through dedicated input ports. Computers can use dedicated addresses to address these ports.
Suppose that the input port through which a keyboard is connected to a computer carries the unique address Similarly, the execution of the instruction OUTPUT causes the data stored in the accumulator to be moved to the data output register in the output device whose address is Alternatively, the com- puter can address these ports in the usual way of addressing memory locations.
This instruction moves the content of the register Rin into the register R0. In presenting these examples, generic mnemonics will be used. This is done in order to emphasize the understanding of how to use different addressing modes in performing different operations independent of the machine used.
Applications of similar principles using real-life machine examples are presented in Chapter 3. Example 1 In this example, we would like to show a program segment that can be used to perform the task of adding numbers stored at consecutive memory loca- tions starting at location The results should be stored in memory location Example 2 In this example autoincrement addressing will be used to perform the same task performed in Example 1.
Note also that the use of the autoincrement addressing in Example 2 has led to a decrease in the number of instructions used to perform the same task. The numbers are originally stored in a list starting at location The sorted values are also stored in the same list and again starting at location We assume that the list is not orig- inally sorted and therefore a brute force search is used. In this search, the value VAL is compared with every element in the list from top to bottom.
The content of register R3 is used to indicate whether VAL was found. Here, we make use of the stack to send the parameters VAL and N. We presented a model of the main memory in which the memory is abstracted as a sequence of cells, each capable of storing n bits.
A number of addressing modes were presented. These include immediate, direct, indirect, indexed, autoincre- ment, and autodecrement. Examples showing how to use these addressing modes were then presented. Our dis- cussion concluded with a presentation of a number of examples showing how to use the principles and concepts discussed in the chapter in programming the solution of a number of sample problems.
In the next chapter, we will introduce the concepts involved in programming the solution of real-life problems using assembly language. Write a program using the addressing modes and the instruction types pre- sented in Sections 2. Assume that the top of the stack in a program is pointed to by the register SP.
You are required to write program segments to perform each of the following tasks assume that only the following addressing modes are available: indexed, autoincrement, and autodecrement. The results should be stored starting at memory location The above operation is to be performed using each of the following instruction classes. Assume that A, B, and C are memory addresses. Repeat Exercise 6 above assuming that the memory used is byte addressable while each score occupies bit.
The scores are stored rowwise, that is, one row after the other. Repeat Exercise 9 above assuming that your job is to write a subroutine to perform the same task as in Exercise 9. Gilmore, Microprocessors: Principles and Applications, 2nd ed. Hamacher, Z. Vranesic, and S. Zaky, Computer Organization, 5th ed. Patterson, J. Wilkinson, Computer Architecture: Design and Performance, 2nd ed. This chapter considers the issues related to assem- bly language programming. Although high-level languages and compiler technol- ogy have witnessed great advances over the years, assembly language remains necessary in some cases.
Programming in assembly can result in machine code that is much smaller and much faster than that generated by a compiler of a high- level language. Small and fast code could be critical in some embedded and portable applications, where resources may be very limited. In such cases, small portions of the program that may be heavily used can be written in assembly language.
For the reader of this book, learning assembly languages and writing assembly code can be extremely helpful in understanding computer organization and architecture.
A computer program can be represented at different levels of abstraction. A machine language program for a given architecture is a collection of machine instructions represented in binary form.
Programs written at any level higher than the machine language must be trans- lated to the binary representation before a computer can execute them. An assembly language program is a symbolic representation of the machine language program.
Machine language is pure binary code, whereas assembly language is a direct map- ping of the binary code onto a symbolic form that is easier for humans to understand and manage. Converting the symbolic representation into machine language is per- formed by a special program called the assembler. An assembler is a program that accepts a symbolic language program source and produces its machine language equivalent target.
In translating a program into binary code, the assembler will replace symbolic addresses by numeric addresses, replace symbolic operation codes by machine operation codes, reserve storage for instructions and data, and translate constants into machine representation. The purpose of this chapter is to give the reader a general overview of assembly language and its programming.
We start the chapter with a discussion of a Fundamentals of Computer Organization and Architecture, by M. We will introduce instruction mnemonics and the syntax and assembler directives and commands. A discussion on the execution of assembly programs is then presented.
Since assembly language is the symbolic form of machine language, each different type of processor has its own unique assembly language. We need to know the memory size and organization, the processor registers, the instruction format, and the entire instruction set. In this section, we present a very simple hypothetical processor, which will be used in explaining the different topics in assembly language throughout the chapter.
The PC contains the address of the next instruction to be executed. The IR contains the operation code portion of the instruction being executed. The AR contains the address portion if any of the instruction being executed. The AC serves as the implicit source and destination of data. The DR is used to hold data. The memory unit is made up of words of storage. The word size is 16 bits. The processor is shown in Figure 3. The data transfer operations are load, store, and move data between the registers AC and DR.
The data processing instructions are add, subtract, and, and not. The program control instructions are jump and conditional jump. The instruction set of our processor is summarized in Table 3. The instruction size is 16 bits, 4 bits for the operation code and 12 bits for the address when appropriate. Example 1 Let us write a machine language program that adds the contents of memory location 12 00C-hex , initialized to and memory location 14 00E-hex , initialized to 96, and store the result in location 16 hex , initialized to 0.
The program is given in binary instructions in Table 3. For example, the contents of location 0 is an instruction with opcode: , and operand address: Please note that in the case of operations that do not require operand, the operand portion of the instruction is shown as zeros. The program is expected to be stored in the indicated memory locations starting at location 0 during execution. Representing the instructions in hexadecimal will reduce the number of digits to only four per instruction.
Table 3. Assembly programs are written with short abbreviations called mnemonics. A mnemonic is an abbrevi- ation that represents the actual machine instruction.
Assembly language program- ming is the writing of machine instructions in mnemonic form, where each machine instruction binary or hex value is replaced by a mnemonic. Clearly the use of mnemonics is more meaningful than that of hex or binary values, which would make programming at this low level easier and more manageable. An assembly program consists of a sequence of assembly statements, where statements are written one per line.
Figure 3. Labels are used to provide symbolic names for memory addresses. It can also be used to access data using symbolic names. Some allow up to 32 characters in length, others may be restricted to six characters.
Assembly languages for some processors require a colon after each label while others do not. The Intel assembly requires colons after code labels but not after data labels.
There is no colon requirement after each label. The simple mnemonics of the ten binary instructions of Table 3. In addition to program instructions, an assembly program may also include pseudo instructions or assembler directives. Assembler directives are commands that are understood by the assembler and do not correspond to actual machine instructions.
For example, the assembler can be asked to allocate memory storage. In our assembly language for the simple processor, we assume that we can use the pseudo instruction W to reserve a word 16 bits in memory. The following is the assembly code of the machine language program of Example 1 in the previous section. As you know, the assembly of the simple CPU does not have a multiplication operation. We will compute the product by applying the add operation multiple times.
In order to add Y to itself X times, we will use N as a counter that is initialized to X and decremented by one after each addition step. The BZ instruction will be used to test for the case when N reaches 0. We will use a memory location to store N but it will need to be loaded into AC before the BZ instruction is executed.
We will also use a memory location ONE to store the constant 1. The following is the assembly program using the assembly language of our simple processor. We will assume that the values of X and Y are small enough to allow their product to be stored in a single word.
For the sake of this example, let us assume that X and Y are initialized to 5 and 15, respectively. We provided several assembly code segments written using our simple machine model. Among these issues are the following:. Assembler directives. Use of symbols. Use of synthetic operations. Assembler syntax. Interaction with the operating system The use of assembler directives, also called pseudo-operations, is an important issue in writing assembly language programs.
Assembler directives are commands that are understood by the assembler and do not correspond to actual machine instruc- tions. Assembler directives affect the way the assembler performs the conversion of assembly code to machine code. For example, special assembler directives can be used to instruct the assembler to place data items such that they have proper align- ment. In assembly language programs symbols are used to represent numbers, for example, immediate data.
This is done to make the code easier to read, understand, and debug. Symbols are translated to their corresponding numerical values by the assembler. The use of synthetic operations helps assembly programmers to use instructions that are not directly supported by the architecture. Assemblers usually impose some conventions in referring to hardware com- ponents such as registers and memory locations. The underlying hardware in some machines cannot be accessed directly by a pro- gram.
Interactions with operating systems OS can take place in the form of a code that causes the execution of a function that is part of the OS. These functions are called system calls. In this section, we will learn how to get from the point of writing an assembly program to the execution phase.
The assembler reads the source program in assembly language and generates the object program in binary form. The object program is passed to the linker. The linker will combine the required procedures from the link library with the object program and produce the executable program. The loader loads the executable program into memory and branches the CPU to the starting address. The program begins execution. Assemblers Assemblers are programs that generate machine code instructions from a source code program written in assembly language.
The assembler will replace symbolic addresses by numeric addresses, replace symbolic operation codes by machine oper- ation codes, reserve storage for instructions and data, and translate constants into machine representation. The functions of the assembler can be performed by scanning the assembly pro- gram and mapping its instructions to their machine code equivalent. A simple assembler scans the entire assembly program twice, where each scan is called a pass.
This table is called the symbol table. During the second pass, the assembler will use the symbol table and other tables to generate the object program, and output some information that will be needed by the linker. Data Structures The assembler uses at least three tables to perform its functions: symbol table, opcode table, and pseudo instruction table. The symbol table, which is generated in pass one, has an entry for every symbol in the program. Associated with each symbol are its binary value and other information.
We assume that the instruction LD X is starting at location 0 in the memory. Since each instruction takes two bytes, the value of the symbol LOOP is 4 in hexadecimal. Symbol N, for example, will be stored at decimal location 40 in hexadecimal. The values of the other symbols can be obtained in a similar way. The opcode table provides information about the operation codes. Associated with each symbolic opcode in the table are its numerical value and other information about its type, its instruction length, and its operands.
As an example, we explain the information associated with the opcode LD. It has one operand, which is a memory address and its binary value is The instruction length of LD is 2 bytes and its type is memory-reference. The entries of the pseudo instruction table are the pseudo instructions symbols.
Each entry refers the assembler to a procedure that processes the pseudo instruction when encountered in the program. For example, if END is encountered, the trans- lation process is terminated. Your email address will not be published. Save my name, email, and website in this browser for the next time I comment. How to Visualize Data with D3 [Video]. How to Visualize Data with R [Video].
This self-contained text devotes one full chapter to the basics of digital logic. Author : V. ISBN: Category: Computers Page: View: Read Now » Designed as an introductory text for the students of computer science, computer applications, electronics engineering and information technology for their first course on the organization and architecture of computers, this accessible, student friendly text gives a clear and in-depth analysis of the basic principles underlying the subject.
What distinguishes the text is the special attention it pays to Cache and Virtual Memory organization, as well as to RISC architecture and the intricacies of pipelining. All these discussions are climaxed by an illuminating discussion on parallel computers which shows how processors are interconnected to create a variety of parallel computers.
An introduction to the nature of computer architecture and organization. Presents interesting problems with elegant solutions, with emphasis on the abstract elements of the problems common to all computer design. Includes many examples of specific machines and the design philosophy behind them. Chalk Publisher: Bloomsbury Publishing ISBN: Category: Computers Page: View: Read Now » This book describes how a computer works and explains how the various hardware components are organized and interconnected to provide a platform upon which programs can be executed.
It takes a simple, step-by-step approach suitable for first year undergraduates coming to the subject for the first time. The second edition of this book has been thoroughly updated to cover new developments in the field and includes new diagrams and end-of-chapter exercises. It will also be accompanied by a lecturer and student web site which will contain solutions to exercises, further exercises, PowerPoint slides and all the source code used in the book.
Important Notice: Media content referenced within the product description or the product text may not be available in the ebook version. This text was developed to serve as an introduction to computing systems.
Author : Arthur B. Author : Ivan Tomek Publisher: W.
0コメント