CHAPTER 10 INSTRUCTION SETS
CHAPTER 10 INSTRUCTION SETS. CSNB123 coMPUTER oRGANIZATION. Expected Course Outcome. Architecture. Recap Chapter 1. Attributes visible to the programmer Instruction set Number of bits used for data representation I/O mechanisms Addressing techniques. Machine Instruction Characteristics.
CHAPTER 10 INSTRUCTION SETS
E N D
Presentation Transcript
CHAPTER 10 INSTRUCTION SETS CSNB123 coMPUTERoRGANIZATION Systems and Networking
Expected Course Outcome Systems and Networking
Architecture Recap Chapter 1 • Attributes visible to the programmer • Instruction set • Number of bits used for data representation • I/O mechanisms • Addressing techniques Systems and Networking
Machine Instruction Characteristics • Each instruction must contain the information required by the processor for execution Systems and Networking
Machine Instruction Characteristics (Cont.) • Elements of Machine Instruction (MI) Systems and Networking
Simple Instruction Format • Instruction is represented by a sequence of bits • 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 • Opcodes are presented by abbreviations-mnemonics-that indicate the operation ..why do this …hard to remember code in binary form Systems and Networking
Simple Instruction Format (Cont.) • Operands also represented symbolically • Example: • Add the value contained in the location Y to the contents of register R • Y=refer to the address of a location in memory • R=refers to a particular register ADD R,Y Systems and Networking
Instruction Types • HLL language instruction in BASIC • Instruct the computer to add the value stored in Y to the value stored in X and put the result in X. X=513, Y=514 X=X + Y Systems and Networking
Instruction Types (Cont.) X=513, Y=514 X=X + Y Simple instruction sets • Load a register with the contents of memory location 513 • Add the contents of memory location 514 to the register • Store the contents of the register in memory location 513 Systems and Networking
Instruction Types (Cont.) Systems and Networking
Number of Address • Address refer to location that store the value of the operands • In most architecture, most instructions have 1,2 or 3 operand addresses Systems and Networking
Example Y=(A-B)/[C+(DXE)] Systems and Networking
3 address instructions • Each instruction specifies two source operand locations and a destination operation location • Operand 1, Operand 2, Result • Not common since they require a relatively long instructions format to hold the three address references • T = temporary location-to store intermediary result Systems and Networking
Example Y=(A-B)/[C+(DXE)] Systems and Networking
2 address instructions • Each instruction specifies both an operand and the result location • Operand 1, Operand 2, Result • MOVE – is used to move one of the values to a result/temp loc before performing the operation • Reduce space for address Systems and Networking
Example Y=(A-B)/[C+(DXE)] Systems and Networking
1address instructions • Second address must be implicit (hidden) • Common in earlier machines- the implied address being a processor register known as the accumulator (AC) • The AC contains one of the operands and is used to store the result Systems and Networking
Example Y=(A-B)/[C+(DXE)] Systems and Networking
0 address instructions • All address must be implicit (hidden) • Stack-based operations • last-in-first-out (LIFO) set of locations • Interact with the stack using PUSH and POP operations • PUSH – to push a data from memory onto the stack • POP – to pop out data from the stack to a memory location Systems and Networking
Example Y=(A-B)/[C+(DXE)] D B C C A A A A A PUSH B PUSH A SUB PUSH D PUSH C E D D C C C PUSH E ADD DIV A A MPY A A POP Systems and Networking
Number of Address (Cont.) • Fewer address • require less complex processor • Instruction become shorter • But contain more total instructions-longer execution time Systems and Networking
Number of Address (Cont.) • Multiple address instructions – have multiple general purpose register • Register references are faster than memory references – speed up the execution • Most contemporary machine employ a mixture of 2 and 3 address instructions Systems and Networking
Types of Operands • Categories of data • Addresses • Numbers • Integer/floating point • Characters • ASCII etc. • Logical data • 0/1-false/true Systems and Networking
Types of Operations • Data transfer • Arithmetic • Logical • Conversion • I/O • Transfer of control Refer to Table 9.3 Systems and Networking
Types of Operations (Cont.) Systems and Networking
Types of Operations (Cont.) Systems and Networking
Control Operations • Branch/jump instruction • Sequential • Unconditional branch • Conditional branch • Skip • Subroutine / procedure call Systems and Networking
Control Operations - Branch • Has one of its operands the address of the next instruction to be executed • A sequence of code in a computer program which is conditionally executed depending on whether the flow of control is altered or not (at the branching point) • Conditional – the branch is made only if a certain condition is met • Unconditional – a branch instruction in which the branch is always taken Systems and Networking
Control Operations - Branch (Cont.) Systems and Networking
Control Operations - Skip • Useful in loop control • Implies that next instruction to be skipped Systems and Networking
Control Operations – Subroutine • Also known as procedure call • A self-contained computer program that is incorporated into a larger program • At any point in the program, the procedure may be called or invoked • The processor is instructed to go and execute the entire procedure and then return to the point from which the call took place • A procedure allow the same piece of code to be used many times • Involves two basic instructions; call and return instruction Systems and Networking
Control Operations – Subroutine (Cont.) Call instruction Return instruction Instruction that returns from the procedure to the place from which it was called • Instructions that branches from the present location to the procedure Systems and Networking
Control Operations – Subroutine (Cont.) Systems and Networking
Additional Reference • William Stallings, Computer Organization and Architecture: Designing for Performance, 8th. Edition, Prentice-Hall Inc., 2010 Systems and Networking
This teaching material is belongs to Systems and Networking Department College of Information Technology UniversitiTenagaNasional (UNITEN) Malaysia 2014 Systems and Networking