University of Buckingham Introduction to Computer Systems Lecture 5 PDF
Document Details
Uploaded by ErrFreeCornet
The University of Buckingham
Tags
Summary
These lecture notes from the University of Buckingham introduce computer systems and focus on instruction set architecture. Topics include CPU components, registers, instruction cycles, and addressing modes. The document also discusses different types of computer instructions and instruction sets.
Full Transcript
Introduction to Computer Systems Lecture 5: Instruction Set Architecture Instruction Set Architecture – Lecture 5 Topics to be covered in this lecture: Components and functions of the CPU Registers in the CPU Computer instruction cycle – Computer Instructions – The Fetch/Execute...
Introduction to Computer Systems Lecture 5: Instruction Set Architecture Instruction Set Architecture – Lecture 5 Topics to be covered in this lecture: Components and functions of the CPU Registers in the CPU Computer instruction cycle – Computer Instructions – The Fetch/Execute Cycle Computer instruction set – Format of Instructions – Addressing Modes Von Neumann architecture Referring to a 1945 computer architecture by John von Neumann (a mathematician and computer scientist) He described a design architecture for an electronic digital computer with – a processing unit consisting of an arithmetic logic unit, processor registers – a control unit containing an instruction register and program counter, – a memory unit to store both data and instructions (Stored program) – external mass storage, and input and output mechanisms Von Neumann architecture Things you need to remember about “Stored program" computer – The most fundamental characteristic of the Von Neumann architecture – Instructions are a sequence of machine language – Both data and instruction in the same memory Processor and Memory Memory The memory unit has been divided into five parts: – program - sequence of instructions to calculate the area of a circle – constants - 𝝅, numbers used by the program, which do not change during program execution – variables - numbers created and modified by the program – input and output - read information from input devices, write information to output devices Three regions are read-only, one is write-only, one can be read from and written to Processor, Memory and Buses Registers and Memory A register is a storage device exactly like a memory location. In principle, registers and memory do the same thing However, registers are located within the CPU and are much faster to access than memory There are few registers in a computer and millions of memory locations The Motorola 68K has eight data registers and eight address registers You need 32 bits to select one out of 232 possible memory locations Some registers are visible to the programmer, some are invisible General-purpose digital computer The processor The BRAIN of the computer Three main capabilities: – Read and write information in memory – Recognise and execute a series of program commands – Tells other parts of the computer what to do Also called the Central Processing Unit or CPU Contains the arithmetic/logic unit, the control unit and registers The ALU The ALU is a subsystem within the CPU Performs addition, subtraction, and comparison for equality Components – Registers, interconnections between components, and the ALU circuitry. – Together, these components are called data path Register – Storage cell that holds the operands of an arithmetic operation and holds its result Bus – Path for electrical signals Muti-Register ALU Organization Overall ALU Organization The Control Unit The control unit 1. Fetch from memory the next instruction to execute 2. Decode the fetched instruction to determine what is to be done 3. Execute the instruction by issuing the appropriate command to the ALU, memory or I/O controllers 4. Repeat the above steps until the last instruction (e.g. HALT, STOP or QUIT) Control Unit Registers PC - Program Counter (holds the address of the next memory to be accessed) IR - Instruction Register (holds the current instruction being executed) Computer instructions Instructions are used to manipulate values and addresses to perform a task These instructions are loaded to the computer memory In machine code, each instruction has a unique bit pattern For human consumption a symbolic representation is used (LOAD, STORE, ADD, SUB) A computer has a small set of instructions that can be decoded and executed by its control unit A sequence of related instructions that performs a specific task is known as a computer PROGRAM Computer instruction format A computer instruction contains a number of elements Operation code (Opcode): Specifies the operation to be performed (e.g. LOAD, ADD) Source operand reference: The operation may involve one or more operands as inputs Result operand reference: The operation may produce a result Next instruction reference: Tells the computer where to fetch the next instruction from Computer instruction set (CISC vs RISC) Complex instruction set computers (CISC machines) – Large number of powerful multi-clock instructions – "LOAD" and "STORE“ are incorporated in instruction – Uses a small number of registers – Most common microprocessor chips (e.g. Pentium) – Emphasis on hardware – Higher power consumption Computer instruction set (CISC vs RISC) Reduced instruction set computers or RISC machines – Include a limited and simple single-clock instruction set – Faster execution of individual instructions – "LOAD" and "STORE“ are independent instructions – Includes a large number of general-purpose registers – E.g ARM - Advanced RISC Machines (processer of all iPhones, iPads, Sam Galaxy Si , Sam Tab,.. etc) – Emphasis on software – Lower power consumption Computer instruction cycle Fetch Cycle 1. Program Counter (PC) holds address of next instruction to be fetched 2. Processor fetches instruction from memory location pointed to by PC 3. Increment PC – Unless told otherwise 4. Instruction loaded into Instruction Register (IR) 5. Processor interprets (decode) instruction and performs required actions Execute cycle There are 5 types (depending on the instruction) Processor-memory – Data transfer between CPU and main memory Processor I/O – Data transfer between CPU and I/O module Data processing – Some arithmetic or logical operation on data Control – Alteration of sequence of operations (e.g. jump) Combination of above Computer instruction cycle opCode: 1= Load 2= Store 5= Add Types of instructions Data storage – LOAD X, STORE X, MOVE X,Y Arithmetic & Logic – ADD X,Y,Z (ADD X,Y), ADD X, (SUBTRACT, MULTIPLY, DIVIDE, AND and OR) Compare (Decision making) – COMPARE X,Y sets the condition codes (GT, EQ, LT) Branch – JUMP X, JUMPGT X, JUMPEQ X, JUMPLT X, JUMPGE X, JUMPLE X, JUMPNEQ X, HALT Input and Output (data movement) – IN, OUT Fundamental design issues Some of the fundamental design issues relating to ISs are: Operation set: How many operations should be provided? Which operations and how complex should they be? Data types: The types of data upon which the operations are performed (addresses, numbers, characters, logical data) Instruction format: Instruction length (how many bits?), number of addresses, the size of each field Registers: The number of processor registers that can be referenced Addressing: The mode(s) of addressing operands Number of addresses Instruction formats can take zero, one, two or three operands Arithmetic and logic operations require the most operands. – They are either unary (one source operand), or binary (two source operands) – A third address may be used to store the result of an operation We will use the example Y = (A − B)/[C + (D × E)] to look at three, two, one and zero address formats Three address machines Operation, destination, source 1, source 2 a=b+c May be a fourth - next instruction (usually implicit) Not common; needs very long words to hold everything Three address instruction format Two address machines Operation, source 1, source 2 a=a+b Reduces length of instruction Requires some extra work One address machines Implicit second address Usually a register (accumulator) Common on early machines Zero address machines All addresses implicit Uses a stack e.g. c = a + b – push a – push b – add pop c How many addresses? More addresses – More complex (powerful?) instructions – More registers (inter-register operations are quicker) – Fewer instructions per program (easier for the programmer) Fewer addresses – Less complex (powerful?) instructions – More instructions per program – Faster fetch/execution of instructions Addressing modes The most common addressing techniques are: – Immediate addressing – Direct (absolute) addressing – Indirect addressing – Register addressing – Register indirect addressing – Stack addressing Immediate addressing Operand is part of instruction Operand = address field e.g. ADD 12 – Add the value 12 to contents of accumulator – 12 is operand No memory reference to fetch data – Fast – Limited range (restricted to the size of the address field) Direct (absolute) addressing Address field contains address of operand Effective address (EA) = address field (A) e.g. ADD 2000 (Add contents of cell with address 2000 to the accumulator) Single memory reference to access data No additional calculations to work out effective address Indirect addressing Memory cell pointed to by address field contains the address of (pointer to) the operand EA = (A) look in A, find a pointer, follow it to look for operand e.g. ADD (A) : Add contents of cell pointed to by contents of A to accumulator Multiple memory accesses to find operand (hence slower than the previous techniques) Register addressing Operand is held in register named in address filed EA = R Example: ADD R, where R is a register Limited number of registers Very small address field needed – Shorter instructions and faster instruction fetch Register indirect addressing Indirect addressing EA = (R): Operand is in memory cell pointed to by contents of register R ADD (R): Add the contents of the memory location by following a pointer which is stored at an address pointed to by register R Stack addressing Operand is (implicitly) on top of stack e.g. – ADD Pop top two items from stack and add Summary Introduced to the components and functions of the ALU, Control Unit and Registers Explained the Fetch, Decode and Execute cycle Introduced to machine instructions, instruction formats and addressing modes Example instruction set There are many issues to consider when designing an instruction set Further reading A. Clements, Principles of Computer Hardware. – Chapter 5 (pp. 203-217). G. M. Schneider & J. L. Gersting, Invitation to Computer Science. – Chapter 5 (pp.207–232). W. Stallings, Computer Organization and Architecture - Designing for Performance. – Chapter 10 (pp.367–376). – Chapter 11 (pp.419–426).