2Machine Instruction Characteristics Machine Instructions- are instructions executed by the processor.Instruction set- a collection of instructions that the processor can execute
3Elements of a machine instruction Opcode- uses a binary code which specifies the operation to be preformed.Source operand reference- the input for the operationResult operand reference- the result produced by the operationNext instruction reference- tells the processor where to get the next instruction
4Source and result operands can be found in Main or virtual memoryProcessor register- contains registers that can be used by machine instructionsImmediate- the operand value is being contained when the instruction is being executedI/O devices- instruction specifies I/O module and device but if memory mapped then just another main or virtual memory address
5Representation of instruction OPCODE (4 Bits)Ref to Operand (6 Bits)Ref to Operand 2(6 Bits)An instruction format is used to define the layout of the bits allocated to these elements of instructions.The instruction format explicitly or implicitly indicates the addressing Modes used for each operand in that instruction.
6Instruction format Instruction length: - The longer instruction length gives:More OpcodesMore operandsMore addressing modesGreater address range.
7Factors considered for instruction length Memory Size.Memory organization.Bus structureProcessor speedProcessor complexity.
8Allocation of Bits for different fields in an instruction Number of addressing modes.Number of operands.Register versus memory.Number of register sets.Address range.Address granularity.
9Variable length instructions Advantages: -Provides flexibility in addressing modes.Provides complex addressing modes.Reduces number of instruction fetch cycles.Reduces amount of space taken by a program.Disadvantages: -Requires more complex CPU.Decoding of instruction becomes difficult.
10Instruction Sets Instruction Characteristics Types of Operands Types of Operations
11Instruction Representation Are represented by a sequence of bitsIt is common to use “symbolic representation” of machine instructionsOp codes and operands are represented by abbreviations called “mnemonics”
12Mnemonics ADD add SUB subtract MUL multiply DIV divide LOAD load data from memorySTOR store data to memory
13Instruction types Data processing- arithmetic and logic instructions Data storage- moving data into or out of register or memory locationsData movement- I/O instructionsControl- test and branch instructions
14Number of AddressesA traditional way of describing processor architectureWhat is the maximum number of addresses one might need in an instruction?An instruction could be required to contain four addresses
15Number of Addresses 3 addresses instructions Operand 1, Operand 2, Resulta = b + c;May be a forth - next instruction (usually implicit)Not commonNeeds very long words to hold everything
16Number of Addresses 2 addresses instructions One address doubles as operand and resulta = a + b;Reduces length of instructionRequires some extra workTemporary storage to hold some results
17Number of Addresses 1 address instructions Implicit second address Usually a register (accumulator)Common on early machinesE.g. ADD B
18Number of Addresses Zero address instruction: Special memory organizationLast in first out (Stack)Stack is a known locationE.g. CMA
19Utilization of Instruction Addresses (Nonbranching Instructions) Number of AddressesUtilization of Instruction Addresses (Nonbranching Instructions)
20Number of Addresses 1 address instructions 2 Or 3 address instructions One general purpose registerMultiple general purpose registers
21Instruction Set Design Operation Repertoire- How many and which operations to provide, and how complex the operations should be.Data Types- The various types of data upon which operations are performed.Instruction Format- Instruction length (in bits), number of addresses and size of fields.
22Instruction Set Design Registers- Number of processor registers that can be referenced by instructions, and their useAddressing- The mode or modes by which the address of an operand is specified.
24TYPES OF OPERANDS Addresses Numbers Characters Logical Data Specialized Data TypesData StructuresFirst 4 are the most important general categories of dataLast 2: Ex: list or string of characters
25Addresses Main or Virtual memory address Unsigned Integers By calculating on the operand reference we can determine the main or Virtual memory address. This can be considered an unsigned integer and therefore data.
26Numbers All machine languages include numeric types Non-numeric processing: counters, field widths, etcNumbers in a machine are limited by magnitude and precisionConsequences: rounding, overflow, underflow
27Numerical Data Binary integer or Binary fixed point Binary floating pointDecimal
28Decimal Majority of users deal with decimals Necessity to convert from decimal to binary on input and binary to decimal on outputPacked decimal
29Packed DecimalUsed when there is a great deal of I/O and simple computationEach decimal digit is represented by a 4-bit code. Ex: 0 = 0000, 1 = 0001Numbers are formed by a string of 4-bit codes usually in multiples of 8-bit246 =Positive: 1100Negative: 1101Clearly less compact than a straight binary representationNegative numbers can be represented by putting a 4-bit sign digit at either left or right end of a string
30Characters Text or character strings Represented by a sequence of bits Morse CodeInternational Reference Alphabet (IRA)American Standard Code for Information Interchange (ASCII)Extended Binary Coded Decimal Interchange Code (EBCDIC)Data processing and Communication SystemsEach character is represented in a 7-bit pattern. Thus, 128 characters can be represented. Some of these are control characters maybe for printing and whatnotTransmitted using 8-bit per characters. 8th bit may be a 0 or used as parity error checkEBCDIC: IBM mainframes, 8-bit code, compatible with packed decimals as well
31Logical DataConsider n-bit unit as consisting of n 1-bit items of data, each having a value of 0 or 1Advantages:Store array of Boolean or Binary data itemsManipulating bits of data itemsEx: Convert from IRA to packed decimals (only need the first four bits), Floating point Operations (you might want to round)
32Types of Operations Data Transfer Arithmetic Logical Conversion Input/outputSystem ControlTransfer of Control
33Data Transfer Operation Name Description Move(Transfer) Store Load (Fetch)ExchangeClear ( Reset)SetPushPopTransfer word from source to destinationFrom processor to memoryFrom memory to processorSwap contents of source and destinationTransfer 0s to destinationTransfer 1s to destinationWord from source to top of stackFrom top of stack to destination
34Arithmetic Operation Name Description Add Subtract Multiply Divide AbsoluteNegateIncrementDecrementCompute sum of two operandsDifference of two operandsProduct of two operandsQuotient of two operandsReplace by its absolute valueChange signAdd 1 to operandSubtract 1 to operand
35Logical Operation Name Description AND; OR; NOT; OR Test Compare Set Control VariablesShiftVariablesPerform the specified logical operation bitwiseTest specified condition; set flags based on outcomeMake logical and arithmetic comparison of two operandsClass of instructions to set controls for protection purposes, interrupt handling, timer control.Left/right operand introducing constants at end.Left/right with wraparound end
36Conversion Operation Name Description Translate Convert Translate values in a section of memory based on a table of correspondencesConvert the contents of a word from one form to another. E.g(packed decimal to binary
37I/O Operation Name Description Input (Read) Output ( Write) Start I/O End I/OTransfer data from specified I/O port or device to destinationFrom specified source to I/O port or deviceTransfer instructions to I/O processor to initiate I/O operationTransfer status info from I/O system to specified destination
38System Of ControlCan be executed only while the processor is in a certain privileged state or is executing a program in a special privileged area of memory.These instructions, are reserved for the use of the operating system.Examples:A system control instruction may read or alter a control registerAn instruction to read or modify a storage protection keyAccess to process control blocks in multiprogramming system
39Transfer Of Control Description Operation Name Jump (Branch) Unconditional Transfer: load PC with specified addressTest condition: either load PC with specified address or do nothing.Place current program control info in known location; jump to specified addressReplace contents of PC and other register from known locationFetch operand from location and execute as instructedIncrement PC to skip next instructionEither skip or do nothing based on conditionStop program executionTest specified repeatedly and resume conditionNo operation is performed; but program execution is continued.Jump (Branch)Jump ConditionalJump to SubroutineReturnExecuteSkipSkip conditionalHaltWait (Hold)No Operation
40QUESTIONS How many different address designs are there? Name two types of operations.What are the most general categories of data?What type of endian mode does x86 use?What are the most used Character Codes nowadays?What are the elements of machine instruction?What are the advantages of Logical Data?