DOC PREVIEW
U of I CS 231 - Instruction set architectures

This preview shows page 1 out of 4 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 4 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 4 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

4/10/2006 ISA 1Instruction set architectures• Last week we built a simple, but complete, datapath.• The datapath is ultimately controlled by a programmer, so today we’ll look at several aspects of programming in more detail.– How programs are executed on processors– An introduction to instruction set architectures– Example instructions and programs• Next, we’ll see how programs are encoded in a processor. Following that, we’ll finish our processor by designing a control unit, which converts our programs into signals for the datapath.4/10/2006 ISA 2Programming and CPUs• Programs written in a high-level language like C++ must be compiledto produce an executable program.• The result is a CPU-specific machine language program. This can be loaded into memory and executed by the processor.• CS231 focuses on stuff below the dotted blue line, but machine language serves as the interfacebetween hardware and software.DatapathHigh-level programExecutable fileControl wordsCompilerControl UnitHardwareSoftware4/10/2006 ISA 3High-level languages• High-level languages provide many useful programming constructs.– For, while, and do loops– If-then-else statements– Functions and procedures for code abstraction– Variables and arrays for storage• Many languages provide safety features as well.– Static and dynamic typechecking– Garbage collection• High-level languages are also relatively portable.Theoretically, you can write one program and compile it on many different processors.• It may be hard to understand what’s so “high-level” here, until you compare these languages with...4/10/2006 ISA 4Low-level languages• Each CPU has its own low-level instruction set, or machine language, which closely reflects the CPU’s design.• Unfortunately, this means instruction sets are not easy for humans to work with!– Control flow is limited to “jump” and “branch” instructions, which you must use to make your own loops and conditionals.– Support for functions and procedures may be limited.– Memory addresses must be explicitly specified. You can’t just declare new variables and use them!– Very little error checking is provided.– It’s difficult to convert machine language programs to differentprocessors.• Later we’ll look at some rough translations from C to machine language.4/10/2006 ISA 5Compiling• Processors can’t execute programs written in high-level languages directly, so a special program called a compiler is needed to translate high-level programs into low-level machine code.• In the “good” old days, people often wrote machine language programs by hand to make their programs faster, smaller, or both.• Now, compilers almost always do a better job than people.– Programs are becoming more complex, and it’s hard for humans to write and maintain large, efficient machine language code.– CPUs are becoming more complex. It’s difficult to write code that takes full advantage of a processor’s features.• Some languages, like Perl or Lisp, are usually interpreted instead of compiled.– Programs are translated into an intermediate format.– This is a “middle ground” between efficiency and portability.4/10/2006 ISA 6Assembly and machine languages• Machine language instructions are sequences of bits in a specific order. • To make things simpler, people typically use assembly language.– We assign “mnemonic” names to operations and operands.– There is (almost) a one-to-one correspondence between these mnemonics and machine instructions, so it is very easy to convert assembly programs to machine language.• We’ll use assembly code this today to introduce the basic ideas, and switch to machine language tomorrow.4/10/2006 ISA 7Data manipulation instructions• Data manipulation instructions correspond to ALU operations. • For example, here is a possible addition instruction, and its equivalent using our register transfer notation:• This is similar to a high-level programming statement likeR0 = R1 + R2• Here, all of the operands are registers.ADD R0, R1, R2operationdestination sourcesoperandsR0 ← R1 + R2Register transfer instruction:4/10/2006 ISA 8More data manipulation instructions• Here are some other kinds of data manipulation instructions.NOT R0, R1 R0 ← R1’ADD R3, R3, #1 R3 ← R3 + 1SUB R1, R2, #5 R1 ← R2 - 5• Some instructions, like the NOT, have only one operand.• In addition to register operands, constant operands like 1 and 5 are also possible. Constants are denoted with a hash mark in front.4/10/2006 ISA 9Relation to the datapath • These instructions reflect the design of our datapath from last week.• There are at most two source operands in each instruction, since our ALU has just two inputs.• The two sources can be two registers, or one register and one constant.• More complex operations likeR0 ← R1 + R2 - 3must be broken down into several lower-level instructions.• Instructions have just one destination operand, which must be a register.D dataWriteD addressA address B addressA data B dataRegister FileWRDAAA BAABALUFZNCVFSFSS D1 D0QConstantMB4/10/2006 ISA 10What about RAM?• Recall that our ALU has direct access only to the register file.• RAM contents must be copied to the registers before they can be used as ALU operands.• Similarly, ALU results must go through the registers before they can be stored into memory.• We rely on data movementinstructions to transfer data between the RAM and the register file.D dataWriteD addressA address B addressA data B dataRegister FileWRDAAA BAQ D1D0SRAMADRSDATACSWROUTMW+5VABALUFZNCVFSFSMDS D1 D0QConstantMB4/10/2006 ISA 11Loading a register from RAM• A load instruction copies data froma RAM address toone of the registers.LD R1,(R3) R1 ← M[R3] • Remember in our datapath, the RAM address must come from one of the registers—in the example above, R3.• The parentheses help show which register operand holds the memory address.D dataWriteD addressA address B addressA data B dataRegister FileWRDAAA BARAMADRSDATACSWROUTMW+5VABALUFZNCVFSFSMDS D1 D0QConstantMBQ D1D0S4/10/2006 ISA 12Storing a register to RAM• A store instruction copies data froma register toan address in RAM.ST (R3),R1 M[R3] ← R1• One register specifies the RAM address to write to—in the example above, R3.• The other operand specifies the actual data to be stored into RAM—R1 above.Q D1D0SABALUFZNCVFSFSMDS D1


View Full Document

U of I CS 231 - Instruction set architectures

Documents in this Course
Counters

Counters

23 pages

Latches

Latches

22 pages

Lecture

Lecture

33 pages

Lecture

Lecture

16 pages

Lecture

Lecture

4 pages

Datapaths

Datapaths

30 pages

Lecture

Lecture

6 pages

Registers

Registers

17 pages

Datapaths

Datapaths

28 pages

Decoders

Decoders

20 pages

Load more
Download Instruction set architectures
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 Instruction set architectures 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 Instruction set architectures 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?