Document Details

IncredibleEpic

Uploaded by IncredibleEpic

SRM Institute of Science and Technology

Tags

computer architecture functional units computer hardware digital electronics

Summary

This document provides an overview of computer fundamentals, focusing on the functional units of a computer. It details the input unit, memory unit, arithmetic and logic unit, output unit, and control unit, and explains how these interact to process information. The document also covers different addressing modes and machine instructions.

Full Transcript

UNIT III COMPUTER FUNDAMENTALS Functional Units of a Digital Computer: Von Neumann Architecture – Operation and Operands of Computer Hardware Instruction – Instruction Set Architecture (ISA): Memory Location, Address and Operation – Instruction and Instruction Sequencing – Addressing Mod...

UNIT III COMPUTER FUNDAMENTALS Functional Units of a Digital Computer: Von Neumann Architecture – Operation and Operands of Computer Hardware Instruction – Instruction Set Architecture (ISA): Memory Location, Address and Operation – Instruction and Instruction Sequencing – Addressing Modes, Encoding of Machine Instruction – Interaction between Assembly and High Level Language. **************************************************************************** FUNCTIONAL UNITS A computer consists of five functionally independent main parts: 1. Input unit, 2. Memory unit , 3. Arithmetic and logic unit , 4. Output unit , and 5. Control Unit Basic functional units of a computer  The Input Unit accepts coded information from human operators using devices such as keyboards or from other computers over digital communication lines.  The information received is stored in the computer’s memory, either for later use or to be processed immediately by the Arithmetic and Logic Unit.  The processing steps are specified by a program that is also stored in the Memory.  The results are sent back to the outside world through the Output Unit.  All of these actions are coordinated by the Control Unit.  An Interconnection Network provides the means for the functional units to exchange information and coordinate their actions.  Input and output equipment is referred to as the Input-Output (I/O) Unit. 1. INPUT UNIT  Computers accept coded information through input units. The most common input device is the keyboard.  Whenever a key is pressed, the corresponding letter or digit is automatically translated into its corresponding binary code and transmitted to the processor.  The other kinds of input devices for human-computer interaction are available, including the touchpad, mouse, joystick, and trackball. These are often used as graphic input devices in conjunction with displays.  Microphones can be used to capture audio input which is then sampled and converted into digital codes for storage and processing.  Cameras can be used to capture video input.  Digital communication facilities, such as the Internet, can also provide input to a computer from other computers and database servers. 2. MEMORY UNIT  The function of the memory unit is to store programs and data. There are two classes of storage, called Primary and Secondary. Primary Memory  Primary memory, also called main memory, is a fast memory that operates at electronic speeds. Programs must be stored in this memory while they are being executed.  The memory consists of a large number of semiconductor storage cells, each capable of storing one bit of information.  They are handled in groups of fixed size called words.  The number of bits in each word is referred to as the word length of the computer, typically 16, 32, or 64 bits.  To provide easy access to any word in the memory, a distinct address is associated with each word location.  Addresses are consecutive numbers, starting from 0, that identify successive locations.  A particular word is accessed by specifying its address and issuing a control command to the memory that starts the storage or retrieval process.  Instructions and data can be written into or read from the memory under the control of the processor.  A memory in which any location can be accessed in a short and fixed amount of time after specifying its address is called a random-access memory (RAM).  The time required to access one word is called the memory access time.  This time is independent of the location of the word being accessed. It typically ranges from a few nanoseconds (ns) to about 100 ns for current RAM units. Cache memory  Along with the main memory, a smaller, faster RAM unit, called a cache, is used to hold sections of a program that are currently being executed, along with any associated data.  The cache is tightly coupled with the processor and is usually contained on the same integrated-circuit chip. The purpose of the cache is to facilitate high instruction execution rates. Secondary Storage  Secondary storage is used when large amounts of data and many programs have to be stored, particularly for information that is accessed infrequently.  Access times for secondary storage are longer than for primary memory.  Example: o Magnetic disks, o Optical disks (DVD and CD), and o Flash memory devices. 3. ARITHMETIC AND LOGIC UNIT  Most computer operations are executed in the arithmetic and logic unit (ALU) of the processor.  Any arithmetic or logic operation, such as addition, subtraction, multiplication, division, or comparison of numbers is performed by the ALU. Example: If two numbers located in the memory are to be added, they are brought into the processor, and the addition is carried out by the ALU. The sum may then be stored in the memory or retained in the processor for immediate use.  When operands are brought into the processor, they are stored in high-speed storage elements called registers. Each register can store one word of data. 4. OUTPUT UNIT  The output unit function is to send processed results to the outside world. Examples: o Printers o Graphic Displays 5. CONTROL UNIT  The memory, arithmetic and logic, and I/O units store and process information and perform input and output operations. The operation of these units must be coordinated in some way. This is the responsibility of the control unit.  The control unit is used to send control signals to other units.  I/O transfers, consisting of input and output operations, are controlled by program instructions that identify the devices involved and the information to be transferred.  Control circuits are responsible for generating the timing signals that govern the transfers and determine when a given action is to take place.  Data transfers between the processor and the memory are also managed by the control unit through timing signals. OPERATIONS OF COMPUTER HARDWARE INSTRUCTION OPERANDS OF COMPUTER HARDWARE INSTRUCTION Machine instructions operate on data. The most important general categories of data are : Addresses Numbers Characters Logical data Address: The addresses are in fact a form of data. In many situations, some calculation must be performed on the operand reference in an instruction; some calculation must be performed on the operand reference in an instruction to determine physical address. Numbers: All computers support numeric data types. The common numeric data types are: Integers Floating Point Decimal Characters: For documentation a common form is text or character Strings. Most of the computers use ASCII code for character Represented by a unique 7-bit pattern, Logic Data: Most of the processor interpret data as bit ,byte ,word or double these are referred to as units of data. When a data is viewed as n 1-bit items of data each item having the value 0 or 1 it is considered as logical data. INSTRUCTIONS AND INSTRUCTION SEQUENCING INSTRUCTION The words of a computer's language are called instructions, and its vocabulary is called an instruction set. Instruction Set The vocabulary of commands understood by a given architecture. A computer must have instructions capable of performing four types of operations:  Data transfers between the memory and the processor registers  Arithmetic and logic operations on data  Program sequencing and control  I/O transfers The two basic types of notations used are: 1. Register Transfer Notation 2. Assembly Language Notation Register Transfer Notation The transfer of information from one location in the computer to another location such as transfer between memory locations, processor registers, or registers in the I/O subsystem involves Register Transfer Notation. A location is represented by a symbolic name standing for its hardware binary address. Example: 1 The names for the addresses of memory locations may be LOC, PLACE, A, VAR2; Processor register names may be R0, R5; and I/O register names may be DATAIN, OUTSTATUS, and so on. The contents of a location are denoted by placing square brackets around the name of the location. The expression is, R1 ← [LOC] means that the contents of memory location LOC are transferred into processor register R1. Example: 2 Consider the operation that adds the contents of registers R1 and R2, and then places their sum into register R3. It is indicated as, R3 ← [R1] + [R2] This type of notation is known as Register Transfer Notation (RTN). Assembly Language Notation This type of notation to represent machine instructions and programs uses an assembly language format. Example: 1 Consider an instruction that causes the transfer from memory location LOC to processor register R1, is specified by the statement, Move LOC, R1 The contents of LOC are unchanged by the execution of this instruction, but the old contents of register R1 are overwritten. Example: 2 Adding two numbers contained in processor registers R1 and R2 and placing their sum in R3 can be specified by the assembly language statement, Add R1, R2, R3 BASIC INSTRUCTION TYPES The instruction types are generally classified in to:  Three-address instruction  Two-address instruction  One-address instruction  Zero-address instruction 1. Three-Address Instructions The three-address instruction contains the memory addresses of the three operands— A, B, and C. A general instruction of three-address type has the format: Operation Source1, Source2, Destination This three-address instruction can be represented symbolically as Add A, B, C Operands A and B are called the source operands C is called the destination operand Add is the operation to be performed on the operands. 2. Two-Address Instructions In a two-address instructions, each instruction having only one or two operands. A general instruction of two-address type has the format: Operation Source, Destination Example An Add instruction of this type is Add A, B performs the operation B← [A] + [B]. When the sum is calculated, the result is sent to the memory and stored in location B, replacing the original contents of this location. This means that operand B is both a source and a destination. 3. One- Address Instructions A machine instruction that specify only one memory operand is called one-address instruction. When a second operand is needed, it is understood implicitly to be in a unique location. A processor register, usually called the accumulator, may be used for this purpose. The access to data in these registers is much faster than to data stored in memory locations because registers are inside the processor. Example 1: Consider the instruction, Add A It adds the contents of memory location A to the contents of the accumulator register and place the sum back into the accumulator. Example 2: Consider the one-address instructions, Load A Store A The Load instruction copies the contents of memory location A into the accumulator, and The Store instruction copies the contents of the accumulator into memory location A. Using only one-address instructions, the operation C←[A]+[B] can be performed by executing the sequence of instructions, Load A Add B Store C In the Load instruction, address A specifies the source operand, and the destination location, the accumulator, is implied. On the other hand, C denotes the destination location in the Store instruction, whereas the source, the accumulator, is implied. 3. Zero-Address Instructions It is also possible to use instructions in which the locations of all operands are defined implicitly. Such instructions are found in machines that store operands in a structure called a pushdown stack. These instructions are called zero-address instructions. Example: Stack operation: PUSH, POP, and PEEK Instruction Format Example: Write a program to evaluate the arithmetic statement Y = (A+B)*(C+D) using three- address, two-address, one-address and zero-address instructions. Solution: Using Three-address instructions: ADD R1, A, B; ADD R2, C, D; MUL Y, R1, R2; Using Two-address instructions: MOV R1, A; ADD R1, B; MOV R2, C; ADD R2, D; MUL R1, R2; MOV Y, R1; Using One-address instructions: LOAD A; ADD B; STORE T; LOAD C; ADD D; MUL T; STORE Y; Using Zero-address instructions: PUSH A; PUSH B; ADD PUSH C; PUSH D; ADD; MUL; POP Y; ADDRESSING MODES ENCODING OF MACHINE INSTRUCTION The form in which we have presented the instructions is indicative of the form used in assembly languages, except that we tried to avoid using acronyms for the various operations, which are awkward to memorize and are likely to be specific to a particular commercial processor. To be executed in a processor, an instruction must be encoded in a compact binary pattern. Such encoded instructions are properly referred to as machine instructions. The instructions that use symbolic names and acronyms are called assembly language instructions, which are converted into the machine instructions using the assembler program Instructions perform operations such as add, subtract, move, shift, rotate, and branch. These instructions may use operands of different sizes, such as 32-bit and 8-bit numbers or 8-bit ASCII-encoded characters. The type of operation that is to be performed and the type of operands used may be specified using an encoded binary pattern referred to as the OP code for the given instruction. Suppose that 8 bits are allocated for this purpose, giving 256 possibilities for specifying different instructions. This leaves 24 bits to specify the rest of the required information. Add R1, R2 Instruction specify the registers R1 and R2, in addition to the OP code. If the processor has 16 registers, then four bits are needed to identify each register. Additional bits are needed toindicate that the Register addressing mode is used for each operand. Move 24(R0), R5 Requires 16 bits to denote the OP code and the two registers, and some bits to express that the source operand uses the Index addressing mode and that the index value is 24. The instructions can be encoded in a 32-bit word. Depicts a possible format. There is an 8-bit Op-code field and two 7-bit fields for specifying the source and destination operands. The 7-bit field identifies the addressing mode and the register involved (if any). The ―Other info‖ field allows us to specify the additional information that may be needed, such as an index value or an immediate operand. One-word instruction Opcode Source Dest Other info (a) Two-Word instruction Opcode Source Dest Other info Memory address/Immediate operand (c ) Three-operand instruction Op code Ri Rj Rk Other info Requires 18 bits to denote the OP code, the addressing modes, and the register. This leaves 14 bits to express the address that corresponds to LOC, which is clearly insufficient. And #$FF000000. R2 In which case the second word gives a full 32-bit immediate operand. If we want to allow an instruction in which two operands can be specified usingthe Absolute addressing mode, for example Move LOC1, LOC2 Then it becomes necessary to use tow additional words for the 32-bit addresses ofthe operands. This approach results in instructions of variable length, dependent on the number of operands and the type of addressing modes used. Move (R3), R1AddR1, R2 If the Add instruction only has to specify the two registers, it will need just a portion of a 32-bit word. So, we may provide a more powerful instruction that uses three operands Add R1, R2, R3 Which performs the operation R3 8 [R1] + [R2] A possible format for such an instruction in shown in fig c. Of course, the processor has to be able to deal with such three-operand instructions. In an instruction set where all arithmetic and logical operations use only register operands, the only memory references are made to load/store the operands into/from the processor registers. INERACTION BETWEEN ASSEMBLYAND HIGH LEVEL LANGUAGE Definition of assembly language: A low-level programming language which uses symbols and lack variables and functions and which work directly with CPU. Assembly language is coded differently for every type of processor. X86 and x64 processors have a different code of assembly language for performing the same tasks. Assembly language has the same commands as machine language but instead of 0 and 1, it uses names. Definition of high-level language: A high-level language is a human-friendly language which uses variables and functions and it is independent of computer architecture. The programmer writes code with general purpose without worrying about hardware integration part. A program written in high-level language needs to be first interpreted into machine code and then processed by a computer. Assembly language vs high-level language 1. In assembly language programs written for one processor will not run on another type of processor. In high-level language programs run independently of processor type. 2. Performance and accuracy of assembly language code are better than a high-level. 3. High-level languages have to give extra instructions to run code on the computer. 4. Code of assembly language is difficult to understand and debug than a high-level. 5. One or two statements of high-level language expand into many assembly language codes. 6. Assembly language can communicate better than a high-level Some type of hardware actions can only be performed by assembly language. 7. In assembly language, we can directly read pointers at a physical address which is not possible in high-level 8. Working with bits is easier in assembly language. 9. Assembler is used to translate code in assembly language while the compiler is used to compile code in the high-level. 10. The executable code of high-level language is larger than assembly language code so it takes a longer time to execute. 11. Due to long executable code, high-level programs are less efficient than assembly language programs. 12. High-level language programmer does not need to know details about hardware like registers in the processor as compared to assembly programmers. 13. The most high-level language code is first automatically converted into assembly code. Examples of assembly language: Assembly languages are different for every processor. Some of assembly languages examples are below.  ARM  MIPS  x86  Z80  68000  6502  6510 Examples of high-level language:  C  Fortran  Lisp  Prolog  Pascal  Cobol  Basic  Algol  Ada  C++  C#  PHP  Perl  Ruby  Common Lisp  Python  Golang  Javascript  Pharo ASSEMBLY LEVEL LANGUAGE HIGH LEVEL LANGUAGE  It need an assembler for  It needs an compiler/interpreter for conversion conversion  In this we convert a Assembly  In this we convert a high level language to level language to machine level Assembly level language to machine level language language  It is machine dependent  It is machine independent  In this english statement is used  In this mnemonics codes are used  It supports low level operation  It does not support low level language  In this it is easy to access  In this it is difficult to access hardware hardware component component  In this more compact code  No compactness

Use Quizgecko on...
Browser
Browser