Unformatted text preview:

1EE 4504 Section 7 1EE 4504Computer OrganizationSection 7The Instruction SetEE 4504 Section 7 2OverviewMuch of the computer’s architecture /organization is hidden from a HLLprogrammer– In the abstract sense, the programmer shouldnot care what the underlying architecture reallyisThe instruction set is the boundary wherethe computer designer and the computerprogrammer can view the same machineThus, an examination of the instruction setgoes a long way to explaining thecomputer’s CPU itselfThis section investigates the design of theinstruction set and the impact of the set onthe design of the overall computer systemReadings: Chapters 9 and 102EE 4504 Section 7 3Instruction contentEach instruction must contain 4 basicpieces of information– Operation code: specifies the operation to beperformed, expressed as a binary code– Source operand references: operands requiredfor the instruction are specified– Result reference: where should the result of theoperation be placed?– Next instruction reference: how / where is thenext instruction to be found» In most cases, this is not explicitly stated inthe instruction» Next instruction is the one that logicallyfollows the current one in the program(sequential / linear progression through theprogram)EE 4504 Section 7 4Instruction typesAn instruction set should be functionallycomplete– Permit the user to formulate any high-level dataprocessing taskFive categories of instructions– Arithmetic operations– Logic operations– Data movement (internal to the system)– I/O (data movements between the computer andexternal devices)– Control operationsInstruction sets have been designed with– Small numbers of instructions (1)– Hundreds of instructions– Trend today is to use “enough” to get the jobdone well (more on this in the RISC/CISCdiscussions to come)3EE 4504 Section 7 5Until the 1980s, the trend was to constructmore and more complex instruction setscontaining hundreds of instructions andvariationsIntent was to provide mechanisms tobridge the semantic gap, the difference inhigh and low level functioning of thecomputer– Reconcile the views of the HLL programmerand the assembly level programmer– Provide a diverse set of instructions in anattempt to match the programming style of HLL– Permit the compiler to “bridge the gap” with asingle instruction rather than synthesizing aseries of instructions– Did not always have the desired impactEE 4504 Section 7 6Wulff asserts that compiler writers mightmake the better architects– Have had to deal with poor architecturedecisionsWulff’s attributes of a good instruction set– Complete: be able to construct a machine-levelprogram to evaluate any computable function– Efficient: frequently performed functionsshould be done quickly with few instructions– Regular and complete classes of instructions:provide “logical” set of operations– Orthogonal: define instructions, data types, andaddressing independentlyAdditional attribute:– Compatible: with existing H/W and S/W in aproduct line4EE 4504 Section 7 7Addresses in an InstructionIn a typical arithmetic or logicalinstruction, 3 addresses are required -- 2operands and a resultThese addresses can be explicitly given orimplied by the instruction3 address instructions– Both operands and the destination for the resultare explicitly contained in the instruction word– Example: X = Y + Z– With memory speeds (due to caching)approaching the speed of the processor, thisgives a high degree of flexibility to thecompiler» Avoid the hassles of keeping items in theregister set -- use memory as one large setof registers– This format is rarely used due to the length ofaddresses themselves and the resulting length ofthe instruction wordsEE 4504 Section 7 82 address instructions– One of the addresses is used to specify both anoperand and the result location– Example: X = X + Y– Very common in instruction sets1 address instructions– Two addresses are implied in the instruction– Traditional accumulator-based operations– Example: Acc = Acc + X0 address instructions– All addresses are implied, as in register-basedoperations» Example: TBA (transfer register B to A)– Stack-based operations» All operations are based on the use of astack in memory to store operands» Interact with the stack using push and popoperations5EE 4504 Section 7 9Trade off: Fewer addresses in theinstruction results in– More primitive instructions– Less complex CPU– Instructions with shorter length– More total instructions in a program– Longer, more complex programs– Longer execution timesConsiderY = (A-B) / (C+D*E)– 3 addressSUB Y,A,BMUL T,D,EADD T,T,CDIV Y,Y,TEE 4504 Section 7 10– 2 addressMOV Y,ASUB Y,BMOV T,DMUL T,EADD T,CDIV Y,T– 1 addressLOAD DMUL EADD CSTORE YLOAD ASUB BDIV YSTORE Y6EE 4504 Section 7 11– 0 address» Convert to postfix (reverse Polish) notationY = AB-CDE*+/PUSH APUSH BSUBPUSH CPUSH DPUSH EMULADDDIVPOP YEE 4504 Section 7 12Types of Operations7EE 4504 Section 7 13 EE 4504 Section 7 14Control OperationsCommon operations– Branch» Conditional or unconditional» Jump to another part of the program for thenext instruction by modifying the programcounter– Skip» Useful in loop controlISZ R1BRA TOP– Subroutine call / return» Jump to routine with the expectation ofreturning and resuming operation at thenext instruction» Must preserve the address of the nextinstruction (the return address)Store in a register or memory locationStore as part of the subroutine itselfStore on the stack8EE 4504 Section 7 15» Parameters can be passed to / from thesubroutine in similar ways» Use of the stack is the only reentrantapproach» Each called subroutine is allocated a stackframe on the stackContains variable to be passedReturn addressResults to be returnedEE 4504 Section 7 16Endian WarsArchitects must specify how data is stored(its byte ordering) in memory and registers– This leads to the “endian wars”» Big endian» Little endianConsider the hex value $12345678 andhow it is stored in memory starting ataddress $100– Big endian stores most significant byte in thelowest address:100 12101 34102 56103 78– Little endian stores the word in reverse:100 78101 56102 34103 129EE 4504 Section 7 17Observations:– In storing several data items into a memorysegment, each item will have the same address(big or little endian does not change this)– Endianness does not effect the ordering of


View Full Document

CSUN COMP 546 - The Instruction Set

Download The Instruction Set
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view The Instruction Set and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view The Instruction Set 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?