Computer Architecture - Chapter 2 Instructions (1)

nathan·2021년 10월 19일
0

Computer Architecture

목록 보기
3/3

Language of the Computer

Instructions in Memory(1)

  • Instructions are the language of computer
    • vocabulary
    • sentences with a formal grammer
  • Same ISA family supports same instructions
    • supports backward compatibility (하위호환성 지원)
  • Different computers have different instruction sets
    • but with many aspects in common
  • Early computers had very simple instruction sets
    • simplified implementation
  • Ever since, the ISA have tended to be complicated
    • called CISC (Complex Instruction Set Computer)
    • 고성능이지만 높은 파워 소모 -> 효율적 시스템 구성이 어려움
  • Many modern computers have simple instruction sets
    • called RISC (Reduced Instruction Set Computer)
    • 하나의 명령어가 수행할 수 있는 일의 크기를 줄여 각기 비슷한 일을 수행
    • 하나하나 성능은 떨어질 수 있으나 효율적 ISA 구축이 가능, 낮은 파워 소모

Instructions in Memory(2)

    1. Instructions are represented as numbers and, as such, are indistinguishable from data (데이터와 명령어는 구분이 안됨 - 숫자로 표현되기 때문)
    1. Programs are stored in alterable memory(that can be read or written to) just like data
  • Stored-program concept

    • Programs can be shipped as files of binary numbers - binary compatibility
    • Computers can inherit ready-made software provided they are compatible with an existing ISA

Subtract Example

  • C code : f = (g + h) - (i + j);
  • translates into the following assembly code

    add t0, g, h
    add t1, i, j
    sub f, t0, t1

  • Each version may produce a different result because floating-point operations are not necessarily associative(결합법칙) and commutative(교환법칙) ... more on this later

Operands

  • In C, each "variable" is a location in memory

  • In hardware, each memory access is expensive - if variable a is accessed repeatedly, it helps to bring the variable into an on-chip scratchpad and operate on the scratchpad (registers)

  • To simplify the instructions, we require that each instruction (add, sub) only operate on registers

  • Note : the number of operands (variables) in a C program is very large; the number of operands in assembly is fixed..

    • there can be only so many scratchpad registers
    • 레지스터 개수도 정해져 있음

Registers

  • The MIPS ISA has 32 registers (x86 has 8 registers) - Why not more? Why not less? Cost..
  • Each register is 32-bit wide (modern 64-bit architectures have 64-bit wide registers)
  • A 32-bit entity (4bytes) is referred to as a word
  • To make the code more readable, registers are partitioned as $s0-$s7 (C/Java variables), $t0-$t9 (temporary variables)
profile
나는 날마다 모든 면에서 점점 더 나아지고 있다.

0개의 댓글