270 likes | 408 Views
The Instruction Set Architecture. September 27 th , 2007 By: Corbin Johnson CS 146. What is the Instruction Set Architecture?. It contains instructions to use and manipulate programmer-accessible hardware in a computer. in terms of place in a
E N D
The Instruction Set Architecture September 27th, 2007 By: Corbin Johnson CS 146
What is the Instruction Set Architecture? • It contains instructions to use and manipulate programmer-accessible hardware in a computer. in terms of place in a computer
What is the relationship between the Instruction Set Architecture and Assembly / Machine language? • An assembly / machine program is made up of the instructions in the ISA and makes use of registries in the ISA.
Here’s how it works • Higher level languages (Java, C++, etc…) are translated into assembly / machine language by compilers. • When a user calls the program, the compiled program is loaded into RAM. • The program then executes, line by line, until the Operating System takes back control of the computer.
A Sample Computer: ARC • The ARC has an ISA that is a subset of the ISA of the SPARC, or Scalable Processor Architecture processor developed by Sun in the mid 80’s. • Has most important features of SPARC but has left out most complex portions. • ARC is considered a RISC or “Reduced Instruction Set Computer.”
Goal: Program the ARC • A program can be written for the ARC using the ISA of the ARC. • Discuss three main parts of ARC: • RAM • Processor (CPU) • Instruction Set
Discuss three main parts of ARC: • RAM • Processor (CPU) • Instruction Set • 32 bit memory • Byte Addressable • Memory-mapped I/O
Discuss three main parts of ARC: • RAM • Processor (CPU) • Instruction Set • The OS • 211 bits of memory • Only OS uses this area
Discuss three main parts of ARC: • RAM • Processor (CPU) • Instruction Set • The User Space • Undefined amount • User’s program fills Into unused space • Designed to work well If stack small and Program large or Vice versa.
Discuss three main parts of ARC: • RAM • Processor (CPU) • Instruction Set • The System Stack • Undefined amount • Program’s execution Uses stack for storage • Grows towards lower Memory as user’s Space grows towards Higher memory.
Discuss three main parts of ARC: • RAM • Processor (CPU) • Instruction Set • Memory-Mapped I/O • Static slots • Data talks with input And output devices
Discuss three main parts of ARC: • RAM • Processor (CPU) • Instruction Set • The CPU • Executes programs In main memory • Contains Registries Holding data • Four-Step cycle to Execute program
Discuss three main parts of ARC: • RAM • Processor (CPU) • Instruction Set • The Four Step Cycle • Fetch next instruction • Decode the instruction • Read operand in main memory if any • Execute instruction and store results, if any.
Discuss three main parts of ARC: • RAM • Processor (CPU) • Instruction Set • The registers • Positions in CPU that hold data during calculation • Special Registries: %r0, %sp, %link, %psr, % pc
Discuss three main parts of ARC: • RAM • Processor (CPU) • Instruction Set • The Arithmetic and Logic Unit • Takes care of calculations that need to be executed • Fed instructions by the Control Unit
Discuss three main parts of ARC: • RAM • Processor (CPU) • Instruction Set • Some Features of the ISA: • All of the instructions in the Instruction Set are 32 bit • ARC is load-store: all operands must be either loaded to use or stored in memory to be stored • ARC is two’s compliment
Discuss three main parts of ARC: • RAM • Processor (CPU) • Instruction Set • Three different classes of instructions: • Arithmetic and Logic • Memory Access • Transfer of Control
Three different classes of instructions: • Arithmetic and Logic • Memory Access • Transfer of Control • Arithmetic and Logic • Includes instructions like Add and Subtract • Also includes instructions like AND, OR and NOT.
Three different classes of instructions: • Arithmetic and Logic • Memory Access • Transfer of Control • Memory Access • Includes instructions load and store • Loads into registers and stores into memory slots in RAM
Three different classes of instructions: • Arithmetic and Logic • Memory Access • Transfer of Control • Transfer of Control • Instructions help get to different places in program • Place in ISA where conditionals first are seen (if statement, loops, etc…) • Essentially changes program counter register
The Syntax of the ARC Assembly Language The Mnemonic is a way for the programmer to remember the instruction’s name. A Compiler will take a written assembly language code and convert it to machine code.
What’s that cc after addcc? CC stands for Condition Code and they are set in the PSR (it is a 32 bit registry) There are 4: Z: if the result of the instruction is zero, this flag is set. N: if the most significant bit is 1, this bit is set C: if there is a carry out of the MSB or a borrow into it, this flag is set. V: Overflow. The result cannot be represented in 32 bits.
More on The Syntax of the ARC Assembly Language Brackets [ ] around an operand means to load (or store) from (or in) the memory which is addressed by the operand within the brackets.
A few of the 35 instructions • The ARC ISA has more than 35 instructions. • Memory: ld [%r5 + 2064] , %r1 • Arithmetic: addcc %r1, 129, %r1 • Control: call sub_r
From Assembly Language to Machine Code Each Assembly Language instruction is translated one line for one line (one to one). rd: destination registry Cond: based on the PSR, this executes differently Simm13: a user defined constant in 2’s compliment in 13 bits. Rs1: registry 1 in the CPU Disp30/Disp 22: 30/22 bit number is shifted to the left to achieve 32 bit destination of it’s function.
Summary • Although not explicitly shown, this method will take an upper level program and convert it into actual things the computer can do. • Involves translation from the higher level into assembly language into machine code using the ARC ISA.