1 / 30

IT253: Computer Organization

Tonga Institute of Higher Education. IT253: Computer Organization. Lecture 4: Instruction Set Architecture. Instruction Set Architecture: ISA. Instruction Set Architecture. The ISA describes the level of the hardware/software interface. A level which was developed before any other level.

roary-kirk
Download Presentation

IT253: Computer Organization

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Tonga Institute of Higher Education IT253: Computer Organization Lecture 4: Instruction Set Architecture

  2. Instruction Set Architecture: ISA

  3. Instruction Set Architecture • The ISA describes the level of the hardware/software interface. A level which was developed before any other level. • It is the way to communicate between hardware and software • An ISA describes the instructions that are able to execute simple commands on a processor

  4. ISA • When you compile a program, it changes your source code into a list of instructions which work on your processor type • There are many types of ISA’s used. • Each processor has their own ISA • We will learn a type of ISA called MIPS, which is used by many schools to teach, and also by many types of processors in use.

  5. ISA • The ISA level is used to go between high level languages and hardware. • People who make processors talk to people who make compilers to decide what the ISA should be like. • Two important issues to consider in ISA design • Can the set of instructions be implemented efficiently • Will it be easy for chip designers and compiler designers

  6. Thinking about ISAs Requirements for an ISA int x = 5; for (int k = 0; k < 15; k++) { System.out.println(k); } if (x > k) { int [] array = new int[5]; } int z = (x | 7) / 56; What operations do we need? What should be made in Hardware?

  7. Design for an ISA • What do we need for a good ISA? • Operations (add, subtract,multiply) • Explicit operands (constants – 1,2,3) • Storage (where the variables live) • Memory Address (how we get to variables) • Type of variable (int, double) • This means we need, • Arithmetic and logic instructions • Data transfer instructions (load, store) • Control transfer (getting to different places in the program)

  8. ISA Interface • An ISA is a way to define an interface – a way for the software to run on the hardware • A good interface will last a long time • Efficient • Used in different ways (versatile) • Easy to use

  9. Typical ISA interface

  10. Efficiency in instructions For a simple command like C = A + B What instructions to we need to go through

  11. A two address ISA A 2 address ISA uses two explicit operands, and one implicit. That means that the commands look like: add tmp1,a -- In ISA tmp1 = tmp1 + a -- in high level

  12. A three address ISA • An ISA with three explicit operands.

  13. Using Registers • Registers are memory inside the processor that is used to store variables the CPU is currently working with • It is where the numbers for operations like add and subtract are stored • All computers use registers • They are very fast because they exist on the CPU. • In fact, there could be no CPU without the registers

  14. Registers • A register is a place to hold variables needed for an instruction • Like memory, but much smaller. • Usually there are 32, 32-bit registers. • Each register will use 32 bits to save data • Sometimes there are special registers for floating point numbers

  15. 3 Address ISA with Registers • Just like 3 address ISA, but now we can use registers instead of saying each variable

  16. A Load/Store ISA • We have seen an “add” instruction. It is similar for subtracting, multiplying, dividing • What if we need to use memory? • Load and store commands allow a programmer to move data to and from memory. • It is the only way to actually use memory in order to save data for a longer period of time • Memory in this case means the cache, RAM or virtual memory

  17. Load/Store ISA • Example of Load and Storing ISA commands

  18. Registers • Registers can hold data like integers. • This means they can also hold addresses of memory (an address is an integer, like a pointer)

  19. Control Operations • "Control flow" is the word used to describe the order the instructions are executed in • You can change the order with if/else, for loops and functions (methods) int main() { cout << “hello” << endl; int x = GetNumber(); cout << x << endl; } int GetNumber() { return 7; } public static void main(String[] args) { System.out.println(“hello”); int x = GetNumber(); System.out.println(x); } public static int GetNumber() { return 7; }

  20. Control Operations • If there is a function, the “control flow” of the program changes. • The program jumps out of "int main()" and into "int GetNumber()" • You can also change control flow with conditionals (if statements), loops (for and while)

  21. Control Flow: Conditionals • It is a very common action to compare two values and take action on the result if (x == 6) { then do this; } else if (x == 7) { do that; } • This is called a “branch” statement. • It is also known as a conditional. • It is also an if statement. • Know all those names!

  22. Control Flow: Example C++/: if (a == b) { Java c = 1; } else { c = 2; } MIPS: // we assume $s1 = a, $s2 = b, $s3 = c beq $s1, $s2, then // if a==b goto “then” li $s3,2 // c = 2; j done // jump to done then: li $s3,1 // then c = 1; done: // exit program

  23. ISA Commands we need

  24. ISA • We have seen typical 2 and 3 address instruction set architectures. • These were only examples of the form of an ISA. A real ISA, like MIPS, will fill in the missing details • An ISA needs registers, operands and operations • It needs operations like add, load and store • It needs control operations like jumps and branching

  25. ISA • But all these are only commands written in text. A CPU can only understand binary • The key to this problem is that an ISA can be directly translated into binary. • This means each instruction has a special binary code. • Each register has a special binary code

  26. Making instructions machine readable • Programmers are able to read and write commands like the following (in text) • add r1,r2,6 • A processor needs a series of bits to work with • The goal is to translate an instruction to a 32 bit binary number. • It will be like floating point, where certain parts of the instruction are saved in certain parts of the 32 bit integer

  27. Examples of this translation

  28. Machine Codes

  29. Machine Code • Let’s look at one example of the machine code translation Op: This is where we tell whether it is a add, subtract, load, store, and so on. There is a special binary code for each operation Since it is a 6 bit field, we have 6 bits to save the code. For example: Add = 000001 Rs1 = the address of the first register (choose 1 out of 32) Rd = the address of the register of the destination Immediate = a constant integer value

  30. Summary for ISA • ISA is the language that computers use to allow software to communicate with hardware • We need certain types of instructions to make a complete ISA • These instructions will perform operations, load memory, execute conditionals • Once we have an ISA, the computer must convert each instruction to a machine readable format (it has to be binary!) • This is our introduction for the MIPS ISA

More Related