C Chapter 2: Machines, Machine S D Languages, And Digital .

3y ago
19 Views
2 Downloads
1.51 MB
81 Pages
Last View : 1m ago
Last Download : 3m ago
Upload by : Cannon Runnels
Transcription

CSDA2/eChapter 2: Machines, MachineLanguages, and Digital LogicInstruction sets, SRC, RTN, and the mapping of registertransfers to digital logic circuitsComputer Systems Design and Architecture Second Edition 2004 Prentice Hall

CSDA2/eChapter 2 Topics 2.1 Classification of Computers and Instructions2.2 Kinds and Classes of Instruction Sets2.3 Informal Description of the Simple RISC Computer, SRC Students may wish to consult Appendix C, Assembly andAssemblers for information about assemblers and assembly.2.4 Formal Description of SRC using Register Transfer Notation(RTN)2.5 RTN Description of Addressing Modes2.6 Register Transfers and Logic Circuits: from Behavior toHardware Students may wish to consult Appendix A, Digital Logic foradditional information about Digital Logic circuits.Computer Systems Design and Architecture Second Edition 2004 Prentice Hall

CSWhat are the components of an ISA?DA2/e Sometimes known as The Programmers Model of the machine Storage cells The Machine Instruction Set The instruction set is the entire repertoire of machine operationsMakes use of storage cells, formats, and results of the fetch/execute cyclei. e. Register TransfersThe Instruction Format General and special purpose registers in the CPUMany general purpose cells of same size in memoryStorage associated with I/O devicesSize and meaning of fields within the instructionThe nature of the Fetch/Execute cycle Things that are done before the operation code is knownComputer Systems Design and Architecture Second Edition 2004 Prentice Hall

CFig. 2.1 Programmer’s Models of VariousSMachinesDA2/eWe saw in Chap. 1 a variation in number and type of storage cellsComputer Systems Design and Architecture Second Edition 2004 Prentice Hall

CSDA2/e What Must an Instruction Specify?Data FlowWhich operation to perform: add r0, r1, r3In CPU registers, memory cells, I/O locations, or part of instructionPlace to store result Ans: Op code: add, load, branch, etc.Where to find the operand or operands add r0, r1, r3add r0, r1, r3Again CPU register or memory cellLocation of next instructionadd r0, r1, r3br endloopThe default is usually memory cell pointed to by program counter—PC:the next instruction in sequenceSometimes there is no operand, or no result, or no next instruction. Canyou think of examples?Computer Systems Design and Architecture Second Edition 2004 Prentice Hall

CS Fig. 2.2 Accessing Memory—Reading from MemoryDA2/eFor a Memory Read:CPU applies desired address to Address lines A0-An-1CPU issues Read command, RMemory returns the value at that address on Data lines D0-Db-1 and assertsthe COMPLETE signalComputer Systems Design and Architecture Second Edition 2004 Prentice Hall

CS Figure 2.2 Accessing Memory—Writing to MemoryDA2/eFor a Memory Write:CPU applies desired address to Address lines A0-An-1 and and data to be written onData lines D0-Db-1CPU issues Write command, WMemory asserts the COMPLETE signal when the data has been written to memory.Computer Systems Design and Architecture Second Edition 2004 Prentice Hall

CSInstructions Can Be Divided into 3 ClassesDA2/e Data movement instructions Arithmetic and logic (ALU) instructions Move data from a memory location or register to another memory locationor register without changing its formLoad—source is memory and destination is registerStore—source is register and destination is memoryChanges the form of one or more operands to produce a result stored inanother locationAdd, Sub, Shift, etc.Branch instructions (control flow instructions) Any instruction that alters the normal flow of control from executing thenext instruction in sequenceBr Loc, Brz Loc2,—unconditional or conditional branchesComputer Systems Design and Architecture Second Edition 2004 Prentice Hall

CSDA2/eTbl. 2.1 Examples of Data MovementInstructionsInst ruct .MOV A, BMeaningMove 16 bits from mem. loc. A to loc. BMachineVAX11lwz R3, AMove 32 bit s from mem. loc. A to reg. R3 PPC601li 3, 455Load the 32 bit integer 455 int o reg. 3MIPS R3000mov R4, doutMove 16 bits from R4 to out port doutDEC PDP11IN, AL, KBDLoad a byt e from in port KBD to accum.Intel PentiumLEA.L (A0), A2 Load address pointed to by A0 into A2 M68000Lots of variation, even with one instruction typeNotice differences in direction of data flow left-to-right or right-to-leftComputer Systems Design and Architecture Second Edition 2004 Prentice Hall

CSDA2/eTbl 2.2 Examples of ALU(Arithmetic and Logic Unit) InstructionsInstructionMULF A, B, Cnabs r3, r1ori 2, 1, 255DEC R2SHL AX, 4Meaningmultiply the 32-bit floating point values atmem loc’ns. A and B, store at CStore abs value of r1 in r3Store logical OR of reg 1 with 255 into reg 2Decrement the 16-bit value stored in reg R2Shift the 16-bit value in reg AX left by 4 bitsMachineVAX11PPC601MIPS R3000DEC PDP11Intel 8086 Notice again the complete dissimilarity of both syntax and semanticsComputer Systems Design and Architecture Second Edition 2004 Prentice Hall

CSDA2/eTbl 2.3 Examples of Branch InstructionsInstructionBLSS A, Tgtbun r2beq 2, 1, 32SOB R4, LoopJCXZ AddrMeaningMachineBranch to address Tgt if the least significantVAX11bit of mem loc’n. A is set (i.e. 1)Branch to location in R2 if result of previousPPC601floating point computation was Not a Number (NAN)Branch to location (PC 4 32) if contentsMIPS R3000of 1 and 2 are equalDecrement R4 and branch to Loop if R4 0DEC PDP11Jump to Addr if contents of register CX 0.Intel 8086Computer Systems Design and Architecture Second Edition 2004 Prentice Hall

CSDA2/eCPU Registers Associated with Flow ofControl—Branch Insts. Program counter usually contains the address of, or "points to" thenext instructionCondition codes may control branchBranch targets may be contained in separate registersProcessor StateC N V ZProgram CounterCondition Cod Branch TargetsComputer Systems Design and Architecture Second Edition 2004 Prentice Hall

CHLL Conditionals Implemented by Control FlowSChangeDA2/e Conditions are computed by arithmetic instructionsProgram counter is changed to execute only instructionsassociated with true conditionsC languageif NUM 5 then SET 7Computer Systems Design and Architecture Second EditionAssembly languageCMP.W #5, NUMBNEL1MOV.W #7, SETL1 .;the comparison;conditional branch;action if true;action if false 2004 Prentice Hall

CSDA2/eCPU Registers may have a “personality” Architecture classes are often based on how where the operandsand result are located and how they are specified by theinstruction.They can be in CPU registers or main ral PurposeRegisters Push PopTopSecond St ack MachineAccumulat orComputer Systems Design and Architecture Second EditionMachineGeneral Regist erMachine 2004 Prentice Hall

CS3, 2, 1, & 0 Address InstructionsDA2/e The classification is based on arithmetic instructions that have two operands and one resultThe key issue is “how many of these are specified by memoryaddresses, as opposed to being specified implicitly”A 3 address instruction specifies memory addresses for both operandsand the result: R Op1 op Op2A 2 address instruction overwrites one operand in memory with theresult: Op2 Op1 op Op2A 1 address instruction has a register, called the accumulator registerto hold one operand & the result (no address needed):Acc Acc op Op1A 0 address uses a CPU register stack to hold both operands andthe result: TOS TOS op SOS where TOS is Top Of Stack, SOS isSecond On Stack)The 4-address instruction, hardly ever seen, also allows the address ofthe next instruction to specified explicitly.Computer Systems Design and Architecture Second Edition 2004 Prentice Hall

CSDA2/eFig. 2.3 The 4 Address Instruction Explicit addresses for operands, result & next instructionExample assumes 24-bit addresses Discuss: size of instruction in bytesComputer Systems Design and Architecture Second Edition 2004 Prentice Hall

CSDA2/e Fig 2.4 The 3 Address InstructionAddress of next instruction kept in a processor state register—the PC(Except for explicit Branches/Jumps)Rest of addresses in instruction Discuss: savings in instruction word sizeComputer Systems Design and Architecture Second Edition 2004 Prentice Hall

CSDA2/e Fig. 2.5 The 2 Address InstructionBe aware of the difference between address, Op1Addr, and data stored at that address,Op1.Result overwrites Operand 2, Op2, with result, ResThis format needs only 2 addresses in the instruction but there is less choice in placing dataComputer Systems Design and Architecture Second Edition 2004 Prentice Hall

CSDA2/eFig. 2.6 1 Address InstructionsWe now needinstructions to loadand storeoperands:LDA OpAddrSTA OpAddr Special CPU register, the accumulator, supplies 1 operand and stores resultOne memory address used for other operandComputer Systems Design and Architecture Second Edition 2004 Prentice Hall

CSDA2/e Fig. 2.7 The 0 Address InstructionUses a push down stack in CPUArithmetic uses stack for both operands. The result replaces them on the TOSComputer must have a 1 address instruction to push and pop operands to andfrom the stackComputer Systems Design and Architecture Second Edition 2004 Prentice Hall

CSDA2/eExample 2.1 Expression evaluation for 3-0address instructions.Evaluate a (b c)*d-e for 3- 2- 1- and 0-address machines. # of instructions & # of addresses both varyDiscuss as examples: size of code in each caseComputer Systems Design and Architecture Second Edition 2004 Prentice Hall

CSDA2/e Fig. 2.8 General Register MachinesIt is the most common choice in today’s general purpose computersWhich register is specified by small “address” (3 to 6 bits for 8 to 64 registers)Load and store have one long & one short address: 1 1/2 addresses2-Operand arithmetic instruction has 3 “half” addressesComputer Systems Design and Architecture Second Edition 2004 Prentice Hall

CSDA2/eReal Machines are Not So Simple Most real machines have a mixture of 3, 2, 1, 0, 1 1/2 addressinstructionsA distinction can be made on whether arithmetic instructionsuse data from memoryIf ALU instructions only use registers for operands and result,machine type is load-store Only load and store instructions reference memoryOther machines have a mix of register-memory and memorymemory instructionsComputer Systems Design and Architecture Second Edition 2004 Prentice Hall

CSDA2/e Addressing ModesAn addressing mode is hardware support for a useful way ofdetermining a memory addressDifferent addressing modes solve different HLL problems Some addresses may be known at compile time, e.g. global vars.Others may not be known until run time, e.g. pointersAddresses may have to be computed: Examples include: Record (struct) components: Array components: variable base(full address) const.(small)const. base(full address) index var.(small)Possible to store constant values w/o using another memory cell bystoring them with or adjacent to the instruction itself.Computer Systems Design and Architecture Second Edition 2004 Prentice Hall

CSDA2/e HLL Examples of Structured AddressesC language: rec - count CountRec C language: v[i] rec is a pointer to a record: full address variablecount is a field name: fixed byte offset, say 24v is fixed base address of array: full address constanti is name of variable index: no larger than array sizeVariables must be contained in registers or memory cellsSmall constants can be contained in the instructionResult: need for “address arithmetic.” V[i]V E.g. Address of Rec - Count is address of Rec offset ofcount.Computer Systems Design and Architecture Second Edition 2004 Prentice Hall

CSDA2/eFig 2.9 Common Addressing Modes a-dComputer Systems Design and Architecture Second Edition 2004 Prentice Hall

CSDA2/eFig 2.9 Common Addressing Modes e-gComputer Systems Design and Architecture Second Edition 2004 Prentice Hall

CSDA2/eFig. 2.10a Example Computer, SRCSimple RISC Computer 32 general purpose registers of 32 bits32 bit program counter, PC and instruction reg., IR232 bytes of memory address spaceComputer Systems Design and Architecture Second Edition 2004 Prentice Hall

CSDA2/e SRC Characteristics( ) Load-store design: only way to access memory is through load and storeinstructions(–) Operation on 32-bit words only, no byte or half-word operations.( ) Only a few addressing modes are supported( ) ALU Instructions are 3-register type(–) Branch instructions can branch unconditionally or conditionally on whetherthe value in a specified register is 0, 0, 0, or 0.(–) Branch-and-link instructions are similar, but leave the value of current PCin any register, useful for subroutine return.(–) Can only branch to an address in a register, not to a direct address.( ) All instructions are 32-bits (1-word) long.( ) – Similar to commercial RISC machines(–) – Less powerful than commercial RISC machines.Computer Systems Design and Architecture Second Edition 2004 Prentice Hall

CSDA2/eSRC Basic Instruction Formats There are three basic instruction format typesThe number of register specifier fields and length of theconstant field varyOther formats result from unused fields or parts31 27 26 22 21opra0c131 27 26 22 21 17 16oprarb31 27 26 22 21 17 16 12 11oprarbrcType 10c2Type 20c3Type 3 Details of formats:Computer Systems Design and Architecture Second Edition 2004 Prentice Hall

CS Fig 2.10 cont'd. SRCinstructionsDA2/eComputer Systems Design and Architecture Second Edition 2004 Prentice Hall

CSDA2/eTbl 2.4 Example Load & Store Instructions:Memory Addressing Address can be constant, constant register, or constant PCMemory contents or address itself can be loadedInstructionld r1, 32ld r22, 24(r4)st r4, 0(r9)la r7, 32ldr r12, -48lar r3, gR[1] M[32]R[22] M[24 R[4]]M[R[9]] R[4]R[7] 32R[12] M[PC -48]R[3] PCAddressing ModeDirectDisplacementRegister indirectImmediateRelativeRegister (!)(note use of la to load a constant)Computer Systems Design and Architecture Second Edition 2004 Prentice Hall

CSDA2/eAssembly Language Forms of Arithmetic andLogic InstructionsFormatneg ra, rcnot ra, rcadd ra, rb, rcsub ra, rb, rcand ra, rb, rcor ra, rb, rcaddi ra, rb, c2andi ra, rb, c2ori ra, rb, c2 Exampleneg r1, r2not r2, r3add r2, r3, r4addi r1, r3, 1Meaning;Negate (r1 -r2);Not (r2 r3 );2’s complement addition;2’s complement subtraction;Logical and;Logical or;Immediate 2’s complement add;Immediate logical and;Immediate logical orImmediate subtract not needed since constant in addi may benegativeComputer Systems Design and Architecture Second Edition 2004 Prentice Hall

CSBranch Instruction FormatDAThere are actually only two branch op codes:2/e;branch to R[rb] if R[rc] meets; the condition defined by c3 2.0 brlra, rb, rc, c3 2.0 ; R[ra] PC; branch as abovebr rb, rc, c3 2.0 It is c3 2.0 , the 3 lsbs of c3, that governs what the branch condition is:lsbs000001010011100101conditionneveralwaysif rc 0if rc 0if rc 0if rc 0Assy language formbrlnvbr, brlbrzr, brlzrbrnz, brlnzbrpl, brlplbrmi, brlmiExamplebrlnv r6br r5, brl r5brzr r2, r4 Note that branch target address is always in register R[rb]. It must be placed there explicitly by a previous instruction.Computer Systems Design and Architecture Second Edition 2004 Prentice Hall

CSDA2/eTbl. 2.6 Branch Instruction ExamplesAss’ylang.brlnvbrbrlExample instr. Meaningbrlnv r6br r4brl r6,r4brzrbrzr r5,r1brlzrbrnzbrlnzbrlzr r7,r5,r1brnz r1, r0brlnz r2,r1,r0brplbrlplbrpl r3, r2brlpl r4,r3,r2brmibrlmibrmi r0, r1brlmi r3,r0,r1R[6] PCPC R[4]R[6] PC;PC R[4]if (R[1] 0)PC R[5]R[7] PC;if (R[0] 0) PC R[1]R[2] PC;if (R[0] 0) PC R[1]if (R[2] 0) PC R[3]R[4] PC;if (R[2] 0) PC R[3]if (R[1] 0) PC R[0]R[3] PC;if (r1 0) PC R[0]Computer Systems Design and Architecture Second Editionoprarb—44rc c3〈2.0〉— 000— 001— ��43322100plusplus89—30011101minusminus 2004 Prentice Hall

CSDA2/eBranch Instructions—ExampleC: goto Label3SRC:lar r0, Label3br r0 Label3; put branch target address into tgt reg.; and branch Computer Systems Design and Architecture Second Edition 2004 Prentice Hall

CSDA2/eExample of conditional branchin C: #define Cost 125if (X 0) then X -X;in SRC:Cost .equ 125;define symbolic constant.org 1000;next word will be loaded at address 100010X:.dw 1;reserve 1 word for variable X.org 5000;program will be loaded at location 500010lar r31, Over;load address of “false” jump locationldr1, X;load value of X into r1brpl r31, r1;branch to Else if r1 0neg r1, r1;negate valueOver: ;continueComputer Systems Design and Architecture Second Edition 2004 Prentice Hall

CSDA2/eRTN (Register Transfer Notation) Provides a formal means of describing machine structureand functionIs at the “just right” level for machine descriptionsDoes not replace hardware description languages.Can be used to describe what a machine does (anAbstract RTN) without describing how the machine doesit.Can also be used to describe a particular hardwareimplementation (A Concrete RTN)Computer Systems Design and Architecture Second Edition 2004 Prentice Hall

CSDA2/eRTN Notation (Cont’d.) At first you may find this “meta description” confusing, because itis a language that is used to describe a language.You will find that developing a familiarity with RTN will aidgreatly in your understanding of new machine design concepts.We will describe RTN by using it to describe SRC.Computer Systems Design and Architecture Second Edition 2004 Prentice Hall

CSDA2/eSome RTN Features—Using RTN to describe a machine’s static propertiesStatic Properties Specifying registers IR〈31.0〉 specifies a register named “IR” having 32 bits numbered 31 to 0“Naming” using the : naming operator: op〈4.0〉 : IR〈31.27〉 specifies that the 5 msbs of IR be called op, with bits 4.0.Notice that this does not create a new register, it just generates another name,or “alias” for an already existing register or part of a register.Computer Systems Design and Architecture Second Edition 2004 Prentice Hall

CSDA2/eUsing RTN to describeDynamic PropertiesDynamic Properties Conditional expressions:(op 12) R[ra] R[rb] R[rc]:“if” condition “then”; defines the add instructionRTN Assignment OperatorThis fragment of RTN describes the SRC add instruction. It says,“when the op field of IR 12, then store in the register specifiedby the ra field, the result of adding the register specified by therb field to the register specified by the rc field.”Computer Systems Design and Architecture Second Edition 2004 Prentice Hall

CSDA2/eUsing RTN to describe the SRC (static)Processor StateProcessor statePC〈31.0〉:program counter(memory addr. of next inst.)IR〈31.0〉:instruction registerRun:one bit run/halt indicatorStrt:start signalR[0.31]〈31.0〉: general purpose registersComputer Systems Design and Architecture Second Edition 2004 Prentice Hall

CSDA2/eRTN Register Declarations General register specifications shows some features of thenotationDescribes a set of 32 32-bit registers with names R[0] to R[31]R[0.31]〈31.0〉:Name ofregistersRegister #in squarebracketsmsb #. specifiesa range ofindicesComputer Systems Design and Architecture Second Editionlsb#Colon separatesstatements withno orderingBit # inanglebrackets 2004 Prentice Hall

CSDA2/eMemory Declaration:RTN Naming Operator Defining names with formal parameters is a powerfulformatting toolUsed here to define word memory (big endian)Main memory stateMem[0.232 - 1]〈7.0〉: 232 addressable bytes of memoryM[x]〈31.0〉 : Mem[x]#Mem[x 1]#Mem[x 2]#Mem[x 3]:DummyparameterNamingoperatorComputer Systems Design and Architecture Second EditionConcatenationoperatorAll bits

Chapter 2 Topics 2.1 Classification of Computers and Instructions 2.2 Kinds and Classes of Instruction Sets 2.3 Informal Description of the Simple RISC Computer, SRC Students may wish to consult Appendix C, Assembly and Assemblers for information about assemblers and assembly. 2.4 Formal Description of SRC using Register Transfer Notation

Related Documents:

Part One: Heir of Ash Chapter 1 Chapter 2 Chapter 3 Chapter 4 Chapter 5 Chapter 6 Chapter 7 Chapter 8 Chapter 9 Chapter 10 Chapter 11 Chapter 12 Chapter 13 Chapter 14 Chapter 15 Chapter 16 Chapter 17 Chapter 18 Chapter 19 Chapter 20 Chapter 21 Chapter 22 Chapter 23 Chapter 24 Chapter 25 Chapter 26 Chapter 27 Chapter 28 Chapter 29 Chapter 30 .

TO KILL A MOCKINGBIRD. Contents Dedication Epigraph Part One Chapter 1 Chapter 2 Chapter 3 Chapter 4 Chapter 5 Chapter 6 Chapter 7 Chapter 8 Chapter 9 Chapter 10 Chapter 11 Part Two Chapter 12 Chapter 13 Chapter 14 Chapter 15 Chapter 16 Chapter 17 Chapter 18. Chapter 19 Chapter 20 Chapter 21 Chapter 22 Chapter 23 Chapter 24 Chapter 25 Chapter 26

DEDICATION PART ONE Chapter 1 Chapter 2 Chapter 3 Chapter 4 Chapter 5 Chapter 6 Chapter 7 Chapter 8 Chapter 9 Chapter 10 Chapter 11 PART TWO Chapter 12 Chapter 13 Chapter 14 Chapter 15 Chapter 16 Chapter 17 Chapter 18 Chapter 19 Chapter 20 Chapter 21 Chapter 22 Chapter 23 .

decoration machine mortar machine paster machine plater machine wall machinery putzmeister plastering machine mortar spraying machine india ez renda automatic rendering machine price wall painting machine price machine manufacturers in china mail concrete mixer machines cement mixture machine wall finishing machine .

1 Pipe beveling machines OD mount Machine MF3-R 8 Machine MF4-R 10 Machine MF2-25 12 3 Pipe cutting and beveling machines Machine CPC (chain cutting) 36 Machine DLW (cold cutting) 40 Machine BWC (boiler tube cutting) 46 4 Line boring and drilling machines 9 Pipe and pipeline welding equipment

About the husband’s secret. Dedication Epigraph Pandora Monday Chapter One Chapter Two Chapter Three Chapter Four Chapter Five Tuesday Chapter Six Chapter Seven. Chapter Eight Chapter Nine Chapter Ten Chapter Eleven Chapter Twelve Chapter Thirteen Chapter Fourteen Chapter Fifteen Chapter Sixteen Chapter Seventeen Chapter Eighteen

18.4 35 18.5 35 I Solutions to Applying the Concepts Questions II Answers to End-of-chapter Conceptual Questions Chapter 1 37 Chapter 2 38 Chapter 3 39 Chapter 4 40 Chapter 5 43 Chapter 6 45 Chapter 7 46 Chapter 8 47 Chapter 9 50 Chapter 10 52 Chapter 11 55 Chapter 12 56 Chapter 13 57 Chapter 14 61 Chapter 15 62 Chapter 16 63 Chapter 17 65 .

HUNTER. Special thanks to Kate Cary. Contents Cover Title Page Prologue Chapter 1 Chapter 2 Chapter 3 Chapter 4 Chapter 5 Chapter 6 Chapter 7 Chapter 8 Chapter 9 Chapter 10 Chapter 11 Chapter 12 Chapter 13 Chapter 14 Chapter 15 Chapter 16 Chapter 17 Chapter