Instruction Set Architecture (ISA)

Similar documents
Reduced Instruction Set Computer (RISC)

Instruction Set Architecture. or How to talk to computers if you aren t in Star Trek

Instruction Set Architecture

Intel 8086 architecture

Review: MIPS Addressing Modes/Instruction Formats

Introduction to MIPS Assembly Programming

Typy danych. Data types: Literals:

CSE 141 Introduction to Computer Architecture Summer Session I, Lecture 1 Introduction. Pramod V. Argade June 27, 2005

Lecture 7: Machine-Level Programming I: Basics Mohamed Zahran (aka Z)

A single register, called the accumulator, stores the. operand before the operation, and stores the result. Add y # add y from memory to the acc

EECS 427 RISC PROCESSOR

COMP 303 MIPS Processor Design Project 4: MIPS Processor Due Date: 11 December :59

Stack machines The MIPS assembly language A simple source language Stack-machine implementation of the simple language Readings:

Computer Organization and Architecture

CS412/CS413. Introduction to Compilers Tim Teitelbaum. Lecture 20: Stack Frames 7 March 08

Instruction Set Architecture

64-Bit NASM Notes. Invoking 64-Bit NASM

Instruction Set Design

Systems Design & Programming Data Movement Instructions. Intel Assembly

Computer Architecture Lecture 2: Instruction Set Principles (Appendix A) Chih Wei Liu 劉 志 尉 National Chiao Tung University

Chapter 7D The Java Virtual Machine

Instruction Set Architecture (ISA)

CPU Organization and Assembly Language

A Tiny Guide to Programming in 32-bit x86 Assembly Language

Abysssec Research. 1) Advisory information. 2) Vulnerable version

CS:APP Chapter 4 Computer Architecture Instruction Set Architecture. CS:APP2e

CS61: Systems Programing and Machine Organization

Translating C code to MIPS

Administration. Instruction scheduling. Modern processors. Examples. Simplified architecture model. CS 412 Introduction to Compilers

Return-oriented programming without returns

THUMB Instruction Set

MIPS Assembler and Simulator

MIPS Assembly Code Layout

Assembly Language: Function Calls" Jennifer Rexford!

Instruction Set Architecture (ISA) Design. Classification Categories

x64 Cheat Sheet Fall 2015

Lecture Outline. Stack machines The MIPS assembly language. Code Generation (I)

More MIPS: Recursion. Computer Science 104 Lecture 9

Faculty of Engineering Student Number:

Computer Architectures

Assembly Language Programming

612 CHAPTER 11 PROCESSOR FAMILIES (Corrisponde al cap Famiglie di processori) PROBLEMS

CHAPTER 6 TASK MANAGEMENT

Advanced Computer Architecture-CS501. Computer Systems Design and Architecture 2.1, 2.2, 3.2

M A S S A C H U S E T T S I N S T I T U T E O F T E C H N O L O G Y DEPARTMENT OF ELECTRICAL ENGINEERING AND COMPUTER SCIENCE

Chapter 2 Topics. 2.1 Classification of Computers & Instructions 2.2 Classes of Instruction Sets 2.3 Informal Description of Simple RISC Computer, SRC

Computer Systems Architecture

Computer Organization and Components

X86-64 Architecture Guide

5 MIPS Assembly Language

l C-Programming l A real computer language l Data Representation l Everything goes down to bits and bytes l Machine representation Language

Hacking Techniques & Intrusion Detection. Ali Al-Shemery arabnix [at] gmail

1 Classical Universal Computer 3

Where we are CS 4120 Introduction to Compilers Abstract Assembly Instruction selection mov e1 , e2 jmp e cmp e1 , e2 [jne je jgt ] l push e1 call e

Pentium vs. Power PC Computer Architecture and PCI Bus Interface

8085 INSTRUCTION SET

MICROPROCESSOR AND MICROCOMPUTER BASICS

SMIPS Processor Specification

High-speed image processing algorithms using MMX hardware

A SystemC Transaction Level Model for the MIPS R3000 Processor

Property of ISA vs. Uarch?

How It All Works. Other M68000 Updates. Basic Control Signals. Basic Control Signals

Computer Architecture Lecture 3: ISA Tradeoffs. Prof. Onur Mutlu Carnegie Mellon University Spring 2013, 1/18/2013

LSN 2 Computer Processors

PART B QUESTIONS AND ANSWERS UNIT I

Unpacked BCD Arithmetic. BCD (ASCII) Arithmetic. Where and Why is BCD used? From the SQL Server Manual. Packed BCD, ASCII, Unpacked BCD

Computer organization

The 80x86 Instruction Set

İSTANBUL AYDIN UNIVERSITY

Lecture 27 C and Assembly

Off-by-One exploitation tutorial

MACHINE ARCHITECTURE & LANGUAGE

Design of Pipelined MIPS Processor. Sept. 24 & 26, 1997

Winter 2002 MID-SESSION TEST Friday, March 1 6:30 to 8:00pm

D.1 Introduction D-2 D.2 80x86 Registers and Data Addressing Modes D-3 D.3 80x86 Integer Operations D-6 D.4 80x86 Floating-Point Operations D-10 D.

An Introduction to Assembly Programming with the ARM 32-bit Processor Family

Computer Organization and Assembly Language

Instruction Set Architecture

EC 362 Problem Set #2

Buffer Overflows. Security 2011

a storage location directly on the CPU, used for temporary storage of small amounts of data during processing.

MICROPROCESSOR. Exclusive for IACE Students iacehyd.blogspot.in Ph: /422 Page 1

CHAPTER 7: The CPU and Memory

Pipeline Hazards. Arvind Computer Science and Artificial Intelligence Laboratory M.I.T. Based on the material prepared by Arvind and Krste Asanovic

Introducción. Diseño de sistemas digitales.1

Central Processing Unit (CPU)

Microcontroller Basics A microcontroller is a small, low-cost computer-on-a-chip which usually includes:

Overview. CISC Developments. RISC Designs. CISC Designs. VAX: Addressing Modes. Digital VAX

1 The Java Virtual Machine

Phoenix Technologies Ltd.

Chapter 5 Instructor's Manual

2) Write in detail the issues in the design of code generator.

HC12 Assembly Language Programming

Design of Digital Circuits (SS16)

Machine-Level Programming II: Arithmetic & Control

Complete 8086 instruction set

Instruction Set Reference

Stack Overflows. Mitchell Adair

Pipeline Hazards. Structure hazard Data hazard. ComputerArchitecture_PipelineHazard1

What to do when I have a load/store instruction?

Transcription:

Instruction Set Architecture (ISA) Department of Computer Science Faculty of Computer and Information Sciences Hosei University, Tokyo 184-8584 Japan http://cis.k.hosei.ac.jp/ yamin/ ISA p.1/28

Instruction Set Architecture A very important abstraction Interface between hardware and low-level software Standardizes instructions, machine language bit patterns, etc. Advantage: different implementations of the same architecture Disadvantage: sometimes prevents using new innovations ISA p.2/28

Modern Instruction Set Architectures Intel IA-32 (80x86/Pentium/Xeon) AIM PowerPC (Apple, IBM, and Motorola AIM) DEC/Compaq DEC Alpha SGI/MIPS MIPS (Microprocessor without Interlocked Pipeline Stages) SUN SPARC (Scalable Performance Architecture) HP HP-PA (Hewlett Packard Precision Architecture) ISA p.3/28

Intel 80x86 Registers Names EAX ECX EDX EBX ESP EBP ESI EDI EIP EFLAGS 31 0 CS SS DS ES FS GS Use GPR 0 GPR 1 GPR 2 GPR 3 GPR 4 GPR 5 GPR 6 GPR 7 Code segment pointer Stack segment pointer Data segment pointer 0 Data segment pointer 1 Data segment pointer 2 Data segment pointer 3 Instruction pointer (PC) Condition codes ISA p.4/28

Typical 80x86 Instruction Formats (1) JE EIP + displacement 4 4 8 JE Condition Displacement (2) CALL 8 32 CALL Offset (3) MOV EBX, [EDI + 45] 6 1 1 8 8 MOV d w r / m Displacement ISA p.5/28

Typical 80x86 Instruction Formats (4) PUSH ESI 5 3 PUSH Reg (5) ADD EAX, #6765 4 3 1 32 ADD Reg w Immediate (6) TEST EDX, #42 7 1 8 32 TEST w r / m Immediate ISA p.6/28

Some Typical Operations on the 80x86 Arithmetic, Logical ADD, SUB Add/subtract (register-memory format) CMP Compare (register-memory format) SHL, SHR, RCR Shift left, shift right, rotate with carry condition code CBW Convert 8-bit data into 16-bit data (in EAX) TEST Logical AND and set condition codes INC, DEC Increments/decrements destination OR, XOR Logical OR, exclusive OR ISA p.7/28

Some Typical Operations on the 80x86 Control JNZ, JZ Conditional jump to EIP + 8-bit offset JMP Unconditional jump, 8-bit or 16-bit offset CALL Subroutine call, 18-bit offset, return address pushed onto stack RET Returns from subroutine: pops return address from stack and jumps to it LOOP Loop branch (decrement ECX), jump to EIP + 8-bit offset displacement if ECX 0 ISA p.8/28

Some Typical Operations on the 80x86 Data transfer MOV Move between two registers or between register and memory PUSH, POP Push data on stack or pop data from stack top to a register LES Load ES and one of the GPRs from memory String MOVS Copies from string source to destination LODS Loads a byte, word, or double word of a string into EAX ISA p.9/28

MIPS Instruction Format I-type instruction 0 5 6 10 11 15 16 31 Opcode rs rt Immediate 6 bits 5 bits 5 bits 16 bits R-type instruction 0 5 6 10 11 15 16 20 21 31 Opcode rs rt rd shamt func 6 bits 5 bits 5 bits 5 bits 5 bits 6 bits J-type instruction 0 5 6 31 Opcode Offset address to PC 6 bits 26 bits ISA p.10/28

Register File of the MIPS Processor Register name Number Usage $zero 0 constant 0 $at 1 reserved for assembler $v0 $v1 2 3 expression evaluation and results of a function $a0 $a3 4 7 arguments 1 3 $t0 $t7 8 15 temporary (not preserved across call) $s0 $s7 16 23 saved temporary (preserved across call) $t8 $t9 24 25 temporary (not preserved across call) $k0 $k1 26 27 reserved for OS kernel $gp 28 point to global area $sp 29 stack pointer $fp 30 frame point $ra 31 return address (used by function call) ISA p.11/28

Category of MIPS Instructions Arithmetic add, sub, addi, addu, mul, mulu, div, divu Logical and, or, andi, ori, sll, srl Data transfer lw, sw, lb, lbu, sb Conditional branch beq, bne, bnez, slt, slti, sltu, sltiu Unconditional jump j, jr, jal ISA p.12/28

MIPS Operations Data Transfers Instruction LB,LBU,SB LH,LHU,SH LW,LWU,SW LD,SD L.S,L.D,S.S,S.D MFC0,MTC0 MOV.S,MOV.D MFC1,MTC1 Instruction meaning Load byte, load byte unsigned, store byte Load half word, load half word unsigned, store half word Load word, Load word unsigned, store word Load double word, store double word Load SP, load DP, store SP, store DP Move from/to GPR to/from a special register Copy one SP or DP FP register to another FP register Copy 32 bits from/to FP registers to/from integer registers ISA p.13/28

MIPS Operations Arithmetic/Logical Operations Instruction DADD,DADDI,DADDU,DADDUI DSUB,DSUBU DMULT,DMULTU,DDIV,DDIVU MADD AND,ANDI OR,ORI,XOR,XORI LUI DSLL,DSRL,DSRA,DSLLV, DSRLV,DSRAV SLT,SLTI,SLTU,SLTIU Instruction meaning Add, add immediate; signed and unsigned Subtract signed and unsigned Multiply and divide; signed and unsigned Multiply-add And, and immediate Or, or imm., exclusive or, exclusive or imm. Load upper imm. bits 32 to 47 of reg. Sign ext. Shift: both imm. and variable form; shifts are left logical, right logical, right arithmetic Set less than; imm. signed and unsigned ISA p.14/28

MIPS Operations Control Transfers Instruction BEQZ,BNEZ BEQ,BNE BC1T,BC1F MOVN,MOVZ J,JR JAL,JALR TRAP ERET Instruction meaning Branch GPR equal/not equal to zero; 16-bit offset from PC+4 Branch GPR equal/not equal; 16-bit offset from PC+4 Test comparison bit in the FP status register and branch; 16-bit offset from PC+4 Copy GPR to another GPR if third GPR is negative, zero Jumps: 26-bit offset from PC+4 (J) or target in register (JR) Jump and link: save PC+4 in R31, target is PC-relative (JAL) or a register (JALR) Transfer to operating system at a vectored address Return to user code from an exception ISA p.15/28

MIPS Operations Floating Point Operations Instruction ADD.D,ADD.S,ADD.PS SUB.D,SUB.S,SUB.PS MUL.D,MUL.S,MUL.PS DIV.D,DIV.S,DIV.PS CVT._._ C..D,C..S Instruction meaning Add DP, SP numbers, and pairs of SP numbers Subtract DP, SP numbers, and pairs of SP numbers Multiply DP, SP numbers, and pairs of SP numbers Divide DP, SP numbers, and pairs of SP numbers CVT.x.y converts from type x to type y, where x and y are L (64-bit integer), W (64-bit integer), D (DP), or S (SP). Both operands are FPRs. DP and SP compares: =LT,GT,LE,GE,EQ,NE; sets bit in FP status register ISA p.16/28

MIPS Instruction Format (1) R-format add $1, $2, $3 # $1=$2+$3 6-bit 5-bit 5-bit 5-bit 5-bit 6-bit op rs rt rd shamt funct 0 2 3 1 0 32 0 0 0 0 0 0 0 0 0 1 0 0 0 0 1 1 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 ISA p.17/28

MIPS Instruction Format (2) I-format lw $1, 100($2) # $1=Memory[$2+100] 6-bit 5-bit 5-bit 16-bit op rs rt Address/Immediate 35 2 1 100 1 0 0 0 1 1 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 1 0 0 1 0 0 ISA p.18/28

MIPS Instruction Format (3) J-format j 10000 # jump to 10000 6-bit op 26-bit Target address 2 2500 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 1 1 0 0 0 1 0 0 ISA p.19/28

MIPS Instruction Examples add $s1, $s2, $s3 # $s1=$s2+$s3 6-bit 5-bit 5-bit 5-bit 5-bit 6-bit op rs rt rd shamt funct 0 18 19 17 0 32 0 0 0 0 0 0 1 0 0 1 0 1 0 0 1 1 1 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 sub $s1, $s2, $s3 # $s1=$s2 $s3 6-bit 5-bit 5-bit 5-bit 5-bit 6-bit op rs rt rd shamt funct 0 18 19 17 0 34 0 0 0 0 0 0 1 0 0 1 0 1 0 0 1 1 1 0 0 0 1 0 0 0 0 0 1 0 0 0 1 0 ISA p.20/28

MIPS Instruction Examples and $s1, $s2, $s3 # $s1=$s2 AND $s3 6-bit 5-bit 5-bit 5-bit 5-bit 6-bit op rs rt rd shamt funct 0 18 19 17 0 36 0 0 0 0 0 0 1 0 0 1 0 1 0 0 1 1 1 0 0 0 1 0 0 0 0 0 1 0 0 1 0 0 or $s1, $s2, $s3 # $s1=$s2 OR $s3 6-bit 5-bit 5-bit 5-bit 5-bit 6-bit op rs rt rd shamt funct 0 18 19 17 0 37 0 0 0 0 0 0 1 0 0 1 0 1 0 0 1 1 1 0 0 0 1 0 0 0 0 0 1 0 0 1 0 1 ISA p.21/28

MIPS Instruction Examples addi $s1, $s2, 100 # $s1=$s2+100 6-bit 5-bit 5-bit 16-bit op rs rt Immediate 8 18 17 100 0 0 1 0 0 0 1 0 0 1 0 1 0 0 0 1 0 0 0 0 0 0 0 0 0 1 1 0 0 1 0 0 andi $s1, $s2, 100 # $s1=$s2 AND 100 6-bit 5-bit 5-bit 16-bit op rs rt Immediate 12 18 17 100 0 0 1 1 0 0 1 0 0 1 0 1 0 0 0 1 0 0 0 0 0 0 0 0 0 1 1 0 0 1 0 0 ISA p.22/28

MIPS Instruction Examples ori $s1, $s2, 100 # $s1=$s2 OR 100 6-bit 5-bit 5-bit 16-bit op rs rt Immediate 13 18 17 100 0 0 1 1 0 1 1 0 0 1 0 1 0 0 0 1 0 0 0 0 0 0 0 0 0 1 1 0 0 1 0 0 sll $s1, $s2, 10 # $s1=shift($s2) left logical 10 bits 6-bit 5-bit 5-bit 5-bit 5-bit 6-bit op rs rt rd shamt funct 0 0 18 17 10 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 1 0 0 0 1 0 1 0 1 0 0 0 0 0 0 0 ISA p.23/28

MIPS Instruction Examples srl $s1, $s2, 10 #$s1=shift($s2) right logical 10 bits 6-bit 5-bit 5-bit 5-bit 5-bit 6-bit op rs rt rd shamt funct 0 0 18 17 10 2 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 1 0 0 0 1 0 1 0 1 0 0 0 0 0 2 0 lui $s1, 100 # $s1=100<<16 6-bit 5-bit 5-bit 16-bit op rs rt Immediate 15 0 17 100 0 0 1 1 1 1 0 0 0 0 0 1 0 0 0 1 0 0 0 0 0 0 0 0 0 1 1 0 0 1 0 0 ISA p.24/28

MIPS Instruction Examples lw $s1, 100($s2) # $s1=memory[$s2+100] 6-bit 5-bit 5-bit 16-bit op rs rt Address 35 18 17 100 1 0 0 0 1 1 1 0 0 1 0 1 0 0 0 1 0 0 0 0 0 0 0 0 0 1 1 0 0 1 0 0 sw $s1, 100($s2) # $Memory[$s2+100]=$s1 6-bit 5-bit 5-bit 16-bit op rs rt Address 43 18 17 100 1 0 1 0 1 1 1 0 0 1 0 1 0 0 0 1 0 0 0 0 0 0 0 0 0 1 1 0 0 1 0 0 ISA p.25/28

MIPS Instruction Examples beq $s1, $s2, 25 # if $s1=$s2, goto PC+4+25*4 6-bit 5-bit 5-bit 16-bit op rs rt Address 4 17 18 25 0 0 0 1 0 0 1 0 0 0 1 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 1 bne $s1, $s2, 25 # if $s1 $s2, goto PC+4+25*4 6-bit 5-bit 5-bit 16-bit op rs rt Address 5 17 18 25 0 0 0 1 0 1 1 0 0 0 1 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 1 ISA p.26/28

MIPS Instruction Examples slt $s1, $s2, $s3 # if $s2<$s3, $s1=1; else $s1=0 6-bit 5-bit 5-bit 5-bit 5-bit 6-bit op rs rt rd shamt funct 0 18 19 17 0 42 0 0 0 0 0 0 1 0 0 1 0 1 0 0 1 1 1 0 0 0 1 0 0 0 0 0 1 0 1 0 1 0 j 10000 # jump to 10000 6-bit op 26-bit Target address 2 2500 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 1 1 0 0 0 1 0 0 ISA p.27/28

MIPS Instruction Examples jal 10000 # $31=PC+4; jump to 10000 6-bit op 26-bit Target address 3 2500 0 0 0 0 1 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 1 1 0 0 0 1 0 0 jr $ra # jump register $ra 6-bit 5-bit 5-bit 5-bit 5-bit 6-bit op rs rt rd shamt funct 0 31 0 0 0 8 0 0 0 0 0 0 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 ISA p.28/28