본문 바로가기
Computer Science/Computer Architecture

Machine Instruction, ISA, and Computer

by Gofo 2021. 3. 18.

Machine Instruction

Assembly languages v.s. Binary languages

Binary languages와 Assembly languages는 둘 다 같은 abstraction level을 가지는 machine languages이다.

어셈블리 언어는 인간이 인지를 편히 할 수 있도록 만들어진 mnemonic으로, 실제 machine에서는 binary language로 변환되어 사용된다.

 

Relative address vs Absolute address

Instruction에서의 address는 absolute address를 사용하지 않는다.

이는 RISC style, 즉 32bit의 구조를 지키기 위해서이다.

 

만약 absolute address를 사용하게 되면 destination address만으로도 32bit가 되므로 RISC style을 지키지 못하게 된다.

32bit 단위를 맞추기 위해 opcode와 destination address를 32bit로 맞추게 되면 instruction fetch 과정에서부터이 2배 이상의 memory access가 필요하게 되며 결국 성능의 저하가 일어난다. 따라서 relative address를 사용한다.

 

Machine instruction (RISC style)

Machine instruction은 다음과 같은 종류로 구성된다.

  • Opcode
    • 8-bits
    • Instruction의 종류를 나타낸다.
    • Instruction decode는 opcode를 해석함으로써 어떤 instruction인지 찾는 것이다.
  • Registry
    • 5-bits
    • 레지스트리의 종류를 나타낸다.
  • Constant
    • various
    • 크기가 instruction의 종류에 따라 달라진다.

 


Instruction Set Architecture (ISA)

컴퓨터는 processor, memory, I/O devices로 이루어져있다.

Processor의 입장에서 I/O device는 load/store의 대상이므로 memory와 같게 볼 수 있다.

 

George Boole의 "The Laws of Thought"로부터 우리는 AND, OR, NOT, IF만 있다면 모든 논리를 표현할 수 있다.

즉, 데이터를 다루기 위한 load, store와 연산을 위한 add, jump만 있다면 모든 기능을 만들 수 있게 되는 것이다.

 

Insturction Set Architecture (ISA)

High-level language의 primitive인 statements는 결국 이러한 machine instruction들로 이루어져있는(추상화 된) 것이다.

  • ALU instructions
    • 연산 담당
    • add, sub, mult, div, and, or, not
  • Data transfer instruction(Memory access instruction)
    • memory, external memory, I/O device에 접근(read/wirte)한다.
    • load, store
  • Jump instruction
    • 조건 비교를 통해 수행한다.(IF의 기능)
    • jump if $=, \neq, >, <, \leq, \geq$

 

Load Instruction

Memory에서 program/data을 read하고 그 값을 어떠한 register에 저장한다.

<pre>LD destinatino_register source_register(relative)</pre>

 

예를 들어 <pre>LD R0 R31(0)</pre>은 (R31에 담겨있는 주소 + 0)에서부터 데이터를 읽어와서 R0에 저장한다.

 

Store Instruction

Source에 저장되어있는 data를 memory에 저장한다.

<pre>ST destination source(relative)</pre>

 

예를 들어 R2에 "0000 0005", R31에 "1000 0000"이 저장되어있고, <pre>ST R2, R31(+8)</pre>이 실행된다고 하자.

R31(+8)은 "1000 0008"이 되고, R2의 data는 "0000 0005"가 되므로,

address "1000 0008"번지의 memory에 "0000 0005"가 저장되는 것이다.

 

ADD Instruction

ALU에서 수행되는 ALU(processor internal) operation이다. 

 

만약 <pre>ADD R2, R0, R1</pre>이라는 instruction이 있다면,

R0의 data와 R1의 data을 더해서 R2 register에 넣는다.

 

JUMP Insturction

IF의 기능을 담당한다. ADD와 마찬가지로 ALU operation이다.

조건이 충족되면 jump operation을 수행하는 conditional jump instruction이다.

 

$=, \neq, >, <, \leq, \geq$을 조건으로 사용할 수 있다.

 

예를 들어, <pre>JUMP-POS R1, #4</pre>은 만약 R1의 data가 positive라면 address (PC + 4)로 이동하라는 의미이다.

 


ISA and Computer

Computer라는 Machine/processor는 ISA(Instruction Set Architecture)의 implementation이다.

 

컴퓨터를 사는 이유, 컴퓨터가 제공하는 interface, abstranction은 결국 다 ISA로 수렴한다.

 

Dependency

ISA와 OS API을 합해서 platform이라 한다. 예를 들어 Wintel(Windows + Intel) platform이 있다.

 

ISA에 따라서 programming하는 것이 달라지기 때문에 ISA(processor)는 독점성을 가진다. 이를 ISA Dependency라고 한다.

이로 인해서 platform dependency도 발생한다.

 

Platform에 따라 프로그래밍하는 것이 달라지기 때문에, 처음 platform을 선택한 후에 다른 platform으로 바꾸기 위해서는 처음부터 다시 프로그래밍을 해야 한다.

'Computer Science > Computer Architecture' 카테고리의 다른 글

Computer and Our Life  (0) 2021.03.18
Stored Program Concept  (0) 2021.03.18
Program Execution  (0) 2021.03.18
Data : type, storage, and C's data type  (0) 2021.03.17
Abstraction과 Software Design  (0) 2021.03.14

댓글