3. MIPS Instruction Set1

이세진·2022년 4월 3일
0

Computer Science

목록 보기
48/74

생성일: 2021년 9월 12일 오후 6:31

Instruction Set (명령집합)

  • The vocabulary of commands understood by a given architecture
  • The words of a computer's language are called instructions, and its vocabulary is called instruction set

Machine Language

  1. Programming languages
    1. High level programming languages
      • C, C++, Java, Python....
  2. Assembly programming languages
    1. symbolic machine languages
  3. Machine languages
    1. Binary(1과0), IA32, IA64, ARM, MIPS, Power PC

Translator

  • Compiler : high-level language ⇒ machine language
  • Assembler : assembly language ⇒ machine language (A part of compiler)
  • Interpreter : Translate and execute programs directly
    • JVM(Java virtual machine)

Compiler

Source Program : high-level 언어로 작성된 프로그램
Target Program : machine 언어(x86, MIPS, ARM)로 작성된 프로그램

  • 좋은 Compiler는?
    • Generate correct code
    • Target code runs fast
    • Compiler runs fast
    • Support for separate compilation, good diagnostics for errors
  • Compilation Process

preprocessor = 전처리기

  • Compiler Phases

Machine State

  • ISA defines machine states and instructions
  • Registers(Register Files)
    • CPU internal storage to store data fetched from memory
      • Can be read or written in a single cycle
      • Arithmetic and logic operations are usually performed on registers
      • MIPS ISA has 32 32-bit registers: Each register consists of 32 flip-flops
    • Top level of the memory hierarchy
      • Registers ↔ Caches ↔ Memory ↔ Hard disk
      • Registers are visible to programmers and maintained by programmers
      • Caches are invisible to programmers and maintained by HW
  • Smaller is Faster
    • 32 registers의 제한 이유 : A very large number of registers may increase the clock cycle time simply because it takes electronic signals longer when they must travel farther

Memory

  • A large, single dimensional array, starting at address 0
  • Store programs (which contains both instructions and data)
  • To transfer data, use load (memory to register) and store (register to memory) instructions

Memory Operands (피연산자)

  • load = The data transfer instruction that copies data from memory to a register
  • The format of the load instruction is the name of the operation followed by the register to be loaded, then a constant and register used to access memory
  • memory address = constant portion of the instruction + contents of the second register forms

Data Size

  • word: the default data size for computation
    • 32b for 32b ISA, 64b for 64b ISA
  • Double word: 64b data
  • Half word: 16b data
  • Byte: 8b data

Machine Instruction

  • Opcode(연산코드) : Specifies the operation to be performed
    • ADD, MULT, LOAD, STORE, JUMP
  • Operands : Specifies the location of data
    • Source operands (input data)
    • Destination operands (output data)
    • The location can be
      • Memory operand specified by a memory address : Ex) 8(R2), x1004F
      • Register operand specified by a register number : R1

MIPS Instruction Types

  • Arithmetic and logic instructions
    • ADD, MULT, XOR, SHIFT...
  • Data transfer instructions (memory instructions)
    • LOAD, STORE
  • Control transfer instructions (branch instructions)
    • Change the program control flow
    • JUMP, CALL, RETURN, BEQ

MIPS Instruction Format - R type

32 bits long

MIPS Instruction Format - I type

32 bits long

MIPS Instruction Format - J type

32 bits long

  • Jump(j), Jump and link(jal) instructions have two fields
    • Opcode (6 bits)
    • Address (26 bits)

MIPS Addressing Modes

  • Register addressing
    • Address is in a register
    • jr $ra (indirect branches)
  • Base addressing
    • Address is the sum of register(base register) and a constant(offset)
    • Idw s0,100(s0, 100(s1)
  • Immediate addressing
    • For constant operands (immediate operand)
    • add $t1, $t2, 3
  • PC-relative addressing
    • Address is the sum of PC and constant(offset)
    • beq $s0, $s1, L1
  • Pseudodirect addressing
    • Address is the 26 bit offset concatenated with the upper bits of PC
    • j L 1

MIPS Instruction Example

profile
나중은 결코 오지 않는다.

0개의 댓글